agave-metadata/metadata-api/src/main/java/org/iplantc/service/metadata/resources/MetadataResource.java
/**
	 * This method represents the HTTP GET action. The input files for the authenticated user are
	 * retrieved from the database and sent to the user as a {@link org.json.JSONArray JSONArray}
	 * of {@link org.json.JSONObject JSONObject}.
	 *
	 */
This method represents the HTTP GET action. The input files for the authenticated user are
retrieved from the database and sent to the user as a  org.json.JSONArray JSONArray
of  org.json.JSONObject JSONObject.
This method represents the HTTP GET action . The input files for the authenticated user are retrieved from the database and sent to the user as a org . json . JSONArray JSONArray of org . json . JSONObject JSONObject .
@Override
	public Representation represent(Variant variant) throws ResourceException {
		try {
			AgaveLogServiceClient.log(METADATA02.name(), MetaGetById.name(), username, "", getRequest().getClientInfo().getUpstreamAddress());
			String strResult = "";
			MetadataDao dao = MetadataDao.getInstance();
			MetadataPermissionManager permissionManager = new MetadataPermissionManager(uuid, username);
			if (!permissionManager.canRead(username)) {
				getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN);
				return new IplantErrorRepresentation("Cannot validate - User does not have permission to read this metadata entry.");
			}
			MetadataSearch search = new MetadataSearch(username);
			search.setAccessibleOwnersImplicit();
			String tenantId = TenancyHelper.getCurrentTenantId();
			if (hasJsonPathFilters()){
				Document userResult = search.filterFindById(uuid, tenantId, jsonPathFilters);
				if (userResult == null)
					throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND,
							"No metadata item found for user with id " + uuid);
				strResult = userResult.toJson();
			} else {
				MetadataItem metadataItem = search.findById(uuid, tenantId);
				if (metadataItem == null)
					throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND,
							"No metadata item found for user with id " + uuid);
				MetadataItemSerializer metadataItemSerializer = new MetadataItemSerializer();
				strResult = metadataItemSerializer.formatMetadataItemJsonResult(metadataItem).toString();
			}
			return new IplantSuccessRepresentation(strResult);
		}
		catch (ResourceException e) {
			log.error("Failed to fetch metadata " + uuid + " for user " + username);
			throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage());
		}
		catch (Throwable e) {
			log.error("Failed to list metadata " + uuid, e);
			throw new ResourceException(Status.SERVER_ERROR_INTERNAL,
					"An unexpected error occurred while fetching the metadata item. "
							+ "If this continues, please contact your tenant administrator.", e);
		}
	}
@ Override public Representation represent ( Variant variant ) throws ResourceException { try { AgaveLogServiceClient . log ( METADATA02 . name ( ) , MetaGetById . name ( ) , username , "" , getRequest ( ) . getClientInfo ( ) . getUpstreamAddress ( ) ) ; String strResult = "" ; MetadataDao dao = MetadataDao . getInstance ( ) ; MetadataPermissionManager permissionManager = new MetadataPermissionManager ( uuid , username ) ; if ( ! permissionManager . canRead ( username ) ) { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_FORBIDDEN ) ; return new IplantErrorRepresentation ( "Cannot validate - User does not have permission to read this metadata entry." ) ; } MetadataSearch search = new MetadataSearch ( username ) ; search . setAccessibleOwnersImplicit ( ) ; String tenantId = TenancyHelper . getCurrentTenantId ( ) ; if ( hasJsonPathFilters ( ) ) { Document userResult = search . filterFindById ( uuid , tenantId , jsonPathFilters ) ; if ( userResult == null ) throw new ResourceException ( Status . CLIENT_ERROR_NOT_FOUND , "No metadata item found for user with id " + uuid ) ; strResult = userResult . toJson ( ) ; } else { MetadataItem metadataItem = search . findById ( uuid , tenantId ) ; if ( metadataItem == null ) throw new ResourceException ( Status . CLIENT_ERROR_NOT_FOUND , "No metadata item found for user with id " + uuid ) ; MetadataItemSerializer metadataItemSerializer = new MetadataItemSerializer ( ) ; strResult = metadataItemSerializer . formatMetadataItemJsonResult ( metadataItem ) . toString ( ) ; } return new IplantSuccessRepresentation ( strResult ) ; } catch ( ResourceException e ) { log . error ( "Failed to fetch metadata " + uuid + " for user " + username ) ; throw new ResourceException ( Status . CLIENT_ERROR_NOT_FOUND , e . getMessage ( ) ) ; } catch ( Throwable e ) { log . error ( "Failed to list metadata " + uuid , e ) ; throw new ResourceException ( Status . SERVER_ERROR_INTERNAL , "An unexpected error occurred while fetching the metadata item. " + "If this continues, please contact your tenant administrator." , e ) ; } }
This method represents the HTTP GET action.
This method represents the HTTP GET action .
// Include user defined query clauses given within the URL as q=<clauses> // TODO: Should be folded into the fetch call? Much faster, but also removes ability to determine pems //   vs a standard not found.