ResourceDAO resourceDAO = registryContext.getDataAccessManager().getDAOManager().
getResourceDAO();
TagsDAO tagsDAO = registryContext.getDataAccessManager().getDAOManager().
getTagsDAO(StaticConfiguration.isVersioningTags());
ResourcePath resourcePath = requestContext.getResourcePath();
String tagDetails = resourcePath.getParameterValue("tags");
if (tagDetails != null) {
String[] queries = tagDetails.split(":");
if (queries.length != 2) {
return null;
}
String path = resourcePath.getPath();
String tagName = queries[0];
String userName = queries[1];
TaggingDO taggingDO = null;
ResourceIDImpl resourceIDImpl = resourceDAO.getResourceID(path);
if (resourceIDImpl != null) {
ResourceImpl resourceImpl = resourceDAO.getResourceMetaData(resourceIDImpl);
if (resourceImpl != null) {
TaggingDO[] taggingDOs = tagsDAO.getTagging(resourceImpl, tagName, userName);
taggingDO = taggingDOs[0];
}
}
ResourceImpl resource = new ResourceImpl();
resource.setMediaType(RegistryConstants.TAG_MEDIA_TYPE);
resource.setPath(resourcePath.getCompletePath());
if (taggingDO != null) {
resource.setContent(taggingDO.getTagName());
resource.setAuthorUserName(taggingDO.getTaggedUserName());
final Date taggedTime = taggingDO.getTaggedTime();
resource.setCreatedTime(taggedTime);