[confluence-cmis-plugin] r117 committed - Provide a velocity object for null checks, translate the properties li...

5 views
Skip to first unread message

confluence-...@googlecode.com

unread,
Jun 7, 2010, 11:40:16 AM6/7/10
to conflue...@googlegroups.com
Revision: 117
Author: c.sc...@sourcesense.com
Date: Mon Jun 7 08:26:30 2010
Log: Provide a velocity object for null checks, translate the properties
list into a Map for handier velocity templating
http://code.google.com/p/confluence-cmis-plugin/source/detail?r=117

Modified:
/trunk/src/main/java/com/sourcesense/confluence/cmis/BaseCMISMacro.java

=======================================
--- /trunk/src/main/java/com/sourcesense/confluence/cmis/BaseCMISMacro.java
Mon Jun 7 02:42:55 2010
+++ /trunk/src/main/java/com/sourcesense/confluence/cmis/BaseCMISMacro.java
Mon Jun 7 08:26:30 2010
@@ -23,10 +23,17 @@
import com.atlassian.renderer.v2.macro.MacroException;
import com.sourcesense.confluence.cmis.utils.ConfluenceCMISRepository;
import com.sourcesense.confluence.cmis.utils.RepositoryStorage;
+import com.sourcesense.confluence.cmis.utils.VelocityNullChecker;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Property;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.log4j.Logger;

+import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
import java.util.Map;

public abstract class BaseCMISMacro extends BaseMacro {
@@ -39,6 +46,10 @@
protected static final String PARAM_USEPROXY = "useproxy";
protected static final String PARAM_PROPERTIES = "properties";

+ // Velocity placeholders
+ protected static final String VM_DOCUMENT_PROPERTIES
= "documentProperties";
+ protected static final String VM_DOCUMENT_LINK = "documentLink";
+
public static final java.lang.String REPOSITORY_NAME
= "com.sourcesense.confluence.cmis.repository.name";

protected static final int DEFAULT_RESULTS_NUMBER = 20;
@@ -72,6 +83,8 @@

populateParams(params, body, renderContext, repositoryConfluence);

+ renderContext.addParam("check", new VelocityNullChecker());
+
return executeImpl(params, body, renderContext,
repositoryConfluence);
}
catch (Exception e) {
@@ -102,6 +115,25 @@
params.put(BaseCMISMacro.PARAM_USEPROXY, Boolean.FALSE);
}
}
+
+ protected Map<String, String> getPropertiesMap (CmisObject object)
+ {
+ Map<String, String> propMap = new HashMap<String, String>();
+
+ for (Property<?> prop : object.getProperties())
+ {
+ String stringValue = prop.getValueAsString();
+ if (PropertyType.DATETIME.equals(prop.getType()))
+ {
+ Calendar cal = (Calendar) prop.getFirstValue();
+ DateFormat df = DateFormat.getDateTimeInstance();
+ stringValue = df.format(cal.getTime());
+ }
+ propMap.put(prop.getDisplayName(), stringValue);
+ }
+
+ return propMap;
+ }

protected abstract String executeImpl(Map params, String body,
RenderContext renderContext, ConfluenceCMISRepository repositoryConfluence)
throws MacroException;

Reply all
Reply to author
Forward
0 new messages