As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
serviceRegistry.getNodeService().getProperty(file.getNodeRef(), ApplicationModel.PROP_ICON)
alfresco/service/api/node/workspace/SpacesStore/9d0f9136-ca36-49c3-8bdc-41020b465b3e
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"; } }
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); }