chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1209687 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: FolderPanel.java model/ClientModel.java
Date Fri, 02 Dec 2011 20:50:42 GMT
Author: fmui
Date: Fri Dec  2 20:50:42 2011
New Revision: 1209687

URL: http://svn.apache.org/viewvc?rev=1209687&view=rev
Log:
Workbench: allow loading of unfiled objects

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java?rev=1209687&r1=1209686&r2=1209687&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
Fri Dec  2 20:50:42 2011
@@ -33,6 +33,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ObjectId;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
 import org.apache.chemistry.opencmis.workbench.model.FolderListener;
@@ -106,8 +107,8 @@ public class FolderPanel extends JPanel 
             public void actionPerformed(ActionEvent e) {
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-                    model.loadFolder(parentId, false);
-                    model.loadObject(model.getCurrentFolder().getId());
+                    ObjectId objectId = model.loadFolder(parentId, false);
+                    model.loadObject(objectId.getId());
                 } catch (Exception ex) {
                     ClientHelper.showError(null, ex);
                     return;
@@ -158,8 +159,8 @@ public class FolderPanel extends JPanel 
             if (id.length() == 0) {
                 id = "/";
             }
-            model.loadFolder(id, id.startsWith("/"));
-            model.loadObject(model.getCurrentFolder().getId());
+            ObjectId objectId = model.loadFolder(id, id.startsWith("/"));
+            model.loadObject(objectId.getId());
         } catch (Exception ex) {
             ClientHelper.showError(null, ex);
             return;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java?rev=1209687&r1=1209686&r2=1209687&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
Fri Dec  2 20:50:42 2011
@@ -133,27 +133,32 @@ public class ClientModel {
         }
     }
 
-    public synchronized void loadFolder(String folderId, boolean byPath) throws Exception
{
+    public synchronized ObjectId loadFolder(String folderId, boolean byPath) throws Exception
{
         try {
             Session session = clientSession.getSession();
+            CmisObject selectedObject = null;
             CmisObject folderObject = null;
 
             if (byPath) {
-                folderObject = session.getObjectByPath(folderId);
+                selectedObject = session.getObjectByPath(folderId);
             } else {
-                folderObject = session.getObject(session.createObjectId(folderId));
+                selectedObject = session.getObject(folderId);
             }
 
-            if (!(folderObject instanceof Folder)) {
-                if (folderObject instanceof FileableCmisObject) {
-                    List<Folder> parents = ((FileableCmisObject) folderObject).getParents();
+            if (selectedObject instanceof Folder) {
+                folderObject = selectedObject;
+            } else {
+                if (selectedObject instanceof FileableCmisObject) {
+                    List<Folder> parents = ((FileableCmisObject) selectedObject).getParents();
                     if (parents != null && parents.size() > 0) {
                         folderObject = parents.get(0);
                     } else {
-                        throw new Exception("The object is not a folder and not in a folder!");
+                        setCurrentFolder(null, new ArrayList<CmisObject>(0));
+                        return selectedObject;
                     }
                 } else {
-                    throw new Exception("The object is a relationship and not in a folder!");
+                    setCurrentFolder(null, new ArrayList<CmisObject>(0));
+                    return selectedObject;
                 }
             }
 
@@ -165,6 +170,8 @@ public class ClientModel {
             }
 
             setCurrentFolder((Folder) folderObject, children);
+
+            return selectedObject;
         } catch (Exception ex) {
             setCurrentFolder(null, new ArrayList<CmisObject>(0));
             throw ex;



Mime
View raw message