package open.dolphin.rest; import java.text.SimpleDateFormat; import java.util.Date; import java.util.logging.Logger; import open.dolphin.infomodel.IInfoModel; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import org.codehaus.jackson.map.annotate.JsonSerialize; /** * * @author Kazushi Minagawa, Digital Globe, Inc. */ public class AbstractResource { protected static final String CAMMA = ","; protected static final boolean DEBUG = false; protected Date parseDate(String source) { try { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(source); } catch (Exception e) { e.printStackTrace(System.err); } return null; } protected void debug(String msg) { Logger.getLogger("open.dolphin").fine(msg); } protected static String getRemoteFacility(String remoteUser) { int index = remoteUser.indexOf(IInfoModel.COMPOSITE_KEY_MAKER); return remoteUser.substring(0, index); } protected static String getFidPid(String remoteUser, String pid) { StringBuilder sb = new StringBuilder(); sb.append(getRemoteFacility(remoteUser)); sb.append(IInfoModel.COMPOSITE_KEY_MAKER); sb.append(pid); return sb.toString(); } // 2013/06/24 protected static ObjectMapper getSerializeMapper() { ObjectMapper mapper = new ObjectMapper(); //mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); return mapper; } }