agave-metadata/metadata-api/src/main/java/org/iplantc/service/metadata/resources/MetadataCollection.java
/**
     * Formats each metadata item returned with Agave decorations
     * @param metadataObject the bson object to format
     * @return bson object with hypermedia added and links resolved
     * @throws UUIDException if the associated uuid cannot be resolved.
     */
Formats each metadata item returned with Agave decorations
@param metadataObject the bson object to format
@return bson object with hypermedia added and links resolved
@throws UUIDException if the associated uuid cannot be resolved.
Formats each metadata item returned with Agave decorations @param metadataObject the bson object to format @return bson object with hypermedia added and links resolved @throws UUIDException if the associated uuid cannot be resolved .
private DBObject formatMetadataObject(DBObject metadataObject) throws UUIDException {
        metadataObject.removeField("_id");
        metadataObject.removeField("tenantId");
        BasicDBObject hal = new BasicDBObject();
        hal.put("self",
                new BasicDBObject("href",
                        TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_METADATA_SERVICE) + "data/" + metadataObject.get(
                                "uuid")));
        hal.put("permissions",
                new BasicDBObject("href",
                        TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_METADATA_SERVICE) + "data/" + metadataObject.get(
                                "uuid") + "/pems"));
        hal.put("owner",
                new BasicDBObject("href",
                        TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_PROFILE_SERVICE) + metadataObject.get("owner")));
        if (metadataObject.containsField("associationIds")) {
            BasicDBList halAssociationIds = new BasicDBList();
            for (Object associatedId : (BasicDBList) metadataObject.get("associationIds")) {
                AgaveUUID agaveUUID = new AgaveUUID((String) associatedId);
                try {
                    String resourceUrl = agaveUUID.getObjectReference();
                    BasicDBObject assocResource = new BasicDBObject();
                    assocResource.put("rel", associatedId);
                    assocResource.put("href", TenancyHelper.resolveURLToCurrentTenant(resourceUrl));
                    assocResource.put("title", agaveUUID.getResourceType().name().toLowerCase());
                    halAssociationIds.add(assocResource);
                } catch (UUIDException e) {
                    BasicDBObject assocResource = new BasicDBObject();
                    assocResource.put("rel", associatedId);
                    assocResource.put("href", null);
                    if (agaveUUID != null) {
                        assocResource.put("title", agaveUUID.getResourceType().name().toLowerCase());
                    }
                    halAssociationIds.add(assocResource);
                }
            }
            hal.put("associationIds", halAssociationIds);
        }
        if (metadataObject.get("schemaId") != null && !StringUtils.isEmpty(metadataObject.get("schemaId").toString())) {
            AgaveUUID agaveUUID = new AgaveUUID((String) metadataObject.get("schemaId"));
            hal.append(agaveUUID.getResourceType().name(),
                    new BasicDBObject("href", TenancyHelper.resolveURLToCurrentTenant(agaveUUID.getObjectReference())));
        }
        metadataObject.put("_links", hal);
        return metadataObject;
    }
private DBObject formatMetadataObject ( DBObject metadataObject ) throws UUIDException { metadataObject . removeField ( "_id" ) ; metadataObject . removeField ( "tenantId" ) ; BasicDBObject hal = new BasicDBObject ( ) ; hal . put ( "self" , new BasicDBObject ( "href" , TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_METADATA_SERVICE ) + "data/" + metadataObject . get ( "uuid" ) ) ) ; hal . put ( "permissions" , new BasicDBObject ( "href" , TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_METADATA_SERVICE ) + "data/" + metadataObject . get ( "uuid" ) + "/pems" ) ) ; hal . put ( "owner" , new BasicDBObject ( "href" , TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_PROFILE_SERVICE ) + metadataObject . get ( "owner" ) ) ) ; if ( metadataObject . containsField ( "associationIds" ) ) { BasicDBList halAssociationIds = new BasicDBList ( ) ; for ( Object associatedId : ( BasicDBList ) metadataObject . get ( "associationIds" ) ) { AgaveUUID agaveUUID = new AgaveUUID ( ( String ) associatedId ) ; try { String resourceUrl = agaveUUID . getObjectReference ( ) ; BasicDBObject assocResource = new BasicDBObject ( ) ; assocResource . put ( "rel" , associatedId ) ; assocResource . put ( "href" , TenancyHelper . resolveURLToCurrentTenant ( resourceUrl ) ) ; assocResource . put ( "title" , agaveUUID . getResourceType ( ) . name ( ) . toLowerCase ( ) ) ; halAssociationIds . add ( assocResource ) ; } catch ( UUIDException e ) { BasicDBObject assocResource = new BasicDBObject ( ) ; assocResource . put ( "rel" , associatedId ) ; assocResource . put ( "href" , null ) ; if ( agaveUUID != null ) { assocResource . put ( "title" , agaveUUID . getResourceType ( ) . name ( ) . toLowerCase ( ) ) ; } halAssociationIds . add ( assocResource ) ; } } hal . put ( "associationIds" , halAssociationIds ) ; } if ( metadataObject . get ( "schemaId" ) != null && ! StringUtils . isEmpty ( metadataObject . get ( "schemaId" ) . toString ( ) ) ) { AgaveUUID agaveUUID = new AgaveUUID ( ( String ) metadataObject . get ( "schemaId" ) ) ; hal . append ( agaveUUID . getResourceType ( ) . name ( ) , new BasicDBObject ( "href" , TenancyHelper . resolveURLToCurrentTenant ( agaveUUID . getObjectReference ( ) ) ) ) ; } metadataObject . put ( "_links" , hal ) ; return metadataObject ; }
Formats each metadata item returned with Agave decorations
 @param metadataObject the bson object to format
 @return bson object with hypermedia added and links resolved
 @throws UUIDException if the associated uuid cannot be resolved.
Formats each metadata item returned with Agave decorations @param metadataObject the bson object to format @return bson object with hypermedia added and links resolved @throws UUIDException if the associated uuid cannot be resolved .
// TODO: break this into a list of object under the associationIds attribute so // we dont' overwrite the objects in the event there are multiple of the same type.