protected void applyUpdateOperationRules( UpdateRequest updateRequest, Entry<Serializable, Metacard> anUpdate, Metacard aMetacard, Date now) { if (UpdateRequest.UPDATE_BY_ID.equals(updateRequest.getAttributeName()) && !anUpdate.getKey().toString().equals(aMetacard.getId())) { LOGGER.info( "{} in metacard must match the Update {}, overwriting metacard {} [{}] with the update identifier [{}]", Metacard.ID, Metacard.ID, Metacard.ID, aMetacard.getId(), anUpdate.getKey()); aMetacard.setAttribute(new AttributeImpl(Metacard.ID, anUpdate.getKey())); } if (aMetacard.getCreatedDate() == null) { LOGGER.info( "{} date should match the original metacard. Changing date to current timestamp so it is at least not null.", Metacard.CREATED); aMetacard.setAttribute(new AttributeImpl(Metacard.CREATED, now)); } if (aMetacard.getModifiedDate() == null) { aMetacard.setAttribute(new AttributeImpl(Metacard.MODIFIED, now)); } if (aMetacard.getEffectiveDate() == null) { aMetacard.setAttribute(new AttributeImpl(Metacard.EFFECTIVE, now)); } }
protected void applyCreatedOperationRules( CreateRequest createRequest, Metacard aMetacard, Date now) { LOGGER.debug("Applying standard rules on CreateRequest"); aMetacard.setAttribute( new AttributeImpl(Metacard.ID, UUID.randomUUID().toString().replaceAll("-", ""))); if (aMetacard.getCreatedDate() == null) { aMetacard.setAttribute(new AttributeImpl(Metacard.CREATED, now)); } if (aMetacard.getModifiedDate() == null) { aMetacard.setAttribute(new AttributeImpl(Metacard.MODIFIED, now)); } if (aMetacard.getEffectiveDate() == null) { aMetacard.setAttribute(new AttributeImpl(Metacard.EFFECTIVE, now)); } }
@Override public Metacard transform(InputStream inputStream, String id) throws IOException, CatalogTransformerException { Metacard metacard = null; try { metacard = (Metacard) xstream.fromXML(inputStream); if (StringUtils.isNotEmpty(id)) { metacard.setAttribute(new AttributeImpl(Metacard.ID, id)); } } catch (XStreamException e) { throw new CatalogTransformerException("Unable to transform from CSW Record to Metacard.", e); } finally { IOUtils.closeQuietly(inputStream); } if (metacard == null) { throw new CatalogTransformerException("Unable to transform from CSW Record to Metacard."); } return metacard; }