agave-metadata/metadata-core/src/main/java/org/iplantc/service/metadata/model/serialization/MetadataItemSerializer.java
/**
     * Format {@link MetadataItem} to a {@link Document} with resolved links
     * @param document {@link Document} to format
     * @return {@link Document} equivalent of the MetadataItem
     */
Format  MetadataItem to a  Document with resolved links
@param document  Document to format
@return  Document equivalent of the MetadataItem
Format MetadataItem to a Document with resolved links @param document Document to format @return Document equivalent of the MetadataItem
public Document formatMetadataItemDocumentResult(Document document) throws UUIDException, PermissionException, MetadataAssociationException {
        Document hal = new Document();
        if (resourceURL == null)
            this.resourceURL = TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_METADATA_SERVICE);
        String uuid = document.getString("uuid");
        hal.put("self",
                new Document("href",
                        resourceURL + "data/" +
                                uuid));
        hal.put("permissions",
                new Document("href",
                        resourceURL + "data/" +
                                uuid + "/pems"));
        hal.put("owner",
                new Document("href",
                        resourceURL + document.getString("owner")));
        if (document.containsKey("associationIds")) {
            BasicDBList halAssociationIds = new BasicDBList();
            MetadataAssociationList associationList = new MetadataAssociationList();
            List<String> docAssociationList = document.getList("associationIds", String.class);
            if (docAssociationList.size() > 0)
                associationList.addAll(docAssociationList);
            halAssociationIds = formatAssociationIds(associationList);
            hal.put("associationIds", halAssociationIds);
        }
        if (document.containsKey("schemaId")) {
            String schemaId = document.getString("schemaId");
            if (schemaId != null && !StringUtils.isEmpty(schemaId)) {
                AgaveUUID agaveUUID = new AgaveUUID(schemaId);
                hal.append(agaveUUID.getResourceType().name(),
                        new Document("href", TenancyHelper.resolveURLToCurrentTenant(agaveUUID.getObjectReference())));
            }
        } else {
            document.put("schemaId", null); 
        }
        document.put("created", document.getDate("created").toInstant().toString());
        document.put("lastUpdated", document.getDate("lastUpdated").toInstant().toString());
        document.put("_links", hal);
        return document;
    }
public Document formatMetadataItemDocumentResult ( Document document ) throws UUIDException , PermissionException , MetadataAssociationException { Document hal = new Document ( ) ; if ( resourceURL == null ) this . resourceURL = TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_METADATA_SERVICE ) ; String uuid = document . getString ( "uuid" ) ; hal . put ( "self" , new Document ( "href" , resourceURL + "data/" + uuid ) ) ; hal . put ( "permissions" , new Document ( "href" , resourceURL + "data/" + uuid + "/pems" ) ) ; hal . put ( "owner" , new Document ( "href" , resourceURL + document . getString ( "owner" ) ) ) ; if ( document . containsKey ( "associationIds" ) ) { BasicDBList halAssociationIds = new BasicDBList ( ) ; MetadataAssociationList associationList = new MetadataAssociationList ( ) ; List < String > docAssociationList = document . getList ( "associationIds" , String . class ) ; if ( docAssociationList . size ( ) > 0 ) associationList . addAll ( docAssociationList ) ; halAssociationIds = formatAssociationIds ( associationList ) ; hal . put ( "associationIds" , halAssociationIds ) ; } if ( document . containsKey ( "schemaId" ) ) { String schemaId = document . getString ( "schemaId" ) ; if ( schemaId != null && ! StringUtils . isEmpty ( schemaId ) ) { AgaveUUID agaveUUID = new AgaveUUID ( schemaId ) ; hal . append ( agaveUUID . getResourceType ( ) . name ( ) , new Document ( "href" , TenancyHelper . resolveURLToCurrentTenant ( agaveUUID . getObjectReference ( ) ) ) ) ; } } else { document . put ( "schemaId" , null ) ; } document . put ( "created" , document . getDate ( "created" ) . toInstant ( ) . toString ( ) ) ; document . put ( "lastUpdated" , document . getDate ( "lastUpdated" ) . toInstant ( ) . toString ( ) ) ; document . put ( "_links" , hal ) ; return document ; }
Format {@link MetadataItem} to a {@link Document} with resolved links
 @param document {@link Document} to format
 @return {@link Document} equivalent of the MetadataItem
Format { @link MetadataItem } to a { @link Document } with resolved links @param document { @link Document } to format @return { @link Document } equivalent of the MetadataItem