chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1459297 - in /chemistry/opencmis/trunk: chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/ chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencm...
Date Thu, 21 Mar 2013 13:20:48 GMT
Author: fmui
Date: Thu Mar 21 13:20:47 2013
New Revision: 1459297

URL: http://svn.apache.org/r1459297
Log:
TCK: added first simple secondary types test

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/CreateAndDeleteTypeTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
Thu Mar 21 13:20:47 2013
@@ -117,6 +117,7 @@ public abstract class AbstractSessionTes
     private Boolean supportsRelationships;
     private Boolean supportsPolicies;
     private Boolean supportsItems;
+    private Boolean supportsSecondaries;
 
     public BindingType getBinding() {
         if (getParameters() == null) {
@@ -197,6 +198,15 @@ public abstract class AbstractSessionTes
         return objectTypeId;
     }
 
+    protected String getSecondaryTestTypeId() {
+        String objectTypeId = getParameters().get(TestParameters.DEFAULT_SECONDARY_TYPE);
+        if (objectTypeId == null) {
+            objectTypeId = TestParameters.DEFAULT_SECONDARY_TYPE_VALUE;
+        }
+
+        return objectTypeId;
+    }
+
     // --- helpers ---
 
     protected String[] getAllProperties(CmisObject object) {
@@ -781,6 +791,20 @@ public abstract class AbstractSessionTes
         return supportsItems.booleanValue();
     }
 
+    protected boolean hasSecondaries(Session session) {
+        if (supportsSecondaries == null) {
+            supportsSecondaries = Boolean.FALSE;
+            for (ObjectType type : session.getTypeChildren(null, false)) {
+                if (BaseTypeId.CMIS_SECONDARY.value().equals(type.getId())) {
+                    supportsSecondaries = Boolean.TRUE;
+                    break;
+                }
+            }
+        }
+
+        return supportsSecondaries.booleanValue();
+    }
+
     protected CmisTestResult checkObject(Session session, CmisObject object, String[] properties,
String message) {
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
Thu Mar 21 13:20:47 2013
@@ -31,6 +31,9 @@ public class TestParameters {
     public static final String DEFAULT_ITEM_TYPE = "org.apache.chemistry.opencmis.tck.default.itemType";
     public static final String DEFAULT_ITEM_TYPE_VALUE = "cmis:item";
 
+    public static final String DEFAULT_SECONDARY_TYPE = "org.apache.chemistry.opencmis.tck.default.secondaryType";
+    public static final String DEFAULT_SECONDARY_TYPE_VALUE = "cmis:secondary";
+
     public static final String DEFAULT_TEST_FOLDER_PARENT = "org.apache.chemistry.opencmis.tck.default.testFolderParent";
     public static final String DEFAULT_TEST_FOLDER_PARENT_VALUE = "/";
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
Thu Mar 21 13:20:47 2013
@@ -34,6 +34,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
@@ -152,6 +153,20 @@ public class BaseTypesTest extends Abstr
             } catch (CmisObjectNotFoundException e) {
                 addResult(createResult(WARNING, "Secondary type not available!", e, false));
             }
+        } else {
+            try {
+                session.getTypeDefinition(BaseTypeId.CMIS_ITEM.value());
+                addResult(createResult(FAILURE, "CMIS 1.0 repository returns cmis:item type
definition!"));
+            } catch (CmisBaseException e) {
+                // expected
+            }
+
+            try {
+                session.getTypeDefinition(BaseTypeId.CMIS_SECONDARY.value());
+                addResult(createResult(FAILURE, "CMIS 1.0 repository returns cmis:secondary
type definition!"));
+            } catch (CmisBaseException e) {
+                // expected
+            }
         }
 
         int numOfTypes = runTypeChecks(session, session.getTypeDescendants(null, -1, true));

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/CreateAndDeleteTypeTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/CreateAndDeleteTypeTest.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/CreateAndDeleteTypeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/CreateAndDeleteTypeTest.java
Thu Mar 21 13:20:47 2013
@@ -59,7 +59,7 @@ public class CreateAndDeleteTypeTest ext
     @Override
     public void run(Session session) {
         if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0) {
-            addResult(createResult(SKIPPED, "Items are not supporetd by CMIS 1.0. Test skipped!"));
+            addResult(createResult(SKIPPED, "Type mutability is not supporetd by CMIS 1.0.
Test skipped!"));
             return;
         }
 
@@ -155,7 +155,8 @@ public class CreateAndDeleteTypeTest ext
                 "The number of defined properties and the number of non-inherited properties
don't match!");
         addResult(assertEquals(newTypeDef.getPropertyDefinitions().size(), newPropDefs.size(),
null, failure));
 
-        // check the order of the properties, which must match the order of the original
type definition
+        // check the order of the properties, which must match the order of the
+        // original type definition
         // (OpenCMIS keeps the order of the property definitions.)
         int i = 0;
         for (Map.Entry<String, PropertyDefinition<?>> propDef : newTypeDef.getPropertyDefinitions().entrySet())
{

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java?rev=1459297&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
Thu Mar 21 13:20:47 2013
@@ -0,0 +1,168 @@
+/*
+ * 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.tck.tests.types;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
+import org.apache.chemistry.opencmis.client.api.SecondaryType;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+public class SecondaryTypesTest extends AbstractSessionTest {
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Secondary Types Test");
+        setDescription("Creates documents, attaches and detaches secondary types, checks
the properties, and finally deletes the test documents.");
+    }
+
+    @Override
+    public void run(Session session) {
+        if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0) {
+            addResult(createResult(SKIPPED, "Secondary types are not supporetd by CMIS 1.0.
Test skipped!"));
+            return;
+        }
+
+        if (!hasSecondaries(session)) {
+            addResult(createResult(SKIPPED, "Repository doesn't support secondary types.
Test skipped!"));
+            return;
+        }
+
+        // check cmis:secondaryObjectTypeIds property definition
+        ObjectType docType = session.getTypeDefinition(getDocumentTestTypeId());
+        PropertyDefinition<?> secTypesPropDef = docType.getPropertyDefinitions().get(
+                PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+        if (secTypesPropDef == null) {
+            addResult(createResult(FAILURE, "Test document type has no " + PropertyIds.SECONDARY_OBJECT_TYPE_IDS
+                    + " property!"));
+            return;
+        } else if (secTypesPropDef.getUpdatability() != Updatability.READWRITE) {
+            addResult(createResult(SKIPPED,
+                    "Test document type does not allow attaching secondary types. Test skipped!"));
+            return;
+        }
+
+        // create a test folder
+        Folder testFolder = createTestFolder(session);
+
+        try {
+            createDocumentAndAttachSecondaryType(session, testFolder);
+            createDocumentWithSecondaryType(session, testFolder);
+        } finally {
+            // delete the test folder
+            deleteTestFolder();
+        }
+    }
+
+    private void createDocumentAndAttachSecondaryType(Session session, Folder testFolder)
{
+        CmisTestResult f;
+
+        Document doc = createDocument(session, testFolder, "createandattach.txt", "Secondary
Type Test");
+
+        try {
+            String secondaryTestTypeId = getSecondaryTestTypeId();
+
+            // -- attach secondary type
+            List<String> secondaryTypes = new ArrayList<String>();
+
+            // copy already attached secondary types, if there are any
+            if (doc.getSecondaryTypes() != null) {
+                for (SecondaryType secType : doc.getSecondaryTypes()) {
+                    secondaryTypes.add(secType.getId());
+                }
+            }
+
+            secondaryTypes.add(secondaryTestTypeId);
+
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
+
+            // attach secondary type
+            Document newDoc = (Document) doc.updateProperties(properties);
+
+            // check if the secondary type is there
+            boolean found = false;
+            if (newDoc.getSecondaryTypes() == null) {
+                addResult(createResult(FAILURE, "Document does not have the attached secondary
type!"));
+            } else {
+                for (SecondaryType secType : newDoc.getSecondaryTypes()) {
+                    if (secondaryTestTypeId.equals(secType.getId())) {
+                        found = true;
+                        break;
+                    }
+                }
+
+                f = createResult(FAILURE, "Document does not have the attached secondary
type!");
+                addResult(assertIsTrue(found, null, f));
+            }
+
+            // -- detach secondary type
+            if (found) {
+                secondaryTypes = new ArrayList<String>();
+
+                for (SecondaryType secType : newDoc.getSecondaryTypes()) {
+                    if (!secondaryTestTypeId.equals(secType.getId())) {
+                        secondaryTypes.add(secType.getId());
+                    }
+                }
+
+                properties = new HashMap<String, Object>();
+                properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
+
+                // attach secondary type
+                Document newDoc2 = (Document) doc.updateProperties(properties);
+
+                found = false;
+                if (newDoc2.getSecondaryTypes() != null) {
+                    for (SecondaryType secType : newDoc2.getSecondaryTypes()) {
+                        if (secondaryTestTypeId.equals(secType.getId())) {
+                            found = true;
+                            break;
+                        }
+                    }
+                }
+
+                f = createResult(FAILURE, "Document still has the detached secondary type!");
+                addResult(assertIsFalse(found, null, f));
+            }
+
+        } finally {
+            deleteObject(doc);
+        }
+    }
+
+    private void createDocumentWithSecondaryType(Session session, Folder testFolder) {
+        // TODO
+    }
+
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
Thu Mar 21 13:20:47 2013
@@ -35,5 +35,6 @@ public class TypesTestGroup extends Abst
 
         addTest(new BaseTypesTest());
         addTest(new CreateAndDeleteTypeTest());
+        addTest(new SecondaryTypesTest());
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
Thu Mar 21 13:20:47 2013
@@ -196,19 +196,23 @@ public class TckDialog {
             configPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
 
             final JComboBox folderComboBox = addComboBox(configPanel, "Test folder type:",
-                    BaseTypeId.CMIS_FOLDER.value(), TestParameters.DEFAULT_FOLDER_TYPE_VALUE);
+                    BaseTypeId.CMIS_FOLDER.value(), TestParameters.DEFAULT_FOLDER_TYPE_VALUE,
true);
             configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
 
             final JComboBox documentComboBox = addComboBox(configPanel, "Test document type:",
-                    BaseTypeId.CMIS_DOCUMENT.value(), TestParameters.DEFAULT_DOCUMENT_TYPE_VALUE);
+                    BaseTypeId.CMIS_DOCUMENT.value(), TestParameters.DEFAULT_DOCUMENT_TYPE_VALUE,
true);
             configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
 
             final JComboBox relationshipComboBox = addComboBox(configPanel, "Test relationship
type:",
-                    BaseTypeId.CMIS_RELATIONSHIP.value(), TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE);
+                    BaseTypeId.CMIS_RELATIONSHIP.value(), TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE,
true);
             configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
 
             final JComboBox itemComboBox = addComboBox(configPanel, "Test item type:", BaseTypeId.CMIS_ITEM.value(),
-                    TestParameters.DEFAULT_ITEM_TYPE_VALUE);
+                    TestParameters.DEFAULT_ITEM_TYPE_VALUE, true);
+            configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
+
+            final JComboBox secondaryComboBox = addComboBox(configPanel, "Test secondary
type:",
+                    BaseTypeId.CMIS_SECONDARY.value(), TestParameters.DEFAULT_SECONDARY_TYPE_VALUE,
false);
             configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
 
             configPanel.add(new JLabel("Test folder path:"));
@@ -251,6 +255,10 @@ public class TckDialog {
                         if (itemComboBox.isEnabled()) {
                             parameters.put(TestParameters.DEFAULT_ITEM_TYPE, (String) itemComboBox.getSelectedItem());
                         }
+                        if (secondaryComboBox.isEnabled()) {
+                            parameters.put(TestParameters.DEFAULT_SECONDARY_TYPE,
+                                    (String) secondaryComboBox.getSelectedItem());
+                        }
                         parameters.put(TestParameters.DEFAULT_TEST_FOLDER_PARENT, testParentFolderField.getText());
 
                         runner.setParameters(parameters);
@@ -291,12 +299,13 @@ public class TckDialog {
             model.nodeChanged((TreeNode) model.getRoot());
         }
 
-        private JComboBox addComboBox(JPanel panel, String title, String rootTypeId, String
defaultTypeId) {
+        private JComboBox addComboBox(JPanel panel, String title, String rootTypeId, String
defaultTypeId,
+                boolean creatableOnly) {
             final JLabel label = new JLabel(title);
             label.setAlignmentX(Component.LEFT_ALIGNMENT);
             panel.add(label);
 
-            List<ObjectType> types = model.getCreateableTypes(rootTypeId);
+            List<ObjectType> types = model.getTypesAsList(rootTypeId, creatableOnly);
             String[] typeIds = new String[types.size()];
 
             int i = 0;

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=1459297&r1=1459296&r2=1459297&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
Thu Mar 21 13:20:47 2013
@@ -329,7 +329,7 @@ public class ClientModel {
         return clientSession.getSession().createRelationship(properties, null, null, null);
     }
 
-    public synchronized List<ObjectType> getCreateableTypes(String rootTypeId) {
+    public synchronized List<ObjectType> getTypesAsList(String rootTypeId, boolean
creatableOnly) {
         List<ObjectType> result = new ArrayList<ObjectType>();
 
         ObjectType rootType = null;
@@ -340,10 +340,14 @@ public class ClientModel {
         }
 
         List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId,
-1, false);
-        addType(types, result);
+        addType(types, result, creatableOnly);
 
-        boolean isCreatable = (rootType.isCreatable() == null ? true : rootType.isCreatable().booleanValue());
-        if (isCreatable) {
+        if (creatableOnly) {
+            boolean isCreatable = (rootType.isCreatable() == null ? true : rootType.isCreatable().booleanValue());
+            if (isCreatable) {
+                result.add(rootType);
+            }
+        } else {
             result.add(rootType);
         }
 
@@ -356,17 +360,20 @@ public class ClientModel {
         return result;
     }
 
-    private void addType(List<Tree<ObjectType>> types, List<ObjectType>
resultList) {
+    private void addType(List<Tree<ObjectType>> types, List<ObjectType>
resultList, boolean creatableOnly) {
         for (Tree<ObjectType> tt : types) {
             if (tt.getItem() != null) {
-                boolean isCreatable = (tt.getItem().isCreatable() == null ? true : tt.getItem().isCreatable()
-                        .booleanValue());
-
-                if (isCreatable) {
+                if (creatableOnly) {
+                    boolean isCreatable = (tt.getItem().isCreatable() == null ? true : tt.getItem().isCreatable()
+                            .booleanValue());
+                    if (isCreatable) {
+                        resultList.add(tt.getItem());
+                    }
+                } else {
                     resultList.add(tt.getItem());
                 }
 
-                addType(tt.getChildren(), resultList);
+                addType(tt.getChildren(), resultList, creatableOnly);
             }
         }
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java?rev=1459297&r1=1459296&r2=1459297&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java
Thu Mar 21 13:20:47 2013
@@ -82,7 +82,7 @@ public abstract class CreateDialog exten
     }
 
     protected Object[] getTypes(String rootTypeId) {
-        List<ObjectType> types = model.getCreateableTypes(rootTypeId);
+        List<ObjectType> types = model.getTypesAsList(rootTypeId, true);
 
         Object[] result = new Object[types.size()];
 



Mime
View raw message