chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1348103 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache...
Date Fri, 08 Jun 2012 15:12:22 GMT
Author: fmui
Date: Fri Jun  8 15:12:22 2012
New Revision: 1348103

URL: http://svn.apache.org/viewvc?rev=1348103&view=rev
Log:
CMIS-527: implemented Document.copy() for the AtomPub binding
Workbench: added Copy panel

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java?rev=1348103&r1=1348102&r2=1348103&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
Fri Jun  8 15:12:22 2012
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.cl
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -32,15 +33,18 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Policy;
+import org.apache.chemistry.opencmis.client.api.Property;
 import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
 import org.apache.chemistry.opencmis.client.api.TransientDocument;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
 
@@ -131,8 +135,13 @@ public class DocumentImpl extends Abstra
     public Document copy(ObjectId targetFolderId, Map<String, ?> properties, VersioningState
versioningState,
             List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
OperationContext context) {
 
-        ObjectId newId = getSession().createDocumentFromSource(this, properties, targetFolderId,
versioningState,
-                policies, addAces, removeAces);
+        ObjectId newId = null;
+        try {
+            newId = getSession().createDocumentFromSource(this, properties, targetFolderId,
versioningState, policies,
+                    addAces, removeAces);
+        } catch (CmisNotSupportedException nse) {
+            newId = copyViaClient(targetFolderId, properties, versioningState, policies,
addAces, removeAces);
+        }
 
         // if no context is provided the object will not be fetched
         if (context == null || newId == null) {
@@ -151,6 +160,40 @@ public class DocumentImpl extends Abstra
         return copy(targetFolderId, null, null, null, null, null, getSession().getDefaultContext());
     }
 
+    /**
+     * Copies the document manually. The content is streamed from the repository
+     * and back.
+     */
+    protected ObjectId copyViaClient(ObjectId targetFolderId, Map<String, ?> properties,
+            VersioningState versioningState, List<Policy> policies, List<Ace>
addAces, List<Ace> removeAces) {
+        Map<String, Object> newProperties = new HashMap<String, Object>();
+
+        OperationContext allPropsContext = getSession().createOperationContext();
+        allPropsContext.setFilterString("*");
+        allPropsContext.setIncludeAcls(false);
+        allPropsContext.setIncludeAllowableActions(false);
+        allPropsContext.setIncludePathSegments(false);
+        allPropsContext.setIncludePolicies(false);
+        allPropsContext.setIncludeRelationships(IncludeRelationships.NONE);
+        allPropsContext.setRenditionFilterString("cmis:none");
+
+        Document allPropsDoc = (Document) getSession().getObject(this, allPropsContext);
+
+        for (Property<?> prop : allPropsDoc.getProperties()) {
+            if (prop.getDefinition().getUpdatability() == Updatability.READWRITE
+                    || prop.getDefinition().getUpdatability() == Updatability.ONCREATE) {
+                newProperties.put(prop.getId(), prop.getValue());
+            }
+        }
+
+        if (properties != null) {
+            newProperties.putAll(properties);
+        }
+
+        return getSession().createDocument(newProperties, targetFolderId, allPropsDoc.getContentStream(),
+                versioningState, policies, addAces, removeAces);
+    }
+
     public void deleteAllVersions() {
         delete(true);
     }

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java?rev=1348103&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java
Fri Jun  8 15:12:22 2012
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.workbench.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
+
+public class CopyPanel extends ActionPanel {
+
+    private static final long serialVersionUID = 1L;
+
+    private JTextField targetFolderField;
+
+    public CopyPanel(ClientModel model) {
+        super("Copy Object", "Copy", model);
+    }
+
+    @Override
+    protected void createActionComponents() {
+        JPanel targetFolderPanel = new JPanel(new BorderLayout());
+        targetFolderPanel.setBackground(Color.WHITE);
+
+        targetFolderPanel.add(new JLabel("Target Folder Id:"), BorderLayout.LINE_START);
+
+        targetFolderField = new JTextField(30);
+        targetFolderPanel.add(targetFolderField, BorderLayout.CENTER);
+
+        addActionComponent(targetFolderPanel);
+    }
+
+    @Override
+    public boolean isAllowed() {
+        if ((getObject() == null) || !(getObject() instanceof Document)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean doAction() throws Exception {
+        ObjectId targetFolderId = new ObjectIdImpl(targetFolderField.getText());
+        ((Document) getObject()).copy(targetFolderId);
+        return true;
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java?rev=1348103&r1=1348102&r2=1348103&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java
Fri Jun  8 15:12:22 2012
@@ -29,6 +29,7 @@ import org.apache.chemistry.opencmis.wor
 import org.apache.chemistry.opencmis.workbench.actions.CancelCheckOutPanel;
 import org.apache.chemistry.opencmis.workbench.actions.CheckInPanel;
 import org.apache.chemistry.opencmis.workbench.actions.CheckOutPanel;
+import org.apache.chemistry.opencmis.workbench.actions.CopyPanel;
 import org.apache.chemistry.opencmis.workbench.actions.DeleteContentStreamPanel;
 import org.apache.chemistry.opencmis.workbench.actions.DeletePanel;
 import org.apache.chemistry.opencmis.workbench.actions.DeleteTreePanel;
@@ -50,6 +51,7 @@ public class ActionsPanel extends JPanel
     private PropertyUpdatePanel propertyUpdatePanel;
     private DeletePanel deletePanel;
     private DeleteTreePanel deleteTreePanel;
+    private CopyPanel copyPanel;
     private MovePanel movePanel;
     private CheckOutPanel checkOutPanel;
     private CancelCheckOutPanel cancelCheckOutPanel;
@@ -83,6 +85,9 @@ public class ActionsPanel extends JPanel
         deleteTreePanel.setObject(object);
         deleteTreePanel.setVisible(deleteTreePanel.isAllowed());
 
+        copyPanel.setObject(object);
+        copyPanel.setVisible(copyPanel.isAllowed());
+
         movePanel.setObject(object);
         movePanel.setVisible(movePanel.isAllowed());
 
@@ -130,6 +135,9 @@ public class ActionsPanel extends JPanel
         deleteTreePanel = new DeleteTreePanel(model);
         add(deleteTreePanel);
 
+        copyPanel = new CopyPanel(model);
+        add(copyPanel);
+
         movePanel = new MovePanel(model);
         add(movePanel);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java?rev=1348103&r1=1348102&r2=1348103&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
Fri Jun  8 15:12:22 2012
@@ -18,14 +18,12 @@
  */
 package org.apache.chemistry.opencmis.workbench.details;
 
-import java.awt.Cursor;
 import java.awt.event.MouseEvent;
 import java.util.Collection;
 
 import org.apache.chemistry.opencmis.client.api.Property;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
 import org.apache.chemistry.opencmis.commons.enums.Action;
-import org.apache.chemistry.opencmis.workbench.ClientHelper;
 import org.apache.chemistry.opencmis.workbench.PropertyEditorFrame;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 



Mime
View raw message