chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r959348 - in /incubator/chemistry/opencmis-browser-binding/trunk/src/main: java/org/apache/chemistry/opencmis/server/impl/browser/ java/org/apache/chemistry/opencmis/server/impl/browser/json/ webapp/
Date Wed, 30 Jun 2010 15:22:49 GMT
Author: fmui
Date: Wed Jun 30 15:22:48 2010
New Revision: 959348

URL: http://svn.apache.org/viewvc?rev=959348&view=rev
Log:
- added getChildren demo

Modified:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java?rev=959348&r1=959347&r2=959348&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
Wed Jun 30 15:22:48 2010
@@ -27,7 +27,6 @@ import javax.xml.bind.annotation.XmlRegi
 import javax.xml.namespace.QName;
 
 import org.apache.chemistry.opencmis.commons.impl.JaxBHelper.CMISExtraObjectFactory;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.ObjectFactory;
@@ -66,11 +65,5 @@ public class CmisJaxbContextResolver imp
             return new JAXBElement<CmisTypeDefinitionListType>(new QName("typeDefintionList"),
                     CmisTypeDefinitionListType.class, value);
         }
-
-        @XmlElementDecl(name = "objectInFolderList")
-        public JAXBElement<CmisObjectInFolderListType> createObjectInFolderList(CmisObjectInFolderListType
value) {
-            return new JAXBElement<CmisObjectInFolderListType>(new QName("objectInFolderList"),
-                    CmisObjectInFolderListType.class, value);
-        }
     }
 }

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java?rev=959348&r1=959347&r2=959348&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
Wed Jun 30 15:22:48 2010
@@ -40,7 +40,6 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.impl.Converter;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
 import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
@@ -196,8 +195,7 @@ public class CmisResource {
     @GET
     @Path("/folder/{repositoryId}")
     @Produces(MediaType.APPLICATION_JSON)
-    public JAXBElement<CmisObjectInFolderListType> getChildren(@PathParam("repositoryId")
String repositoryId,
-            @QueryParam("id") String folderId) {
+    public String getChildren(@PathParam("repositoryId") String repositoryId, @QueryParam("id")
String folderId) {
         CmisService service = null;
 
         try {
@@ -206,8 +204,7 @@ public class CmisResource {
             ObjectInFolderList children = service.getChildren(repositoryId, folderId, null,
null, true,
                     IncludeRelationships.NONE, null, true, null, null, null);
 
-            return CmisJaxbContextResolver.CMIS_JSON_OBJECT_FACTORY.createObjectInFolderList(Converter
-                    .convert(children));
+            return JSONConverter.convert(children).toJSONString();
         } finally {
             if (service != null) {
                 service.close();

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java?rev=959348&r1=959347&r2=959348&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
Wed Jun 30 15:22:48 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.chemistry.opencmis.server.impl.browser.json;
 
-
 public class JSONConstants {
 
     public final static String JSON_REPINFO_ID = "repositoryId";
@@ -72,6 +71,7 @@ public class JSONConstants {
     public final static String JSON_OBJECT_EXACT_ACL = "exactACL";
     public final static String JSON_OBJECT_POLICY_IDS = "policyIds";
     public final static String JSON_OBJECT_RENDITION = "rendition";
+    public final static String JSON_OBJECT_PATH_SEGMENT = "pathSegment";
 
     public final static String JSON_PROPERTY_ID = "id";
     public final static String JSON_PROPERTY_LOCAL_NAME = "localName";
@@ -97,4 +97,8 @@ public class JSONConstants {
     public final static String JSON_RENDITION_HEIGHT = "height";
     public final static String JSON_RENDITION_WIDTH = "width";
     public final static String JSON_RENDITION_DOCUMENT_ID = "renditionDocumentId";
+
+    public final static String JSON_OBJECTINFOLDERLIST_OBJECTS = "objects";
+    public final static String JSON_OBJECTINFOLDERLIST_HAS_MORE_ITEMS = "hasMoreItems";
+    public final static String JSON_OBJECTINFOLDERLIST_NUM_ITEMS = "numItems";
 }

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java?rev=959348&r1=959347&r2=959348&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
Wed Jun 30 15:22:48 2010
@@ -27,6 +27,8 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
 import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
 import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
 import org.apache.chemistry.opencmis.commons.data.PropertyBoolean;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
@@ -351,6 +353,48 @@ public class JSONConverter extends JSONC
         return result;
     }
 
+    /**
+     * Converts an object in a folder list.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectInFolderData objectInFolder) {
+        if ((objectInFolder == null) || (objectInFolder.getObject() == null)) {
+            return null;
+        }
+
+        JSONObject result = convert(objectInFolder.getObject());
+        result.put(JSON_OBJECT_PATH_SEGMENT, objectInFolder.getPathSegment());
+
+        return result;
+    }
+
+    /**
+     * Converts a folder list.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectInFolderList objectInFolderList) {
+        if (objectInFolderList == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        if (objectInFolderList.getObjects() != null) {
+            JSONArray objects = new JSONArray();
+
+            for (ObjectInFolderData object : objectInFolderList.getObjects()) {
+                objects.add(convert(object));
+            }
+
+            result.put(JSON_OBJECTINFOLDERLIST_OBJECTS, objects);
+        }
+
+        result.put(JSON_OBJECTINFOLDERLIST_HAS_MORE_ITEMS, objectInFolderList.hasMoreItems());
+        result.put(JSON_OBJECTINFOLDERLIST_NUM_ITEMS, objectInFolderList.getNumItems());
+
+        return result;
+    }
+
     // -----------------------------------------------------------------
 
     public static String getJSONStringValue(Object obj) {

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp?rev=959348&r1=959347&r2=959348&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp Wed Jun 30
15:22:48 2010
@@ -7,17 +7,22 @@
 <style type="text/css">
   body {
     font-family:Arial,sans-serif;
+    font-size:11pt;
   }
-  .box { 
+  .box {
     border-width:1px;
-    border-style:solid; 
+    border-style:solid;
     width:100%;
+    padding:3px;
+  }
+  td {
+    padding:5px;
   }
 </style>
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function(){
-  $.getJSON('<%=request.getContextPath()%>/browser/repositories', 
+  $.getJSON('<%=request.getContextPath()%>/browser/repositories',
     function(riData) {
       var ri = riData[0];
       $('#repositoryInfo').html(
@@ -30,16 +35,16 @@ $(document).ready(function(){
         '<tr><td>Root folder id:</td><td>' + ri.rootFolderId + '</td></tr>'
+
         '</table>');
 
-      $.getJSON(encodeURI('<%=request.getContextPath()%>/browser/object/' + ri.repositoryId
+ '?id=' + ri.rootFolderId), 
+      $.getJSON(encodeURI('<%=request.getContextPath()%>/browser/object/' + ri.repositoryId
+ '?id=' + ri.rootFolderId),
         function(objData) {
           var id = objData.properties["cmis:objectId"].values[0];
           var name = objData.properties["cmis:name"].values[0];
-          
+
           var s = '<h2>Object "' + name + '" (' + id + ')</h2>';
 
           s = s + '<h3>Properties</h3>';
           s = s + '<table>';
-          
+
           var propertyId;
           for(propertyId in objData.properties) {
               var property = objData.properties[propertyId];
@@ -50,13 +55,13 @@ $(document).ready(function(){
                   if(property.type == 'datetime') {
                       value = new Date(value);
                   }
-                  
+
                   s = s + value + '<br/>';
               }
-               
+
                s = s + '</td></tr>';
-          }          
-          
+          }
+
           s = s + '</table>';
 
           s = s + '<h3>(Some) Allowable Actions</h3>';
@@ -65,11 +70,50 @@ $(document).ready(function(){
           s = s + '<tr><td>Can get children:</td><td>' + objData.allowableActions.canGetChildren
+ '</td></tr>';
           s = s + '<tr><td>Can get content stream:</td><td>' + objData.allowableActions.canGetContentStream
+ '</td></tr>';
           s = s + '</table>';
-          
-    	  $('#objectInfo').html(s);
+
+          $('#objectInfo').html(s);
         });
+
+        $.getJSON(encodeURI('<%=request.getContextPath()%>/browser/folder/' + ri.repositoryId
+ '?id=' + ri.rootFolderId),
+          function(children) {
+            var s = '<h2>Children</h2>';
+            s = s + '<table><tr><th>Name</th><th>Type</th><th>MIME
Type</th><th>Size</th>' +
+            '<th>Created By</th><th>Created At</th><th>Id</th></tr>';
+
+            for(var i in children.objects) {
+                var object = children.objects[i];
+
+                var name = object.properties["cmis:name"].values[0];
+                var type = object.properties["cmis:objectTypeId"].values[0];
+                var mimetype = "";
+                var size = "";
+                var createdBy = object.properties["cmis:createdBy"].values[0];
+                var creationDate = new Date(object.properties["cmis:creationDate"].values[0]);
+                var id = object.properties["cmis:objectId"].values[0];
+                var link = "";
+
+                if(object.properties["cmis:baseTypeId"].values[0] == "cmis:document") {
+                    size = object.properties["cmis:contentStreamLength"].values[0];
+                    mimetype = object.properties["cmis:contentStreamMimeType"].values[0];
+                    link = encodeURI('<%=request.getContextPath()%>/browser/content/'
+ ri.repositoryId + '?id=' + id);
+                }
+
+                s = s + '<tr><td>';
+                if(link != "") {
+                    s = s + '<a href="' + link + '">' + name + '</a>';
+                }
+                else {
+                    s = s + name;
+                }
+                s = s + '</td><td>' + type + '</td><td>' + mimetype
+ '</td><td style="rext-align:right">' + size +
+                 '</td><td>' + createdBy + '</td><td>' + creationDate
+ '</td><td>' + id + '</td></tr>';
+            }
+
+            s = s + '</table>';
+            $('#folderInfo').html(s);
+          });
    });
-});     
+});
 </script>
 </head>
 <body>
@@ -82,5 +126,9 @@ RepositoryInfo
 <div id="objectInfo" class="box">
 objectInfo
 </div>
+<br/>
+<div id="folderInfo" class="box">
+folderInfo
+</div>
 </body>
 </html>
\ No newline at end of file

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp?rev=959348&r1=959347&r2=959348&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp Wed Jun 30
15:22:48 2010
@@ -7,6 +7,7 @@
 <style type="text/css">
   body {
     font-family:Arial,sans-serif;
+    font-size:11pt;
   }
 </style>
 </head>



Mime
View raw message