02-23-2011 06:41 AM
serviceRegistry.getNodeService().getProperty(file.getNodeRef(), ApplicationModel.PROP_ICON)
returns null. When I run :alfresco/service/api/node/workspace/SpacesStore/9d0f9136-ca36-49c3-8bdc-41020b465b3e
there is a attribute called "alf:icon", but I cant figure out the way to get access to these attributes with the java api.02-23-2011 08:58 AM
02-26-2011 04:11 PM
public String getDownloadURL(NodeRef nodeRef){
DictionaryService dictionaryService = serviceRegistry.getDictionaryService();
NodeService nodeService = serviceRegistry.getNodeService();
boolean isDocument = dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT);
if(!isDocument)
throw new AlfrescoRuntimeException("The node is a cm:content subclass");
return "/alfresco/service/api/node/content/" + nodeRef.getStoreRef().getProtocol() + "/"
+ nodeRef.getStoreRef().getProtocol() + "/" + nodeRef.getId();
}
public String getIconURL(NodeRef nodeRef, boolean small){
DictionaryService dictionaryService = serviceRegistry.getDictionaryService();
NodeService nodeService = serviceRegistry.getNodeService();
boolean isDocument = dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT);
if(isDocument){
return FileTypeImageUtils.getFileTypeImage((String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME), small);
} else { //the node is subtype of folder
return "/images/icons/" + nodeService.getProperty(nodeRef, ApplicationModel.PROP_ICON) + (small ? "-16" : "") + ".gif";
}
}
02-26-2011 04:45 PM
02-28-2011 08:36 AM
03-02-2011 02:31 PM
private static String getFileTypeImage(FacesContext fc, ServletContext sc, String name, FileTypeImageSize size)
{
String image = null;
String defaultImage = null;
switch (size)
{
case Small:
defaultImage = DEFAULT_FILE_IMAGE16; break;
case Medium:
defaultImage = DEFAULT_FILE_IMAGE32; break;
case Large:
defaultImage = DEFAULT_FILE_IMAGE64; break;
}
int extIndex = name.lastIndexOf('.');
if (extIndex != -1 && name.length() > extIndex + 1)
{
String ext = name.substring(extIndex + 1).toLowerCase();
String key = ext + ' ' + size.toString();
// found file extension for appropriate size image
synchronized (s_fileExtensionMap)
{
image = s_fileExtensionMap.get(key);
if (image == null)
{
// not found create for first time
if (size != FileTypeImageSize.Large)
{
image = (size == FileTypeImageSize.Small ? IMAGE_PREFIX16 : IMAGE_PREFIX32) +
ext + IMAGE_POSTFIX_GIF;
}
else
{
image = IMAGE_PREFIX64 + ext + IMAGE_POSTFIX_PNG;
}
// does this image exist on the web-server?
if ((fc != null && fc.getExternalContext().getResourceAsStream(image) != null) ||
(sc != null && sc.getResourceAsStream(image) != null))
{
// found the image for this extension - save it for later
s_fileExtensionMap.put(key, image);
}
else if ((fc == null) && (sc == null))
{
// we have neither FacesContext nor ServerContext so return the default image but don't cache it
image = defaultImage;
}
else
{
// not found, save the default image for this extension instead
s_fileExtensionMap.put(key, defaultImage);
image = defaultImage;
}
}
}
}
return (image != null ? image : defaultImage);
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.