Posts

Alfresco Content Model

Image
Alfresco Content models are defined in the Data Dictonary as meta-model. The meta-model consists of two main structures - Content Types and Content Aspect . Content Type is the fundamental Structure of a content item. It defines the composition of properties and behaviours of a content item. Much like in the object-oriented programming model where an object always has to be a defined class type, in Alfresco an item has to be a defined type also. Types are like types or classes in the object-oriented world. They can be used to model business objects, they have properties, and they can inherit from a parent type. “Content”, “Person”, and “Folder” are three important types defined out-of-the-box. There is a root content type defined in Alfresco, all other content types are created inheriting this root type - cm:content or {http://www.alfresco.org/model/content/1.0}content There are two parts in defining the name Namespace of the content type Name of the content type ...

Lucene vs Solr

1) Solr uses Lucene under the hood. Lucene has no clue about the Solr API. 2) Lucene is a powerful search engine framework that lets us add search capability to our application. It exposes an easy-to-use API while hiding all the search-related complex operations. Any application can use this library, not just Solr. 3) Solr is built around Lucene. It is not just an http-wrapper around Lucene but has been known to add more arsenal to Lucene . Solr is ready-to-use out of box. It is a web application that offers related infrastructure and a lot more features in addition to what Lucene offers. 4) Lucene doesn't just create the Index for the consumption by Solr . Lucene handles all the search related operations. Any application can use the Lucene framework. When to use Lucene? You are a search engineer AND You are a programmer AND You want full control over almost all the internals of Lucene AND Your requirements demand you to do all sorts of geeky customization to ...

Update content in Webscript

private void updateContent(NodeRef nodeRef, String path, String fileName, boolean newFile)     {         // Make versionable         nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);         // Update content         InputStream is = this.getClass().getClassLoader().getResourceAsStream(path + fileName);         if (is != null)         {             ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);             if (newFile == true)             {                 contentWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);                 contentWriter.setEncoding("UTF-8");            ...

Good Practice to get response in webscript

Body requestBodyObject = JsonUtility.buildRequestBodyObject(jsonRequest); Map<String,Object> mapOfParams = requestBodyObject.getBody(); String noderef = JavaUtility.extractParameterFromMap(mapOfParams,"noderef"); NodeRef fileNodeRef = new NodeRef(noderef); public static String extractParameterFromMap(Map<String,Object> mapOfParams,String paramName) { String paramValue = ""; if(mapOfParams.containsKey(paramName)){ paramValue = (String)mapOfParams.get(paramName); } return paramValue; } public class JsonUtility { public static Body buildRequestBodyObject(String jsonRequest){ Gson gson = new GsonBuilder().create(); return gson.fromJson(jsonRequest, Body.class); } } =============================================================================== public class Response { private ResponseContainer response; public ResponseContainer getResponse() { return response; } public void setResponse...

Post WebScript

public class JsonUtility { public static Body buildRequestBodyObject(String jsonRequest){ Gson gson = new GsonBuilder().create(); return gson.fromJson(jsonRequest, Body.class); } public static Map<String,PermissionSet> convertToTypePermissionSet(String jsonRequestFromPermSet){ Type t = new TypeToken<Map<String,PermissionSet>>() {}.getType(); Map<String,PermissionSet> map = (Map<String,PermissionSet>) new Gson().fromJson(jsonRequestFromPermSet, t); return map; } } ------------------------------------------------------------------------------------------------------------------ public class JavaUtility { public static final int SUBSTR_END = 1; public static final int GROUPPREFIX_SUBSTR_END = 6; public static final String JSON_PERMSET_STR = "\"permissionSet\""; public static final String JSON_PERMCODE_STR = "\"permissionCode\""; public static final String JSON_PERMSETOBJ...

Get Global Properties

private Properties properties;     /**      *      * @method setProperties      * @param properties      */     public void setProperty(Properties properties)     {       logger.debug("setting properties");       this.properties = properties;     }     public String getGlobalProp(String propName)     {       logger.debug("getting properties");       return this.properties.getProperty(propName);     } ====================== Properties properties; public Map<String, Object> executeImpl(WebScriptRequest request, Status status) { String alf_dir =  properties.getProperty("dir.root"); } public Properties getProperties() { return properties; } public void setProperties(Properties properties) { this.properties = properties; } =========...

Alfresco log4j.properties and log after conversion JSON Log

# Set root logger level to error log4j.rootLogger=info, Console, File ###### Console appender definition ####### # All outputs currently set to be a ConsoleAppender. log4j.appender.Console=org.apache.log4j.ConsoleAppender #log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout=com.demo.logger.layout.json.SplunkJsonLayout # use log4j NDC to replace %x with tenant domain / username log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} %x %-5p [%c{3}] [%t] %m%n #log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n ###### File appender definition ####### log4j.appender.File=org.apache.log4j.DailyRollingFileAppender log4j.appender.File.File=alfresco.log log4j.appender.File.Append=true log4j.appender.File.DatePattern='.'yyyy-MM-dd #log4j.appender.File.layout=org.apache.log4j.PatternLayout log4j.appender.File.layout=com.demo.logger.layout.json.SplunkJsonLayout log4j.appender.File.layout.Conversion...