use of org.alfresco.rest.framework.metadata.ResourceMetaDataWriter in project alfresco-remote-api by Alfresco.
the class WebScriptOptionsMetaData method execute.
@Override
public void execute(final Api api, WebScriptRequest req, WebScriptResponse res) throws IOException {
final Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
ResourceDictionary resourceDic = lookupDictionary.getDictionary();
Map<String, ResourceWithMetadata> apiResources = resourceDic.getAllResources().get(api);
if (apiResources == null) {
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_INVALID_API);
}
String collectionName = templateVars.get(ResourceLocator.COLLECTION_RESOURCE);
String resourceName = templateVars.get(ResourceLocator.RELATIONSHIP_RESOURCE);
String resourceKey = ResourceDictionary.resourceKey(collectionName, resourceName);
if (logger.isDebugEnabled()) {
logger.debug("Locating resource :" + resourceKey);
}
ResourceWithMetadata resource = apiResources.get(resourceKey);
if (resource == null) {
// Get entity resource and check if we are referencing a property on it.
resourceKey = ResourceDictionary.propertyResourceKey(collectionName, resourceName);
resource = apiResources.get(resourceKey);
}
ResourceMetaDataWriter writer = chooseWriter(req);
writer.writeMetaData(res.getOutputStream(), resource, apiResources);
}
Aggregations