chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r999315 - in /incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient: details/ model/
Date Tue, 21 Sep 2010 11:26:02 GMT
Author: fmui
Date: Tue Sep 21 11:26:01 2010
New Revision: 999315

URL: http://svn.apache.org/viewvc?rev=999315&view=rev
Log:
made a few minor improvements to the Swing Client

Modified:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ObjectPanel.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RelationshipTable.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java?rev=999315&r1=999314&r2=999315&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
Tue Sep 21 11:26:01 2010
@@ -23,35 +23,36 @@ import org.apache.chemistry.opencmis.swi
 
 public class ACLTable extends AbstractDetailsTable {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private static final String[] COLUMN_NAMES = { "Principal", "Permissions" };
-	private static final int[] COLUMN_WIDTHS = { 200, 400 };
+    private static final String[] COLUMN_NAMES = { "Principal", "Permissions", "Direct" };
+    private static final int[] COLUMN_WIDTHS = { 200, 400, 50 };
 
-	public ACLTable(ClientModel model) {
-		super();
-		init(model, COLUMN_NAMES, COLUMN_WIDTHS);
-	}
-
-	public int getDetailRowCount() {
-		if ((getObject().getAcl() == null)
-				|| (getObject().getAcl().getAces() == null)) {
-			return 0;
-		}
-
-		return getObject().getAcl().getAces().size();
-	}
-
-	public Object getDetailValueAt(int rowIndex, int columnIndex) {
-		Ace ace = getObject().getAcl().getAces().get(rowIndex);
-
-		switch (columnIndex) {
-		case 0:
-			return ace.getPrincipalId();
-		case 1:
-			return ace.getPermissions().toString();
-		}
+    public ACLTable(ClientModel model) {
+        super();
+        init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+    }
+
+    public int getDetailRowCount() {
+        if ((getObject().getAcl() == null) || (getObject().getAcl().getAces() == null)) {
+            return 0;
+        }
+
+        return getObject().getAcl().getAces().size();
+    }
+
+    public Object getDetailValueAt(int rowIndex, int columnIndex) {
+        Ace ace = getObject().getAcl().getAces().get(rowIndex);
+
+        switch (columnIndex) {
+        case 0:
+            return ace.getPrincipalId();
+        case 1:
+            return ace.getPermissions().toString();
+        case 2:
+            return ace.isDirect();
+        }
 
-		return null;
-	}
+        return null;
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java?rev=999315&r1=999314&r2=999315&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
Tue Sep 21 11:26:01 2010
@@ -60,30 +60,32 @@ public class ExtensionsPanel extends JPa
 
         DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
 
-        // object extensions
-        DefaultMutableTreeNode objectRootNode = new DefaultMutableTreeNode("Object");
-        addExtension(objectRootNode, object.getExtensions(ExtensionLevel.OBJECT));
-        rootNode.add(objectRootNode);
-
-        // property extensions
-        DefaultMutableTreeNode propertiesRootNode = new DefaultMutableTreeNode("Properties");
-        addExtension(propertiesRootNode, object.getExtensions(ExtensionLevel.PROPERTIES));
-        rootNode.add(propertiesRootNode);
-
-        // allowable actions extensions
-        DefaultMutableTreeNode allowableActionsRootNode = new DefaultMutableTreeNode("Allowable
Actions");
-        addExtension(allowableActionsRootNode, object.getExtensions(ExtensionLevel.ALLOWABLE_ACTIONS));
-        rootNode.add(allowableActionsRootNode);
-
-        // ACL extensions
-        DefaultMutableTreeNode aclRootNode = new DefaultMutableTreeNode("ACL");
-        addExtension(aclRootNode, object.getExtensions(ExtensionLevel.ACL));
-        rootNode.add(aclRootNode);
-
-        // policies extensions
-        DefaultMutableTreeNode policiesRootNode = new DefaultMutableTreeNode("Policies");
-        addExtension(policiesRootNode, object.getExtensions(ExtensionLevel.POLICIES));
-        rootNode.add(policiesRootNode);
+        if (object != null) {
+            // object extensions
+            DefaultMutableTreeNode objectRootNode = new DefaultMutableTreeNode("Object");
+            addExtension(objectRootNode, object.getExtensions(ExtensionLevel.OBJECT));
+            rootNode.add(objectRootNode);
+
+            // property extensions
+            DefaultMutableTreeNode propertiesRootNode = new DefaultMutableTreeNode("Properties");
+            addExtension(propertiesRootNode, object.getExtensions(ExtensionLevel.PROPERTIES));
+            rootNode.add(propertiesRootNode);
+
+            // allowable actions extensions
+            DefaultMutableTreeNode allowableActionsRootNode = new DefaultMutableTreeNode("Allowable
Actions");
+            addExtension(allowableActionsRootNode, object.getExtensions(ExtensionLevel.ALLOWABLE_ACTIONS));
+            rootNode.add(allowableActionsRootNode);
+
+            // ACL extensions
+            DefaultMutableTreeNode aclRootNode = new DefaultMutableTreeNode("ACL");
+            addExtension(aclRootNode, object.getExtensions(ExtensionLevel.ACL));
+            rootNode.add(aclRootNode);
+
+            // policies extensions
+            DefaultMutableTreeNode policiesRootNode = new DefaultMutableTreeNode("Policies");
+            addExtension(policiesRootNode, object.getExtensions(ExtensionLevel.POLICIES));
+            rootNode.add(policiesRootNode);
+        }
 
         DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
 

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ObjectPanel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ObjectPanel.java?rev=999315&r1=999314&r2=999315&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ObjectPanel.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ObjectPanel.java
Tue Sep 21 11:26:01 2010
@@ -21,12 +21,17 @@ package org.apache.chemistry.opencmis.sw
 import java.awt.Cursor;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.lang.reflect.Method;
 
 import javax.swing.JButton;
 import javax.swing.JList;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService;
+import org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser;
+import org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl;
 import org.apache.chemistry.opencmis.swingclient.ClientHelper;
 import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
 import org.apache.chemistry.opencmis.swingclient.model.ClientModelEvent;
@@ -43,6 +48,7 @@ public class ObjectPanel extends InfoPan
     private JTextField idField;
     private JTextField typeField;
     private JTextField basetypeField;
+    // private JTextField contentUrlField;
     private JList allowableActionsList;
     private JButton refreshButton;
 
@@ -63,6 +69,7 @@ public class ObjectPanel extends InfoPan
             idField.setText("");
             typeField.setText("");
             basetypeField.setText("");
+            // contentUrlField.setText("");
             allowableActionsList.removeAll();
             refreshButton.setEnabled(false);
         } else {
@@ -71,6 +78,9 @@ public class ObjectPanel extends InfoPan
                 idField.setText(object.getId());
                 typeField.setText(object.getType().getId());
                 basetypeField.setText(object.getBaseTypeId().toString());
+                // String docUrl = getDocumentURL(object,
+                // model.getClientSession().getSession());
+                // contentUrlField.setText(docUrl == null ? "" : docUrl);
                 if (object.getAllowableActions() != null) {
                     allowableActionsList.setListData(object.getAllowableActions().getAllowableActions().toArray());
                 } else {
@@ -90,6 +100,7 @@ public class ObjectPanel extends InfoPan
         idField = addLine("Id:");
         typeField = addLine("Type:");
         basetypeField = addLine("Base Type:");
+        // contentUrlField = addLine("Content URL:");
         allowableActionsList = addComponent("Allowable Actions:", new JList());
         refreshButton = addComponent("", new JButton("Refresh"));
         refreshButton.setEnabled(false);
@@ -107,4 +118,24 @@ public class ObjectPanel extends InfoPan
             }
         });
     }
+
+    public String getDocumentURL(final CmisObject document, final Session session) {
+        String link = null;
+
+        if (!(session.getBinding().getObjectService() instanceof ObjectServiceImpl)) {
+            return null;
+        }
+
+        try {
+            Method loadLink = AbstractAtomPubService.class.getDeclaredMethod("loadLink",
new Class[] { String.class,
+                    String.class, String.class, String.class });
+            loadLink.setAccessible(true);
+            link = (String) loadLink.invoke(session.getBinding().getObjectService(), session.getRepositoryInfo()
+                    .getId(), document.getId(), AtomPubParser.LINK_REL_CONTENT, null);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return link;
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RelationshipTable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RelationshipTable.java?rev=999315&r1=999314&r2=999315&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RelationshipTable.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RelationshipTable.java
Tue Sep 21 11:26:01 2010
@@ -54,9 +54,9 @@ public class RelationshipTable extends A
 		case 1:
 			return relationship.getType().getId();
 		case 2:
-			return relationship.getSource().getId();
+			return relationship.getSourceId();
 		case 3:
-			return relationship.getTarget().getId();
+			return relationship.getTargetId();
 		}
 
 		return null;

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java?rev=999315&r1=999314&r2=999315&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
Tue Sep 21 11:26:01 2010
@@ -108,6 +108,10 @@ public class ClientModel {
         folderOC = createFolderOperationContext();
     }
 
+    public synchronized ClientSession getClientSession() {
+        return clientSession;
+    }
+
     public synchronized RepositoryInfo getRepositoryInfo() throws Exception {
         Session session = clientSession.getSession();
         return session.getRepositoryInfo();
@@ -216,8 +220,8 @@ public class ClientModel {
             File file = new File(filename);
             InputStream stream = new FileInputStream(file);
 
-            content = clientSession.getSession().getObjectFactory().createContentStream(file.getName(),
file.length(),
-                    MIMETypes.getMIMEType(file), stream);
+            content = clientSession.getSession().getObjectFactory()
+                    .createContentStream(file.getName(), file.length(), MIMETypes.getMIMEType(file),
stream);
         }
 
         return content;
@@ -287,16 +291,16 @@ public class ClientModel {
     }
 
     public synchronized CmisObject getFromCurrentChildren(String id) {
-        if((currentChildren == null) || (currentChildren.isEmpty()))  {
+        if ((currentChildren == null) || (currentChildren.isEmpty())) {
             return null;
         }
-        
-        for(CmisObject o: currentChildren) {
-            if(o.getId().equals(id)) {
+
+        for (CmisObject o : currentChildren) {
+            if (o.getId().equals(id)) {
                 return o;
             }
         }
-        
+
         return null;
     }
 

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java?rev=999315&r1=999314&r2=999315&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
Tue Sep 21 11:26:01 2010
@@ -30,64 +30,55 @@ import org.apache.chemistry.opencmis.com
 
 public class ClientSession {
 
-	private List<Repository> repositories;
-	private Session session;
+    private List<Repository> repositories;
+    private Session session;
 
-	public ClientSession(String url, BindingType binding, String username,
-			String password) {
-		Map<String, String> parameters = new HashMap<String, String>();
-
-		if (binding == BindingType.WEBSERVICES) {
-			parameters.put(SessionParameter.BINDING_TYPE,
-					BindingType.WEBSERVICES.value());
-			parameters
-					.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
-			parameters
-					.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
-			parameters
-					.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE,
-					url);
-			parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE,
-					url);
-			parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
-		} else {
-			parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB
-					.value());
-			parameters.put(SessionParameter.ATOMPUB_URL, url);
-		}
-		parameters.put(SessionParameter.USER, username);
-		parameters.put(SessionParameter.PASSWORD, password);
-
-		connect(parameters);
-	}
-
-	public ClientSession(Map<String, String> sessionParameters) {
-		if (sessionParameters == null) {
-			throw new IllegalArgumentException("Parameters must not be null!");
-		}
-
-		connect(sessionParameters);
-	}
-
-	private void connect(Map<String, String> sessionParameters) {
-		repositories = SessionFactoryImpl.newInstance().getRepositories(
-				sessionParameters);
-	}
-
-	public List<Repository> getRepositories() {
-		return repositories;
-	}
-
-	public Session createSession(int index) {
-		session = repositories.get(index).createSession();
-		return getSession();
-	}
-
-	public Session getSession() {
-		return session;
-	}
+    public ClientSession(String url, BindingType binding, String username, String password)
{
+        Map<String, String> parameters = new HashMap<String, String>();
+
+        if (binding == BindingType.WEBSERVICES) {
+            parameters.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
+        } else {
+            parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
+            parameters.put(SessionParameter.ATOMPUB_URL, url);
+        }
+        parameters.put(SessionParameter.USER, username);
+        parameters.put(SessionParameter.PASSWORD, password);
+
+        connect(parameters);
+    }
+
+    public ClientSession(Map<String, String> sessionParameters) {
+        if (sessionParameters == null) {
+            throw new IllegalArgumentException("Parameters must not be null!");
+        }
+
+        connect(sessionParameters);
+    }
+
+    private void connect(Map<String, String> sessionParameters) {
+        repositories = SessionFactoryImpl.newInstance().getRepositories(sessionParameters);
+    }
+
+    public List<Repository> getRepositories() {
+        return repositories;
+    }
+
+    public Session createSession(int index) {
+        session = repositories.get(index).createSession();
+        return getSession();
+    }
+
+    public Session getSession() {
+        return session;
+    }
 }



Mime
View raw message