Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5070792A1 for ; Tue, 3 Apr 2012 05:40:16 +0000 (UTC) Received: (qmail 96477 invoked by uid 500); 3 Apr 2012 05:40:15 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 96388 invoked by uid 500); 3 Apr 2012 05:40:15 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 96301 invoked by uid 99); 3 Apr 2012 05:40:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2012 05:40:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2012 05:40:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B4AA32388C9D for ; Tue, 3 Apr 2012 05:38:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r811246 [18/21] - in /websites/staging/chemistry/trunk/content: ./ java/0.7.0/maven/chemistry-opencmis-workbench/ java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/ java/0.7.0/maven/chemistry-opencmis-workbench/chem... Date: Tue, 03 Apr 2012 05:38:46 -0000 To: commits@chemistry.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120403053851.B4AA32388C9D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/VersionTable.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/VersionTable.html (added) +++ websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/VersionTable.html Tue Apr 3 05:38:43 2012 @@ -0,0 +1,211 @@ + + + + +VersionTable xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench.details;
+20  
+21  import java.awt.Cursor;
+22  import java.awt.event.MouseEvent;
+23  import java.util.Collections;
+24  import java.util.List;
+25  import java.util.concurrent.locks.ReentrantReadWriteLock;
+26  
+27  import javax.swing.SwingUtilities;
+28  
+29  import org.apache.chemistry.opencmis.client.api.Document;
+30  import org.apache.chemistry.opencmis.client.api.ObjectId;
+31  import org.apache.chemistry.opencmis.commons.enums.Action;
+32  import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+33  import org.apache.chemistry.opencmis.workbench.ClientHelper;
+34  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+35  import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
+36  
+37  public class VersionTable extends AbstractDetailsTable {
+38  
+39      private static final long serialVersionUID = 1L;
+40  
+41      private static final String[] COLUMN_NAMES = { "Name", "Label", "Latest", "Major", "Latest Major", "Id",
+42              "Filename", "MIME Type", "Length" };
+43      private static final int[] COLUMN_WIDTHS = { 200, 200, 50, 50, 50, 400, 200, 100, 100 };
+44  
+45      private List<Document> versions;
+46      private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+47  
+48      public VersionTable(ClientModel model) {
+49          super();
+50  
+51          versions = Collections.emptyList();
+52          init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+53      }
+54  
+55      @Override
+56      public void objectLoaded(ClientModelEvent event) {
+57          lock.writeLock().lock();
+58          try {
+59              versions = Collections.emptyList();
+60          } finally {
+61              lock.writeLock().unlock();
+62          }
+63  
+64          if (getObject() instanceof Document) {
+65              final Document doc = (Document) getObject();
+66  
+67              if (doc.getAllowableActions().getAllowableActions().contains(Action.CAN_GET_ALL_VERSIONS)) {
+68                  SwingUtilities.invokeLater(new Runnable() {
+69                      @Override
+70                      public void run() {
+71                          try {
+72                              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+73                              List<Document> newVersions = doc.getAllVersions(getClientModel().getClientSession()
+74                                      .getVersionOperationContext());
+75  
+76                              lock.writeLock().lock();
+77                              try {
+78                                  versions = newVersions;
+79                              } finally {
+80                                  lock.writeLock().unlock();
+81                              }
+82                          } catch (Exception ex) {
+83                              if (!(ex instanceof CmisNotSupportedException)) {
+84                                  ClientHelper.showError(null, ex);
+85                              }
+86                          } finally {
+87                              setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+88                          }
+89                          ((DetailsTableModel) getModel()).fireTableDataChanged();
+90                      }
+91                  });
+92              }
+93          }
+94  
+95          super.objectLoaded(event);
+96      }
+97  
+98      @Override
+99      public void singleClickAction(MouseEvent e, int rowIndex, int colIndex) {
+100         if (getColumnClass(colIndex) != ObjectId.class) {
+101             return;
+102         }
+103 
+104         String versionId = null;
+105         lock.readLock().lock();
+106         try {
+107             versionId = versions.get(getRowSorter().convertRowIndexToModel(rowIndex)).getId();
+108         } finally {
+109             lock.readLock().unlock();
+110         }
+111 
+112         try {
+113             getClientModel().loadObject(versionId);
+114             setTab(0);
+115         } catch (Exception ex) {
+116             ClientHelper.showError(this, ex);
+117         }
+118     }
+119 
+120     @Override
+121     public void doubleClickAction(MouseEvent e, int rowIndex) {
+122         lock.readLock().lock();
+123         try {
+124             if (e.isShiftDown()) {
+125                 ClientHelper.download(this.getParent(), versions.get(getRowSorter().convertRowIndexToModel(rowIndex)),
+126                         null);
+127             } else {
+128                 ClientHelper
+129                         .open(this.getParent(), versions.get(getRowSorter().convertRowIndexToModel(rowIndex)), null);
+130             }
+131         } finally {
+132             lock.readLock().unlock();
+133         }
+134     }
+135 
+136     @Override
+137     public int getDetailRowCount() {
+138         if (!(getObject() instanceof Document)) {
+139             return 0;
+140         }
+141 
+142         lock.readLock().lock();
+143         try {
+144             return versions.size();
+145         } finally {
+146             lock.readLock().unlock();
+147         }
+148     }
+149 
+150     @Override
+151     public Object getDetailValueAt(int rowIndex, int columnIndex) {
+152         Document version = null;
+153 
+154         lock.readLock().lock();
+155         try {
+156             version = versions.get(rowIndex);
+157         } finally {
+158             lock.readLock().unlock();
+159         }
+160 
+161         switch (columnIndex) {
+162         case 0:
+163             return version.getName();
+164         case 1:
+165             return version.getVersionLabel();
+166         case 2:
+167             return version.isLatestVersion();
+168         case 3:
+169             return version.isMajorVersion();
+170         case 4:
+171             return version.isLatestMajorVersion();
+172         case 5:
+173             return version;
+174         case 6:
+175             return version.getContentStreamFileName();
+176         case 7:
+177             return version.getContentStreamMimeType();
+178         case 8:
+179             return version.getContentStreamLength() == -1 ? null : version.getContentStreamLength();
+180         }
+181 
+182         return null;
+183     }
+184 
+185     @Override
+186     public Class<?> getDetailColumClass(int columnIndex) {
+187         if ((columnIndex == 2) || (columnIndex == 3) || (columnIndex == 4)) {
+188             return Boolean.class;
+189         } else if (columnIndex == 5) {
+190             return ObjectId.class;
+191         } else if (columnIndex == 8) {
+192             return Long.class;
+193         }
+194 
+195         return super.getDetailColumClass(columnIndex);
+196     }
+197 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/package-frame.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/package-frame.html (added) +++ websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/package-frame.html Tue Apr 3 05:38:43 2012 @@ -0,0 +1,66 @@ + + + + + + OpenCMIS Workbench 0.7.0 Reference Package org.apache.chemistry.opencmis.workbench.details + + + + +

+ org.apache.chemistry.opencmis.workbench.details +

+ +

Classes

+ + + + + \ No newline at end of file Added: websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/package-summary.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/package-summary.html (added) +++ websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/package-summary.html Tue Apr 3 05:38:43 2012 @@ -0,0 +1,137 @@ + + + + + + OpenCMIS Workbench 0.7.0 Reference Package org.apache.chemistry.opencmis.workbench.details + + + +
+ +
+
+ +
+ +

Package org.apache.chemistry.opencmis.workbench.details

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class Summary
+ ACLTable +
+ AbstractDetailsTable +
+ ActionsPanel +
+ DetailsTableModel +
+ DetailsTabs +
+ ExtensionNode +
+ ExtensionsPanel +
+ JTextAreaWriter +
+ ObjectPanel +
+ PolicyTable +
+ PropertyTable +
+ RelationshipTable +
+ RenditionTable +
+ TypesPanel +
+ VersionTable +
+ +
+ +
+
+ +
+
+ Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved. + + \ No newline at end of file Added: websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientModel.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientModel.html (added) +++ websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientModel.html Tue Apr 3 05:38:43 2012 @@ -0,0 +1,396 @@ + + + + +ClientModel xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench.model;
+20  
+21  import java.io.BufferedInputStream;
+22  import java.io.File;
+23  import java.io.FileInputStream;
+24  import java.io.InputStream;
+25  import java.util.ArrayList;
+26  import java.util.Collections;
+27  import java.util.Comparator;
+28  import java.util.HashMap;
+29  import java.util.List;
+30  import java.util.Map;
+31  
+32  import javax.swing.event.EventListenerList;
+33  
+34  import org.apache.chemistry.opencmis.client.api.CmisObject;
+35  import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
+36  import org.apache.chemistry.opencmis.client.api.Folder;
+37  import org.apache.chemistry.opencmis.client.api.ItemIterable;
+38  import org.apache.chemistry.opencmis.client.api.ObjectId;
+39  import org.apache.chemistry.opencmis.client.api.ObjectType;
+40  import org.apache.chemistry.opencmis.client.api.OperationContext;
+41  import org.apache.chemistry.opencmis.client.api.QueryResult;
+42  import org.apache.chemistry.opencmis.client.api.Session;
+43  import org.apache.chemistry.opencmis.client.api.Tree;
+44  import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
+45  import org.apache.chemistry.opencmis.commons.PropertyIds;
+46  import org.apache.chemistry.opencmis.commons.data.ContentStream;
+47  import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
+48  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+49  import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+50  import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
+51  import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
+52  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+53  import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+54  import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+55  import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
+56  import org.apache.chemistry.opencmis.workbench.RandomInputStream;
+57  
+58  public class ClientModel {
+59  
+60      // object details must not be older than 60 seconds
+61      private static final long OLD = 60 * 1000;
+62  
+63      private ClientSession clientSession;
+64  
+65      private Folder currentFolder = null;
+66      private List<CmisObject> currentChildren = Collections.emptyList();
+67      private CmisObject currentObject = null;
+68  
+69      private final EventListenerList listenerList = new EventListenerList();
+70  
+71      public ClientModel() {
+72      }
+73  
+74      public void addFolderListener(FolderListener listener) {
+75          listenerList.add(FolderListener.class, listener);
+76      }
+77  
+78      public void removeFolderListener(FolderListener listener) {
+79          listenerList.remove(FolderListener.class, listener);
+80      }
+81  
+82      public void addObjectListener(ObjectListener listener) {
+83          listenerList.add(ObjectListener.class, listener);
+84      }
+85  
+86      public void removeObjectListener(ObjectListener listener) {
+87          listenerList.remove(ObjectListener.class, listener);
+88      }
+89  
+90      public synchronized void setClientSession(ClientSession clientSession) {
+91          this.clientSession = clientSession;
+92      }
+93  
+94      public synchronized ClientSession getClientSession() {
+95          return clientSession;
+96      }
+97  
+98      public synchronized RepositoryInfo getRepositoryInfo() throws Exception {
+99          Session session = clientSession.getSession();
+100         return session.getRepositoryInfo();
+101     }
+102 
+103     public synchronized String getRepositoryName() {
+104         try {
+105             return getRepositoryInfo().getName();
+106         } catch (Exception e) {
+107             return "?";
+108         }
+109     }
+110 
+111     public synchronized boolean supportsQuery() {
+112         try {
+113             RepositoryCapabilities cap = getRepositoryInfo().getCapabilities();
+114             if (cap == null) {
+115                 return true;
+116             }
+117 
+118             return (cap.getQueryCapability() != null) && (cap.getQueryCapability() != CapabilityQuery.NONE);
+119         } catch (Exception e) {
+120             return false;
+121         }
+122     }
+123 
+124     public synchronized boolean supportsChangeLog() {
+125         try {
+126             RepositoryCapabilities cap = getRepositoryInfo().getCapabilities();
+127             if (cap == null) {
+128                 return true;
+129             }
+130 
+131             return (cap.getChangesCapability() != null) && (cap.getChangesCapability() != CapabilityChanges.NONE);
+132         } catch (Exception e) {
+133             return false;
+134         }
+135     }
+136 
+137     public synchronized boolean supportsRelationships() {
+138         try {
+139             ObjectType relType = clientSession.getSession().getTypeDefinition(BaseTypeId.CMIS_RELATIONSHIP.value());
+140             return relType != null;
+141         } catch (Exception e) {
+142             return false;
+143         }
+144     }
+145 
+146     public synchronized ObjectId loadFolder(String folderId, boolean byPath) throws Exception {
+147         try {
+148             Session session = clientSession.getSession();
+149             CmisObject selectedObject = null;
+150             CmisObject folderObject = null;
+151 
+152             if (byPath) {
+153                 selectedObject = session.getObjectByPath(folderId);
+154             } else {
+155                 selectedObject = session.getObject(folderId);
+156             }
+157 
+158             if (selectedObject instanceof Folder) {
+159                 folderObject = selectedObject;
+160             } else {
+161                 if (selectedObject instanceof FileableCmisObject) {
+162                     List<Folder> parents = ((FileableCmisObject) selectedObject).getParents();
+163                     if (parents != null && parents.size() > 0) {
+164                         folderObject = parents.get(0);
+165                     } else {
+166                         setCurrentFolder(null, new ArrayList<CmisObject>(0));
+167                         return selectedObject;
+168                     }
+169                 } else {
+170                     setCurrentFolder(null, new ArrayList<CmisObject>(0));
+171                     return selectedObject;
+172                 }
+173             }
+174 
+175             List<CmisObject> children = new ArrayList<CmisObject>();
+176             ItemIterable<CmisObject> iter = ((Folder) folderObject).getChildren(clientSession
+177                     .getFolderOperationContext());
+178             for (CmisObject child : iter) {
+179                 children.add(child);
+180             }
+181 
+182             setCurrentFolder((Folder) folderObject, children);
+183 
+184             return selectedObject;
+185         } catch (Exception ex) {
+186             setCurrentFolder(null, new ArrayList<CmisObject>(0));
+187             throw ex;
+188         }
+189     }
+190 
+191     public synchronized void reloadFolder() throws Exception {
+192         loadFolder(currentFolder.getId(), false);
+193     }
+194 
+195     public synchronized void loadObject(String objectId) throws Exception {
+196         try {
+197             Session session = clientSession.getSession();
+198             CmisObject object = session.getObject(objectId, clientSession.getObjectOperationContext());
+199             object.refreshIfOld(OLD);
+200 
+201             setCurrentObject(object);
+202         } catch (Exception ex) {
+203             setCurrentObject(null);
+204             throw ex;
+205         }
+206     }
+207 
+208     public synchronized void reloadObject() throws Exception {
+209         if (currentObject == null) {
+210             return;
+211         }
+212 
+213         try {
+214             Session session = clientSession.getSession();
+215             CmisObject object = session.getObject(currentObject, clientSession.getObjectOperationContext());
+216             object.refresh();
+217 
+218             setCurrentObject(object);
+219         } catch (Exception ex) {
+220             setCurrentObject(null);
+221             throw ex;
+222         }
+223     }
+224 
+225     public synchronized ItemIterable<QueryResult> query(String q, boolean searchAllVersions, int maxHits)
+226             throws Exception {
+227         OperationContext queryContext = new OperationContextImpl(null, false, false, false, IncludeRelationships.NONE,
+228                 null, false, null, false, maxHits);
+229 
+230         Session session = clientSession.getSession();
+231         return session.query(q, searchAllVersions, queryContext);
+232     }
+233 
+234     public synchronized List<Tree<ObjectType>> getTypeDescendants() throws Exception {
+235         Session session = clientSession.getSession();
+236         return session.getTypeDescendants(null, -1, true);
+237     }
+238 
+239     public ContentStream createContentStream(String filename) throws Exception {
+240         ContentStream content = null;
+241         if ((filename != null) && (filename.length() > 0)) {
+242             File file = new File(filename);
+243             InputStream stream = new BufferedInputStream(new FileInputStream(file));
+244 
+245             content = clientSession.getSession().getObjectFactory()
+246                     .createContentStream(file.getName(), file.length(), MimeTypes.getMIMEType(file), stream);
+247         }
+248 
+249         return content;
+250     }
+251 
+252     public synchronized ObjectId createDocument(String name, String type, String filename,
+253             VersioningState versioningState, boolean unfiled) throws Exception {
+254         Map<String, Object> properties = new HashMap<String, Object>();
+255         properties.put(PropertyIds.NAME, name);
+256         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
+257 
+258         ContentStream content = createContentStream(filename);
+259         return clientSession.getSession().createDocument(properties, (unfiled ? null : currentFolder), content,
+260                 versioningState, null, null, null);
+261     }
+262 
+263     public ContentStream createContentStream(String name, long length, long seed) throws Exception {
+264         return clientSession.getSession().getObjectFactory()
+265                 .createContentStream(name, length, "application/octet-stream", new RandomInputStream(length, seed));
+266     }
+267 
+268     public synchronized ObjectId createDocument(String name, String type, long length, long seed,
+269             VersioningState versioningState, boolean unfiled) throws Exception {
+270         Map<String, Object> properties = new HashMap<String, Object>();
+271         properties.put(PropertyIds.NAME, name);
+272         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
+273 
+274         ContentStream content = createContentStream(name, length, seed);
+275         return clientSession.getSession().createDocument(properties, (unfiled ? null : currentFolder), content,
+276                 versioningState, null, null, null);
+277     }
+278 
+279     public synchronized ObjectId createFolder(String name, String type) throws Exception {
+280         Map<String, Object> properties = new HashMap<String, Object>();
+281         properties.put(PropertyIds.NAME, name);
+282         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
+283 
+284         return clientSession.getSession().createFolder(properties, currentFolder, null, null, null);
+285     }
+286 
+287     public synchronized ObjectId createRelationship(String name, String type, String sourceId, String targetId)
+288             throws Exception {
+289         Map<String, Object> properties = new HashMap<String, Object>();
+290         properties.put(PropertyIds.NAME, name);
+291         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
+292         properties.put(PropertyIds.SOURCE_ID, sourceId);
+293         properties.put(PropertyIds.TARGET_ID, targetId);
+294 
+295         return clientSession.getSession().createRelationship(properties, null, null, null);
+296     }
+297 
+298     public synchronized List<ObjectType> getCreateableTypes(String rootTypeId) {
+299         List<ObjectType> result = new ArrayList<ObjectType>();
+300 
+301         ObjectType rootType = null;
+302         try {
+303             rootType = clientSession.getSession().getTypeDefinition(rootTypeId);
+304         } catch (CmisObjectNotFoundException e) {
+305             return result;
+306         }
+307 
+308         List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId, -1, false);
+309         addType(types, result);
+310 
+311         boolean isCreatable = (rootType.isCreatable() == null ? true : rootType.isCreatable().booleanValue());
+312         if (isCreatable) {
+313             result.add(rootType);
+314         }
+315 
+316         Collections.sort(result, new Comparator<ObjectType>() {
+317             public int compare(ObjectType ot1, ObjectType ot2) {
+318                 return ot1.getDisplayName().compareTo(ot2.getDisplayName());
+319             }
+320         });
+321 
+322         return result;
+323     }
+324 
+325     private void addType(List<Tree<ObjectType>> types, List<ObjectType> resultList) {
+326         for (Tree<ObjectType> tt : types) {
+327             if (tt.getItem() != null) {
+328                 boolean isCreatable = (tt.getItem().isCreatable() == null ? true : tt.getItem().isCreatable()
+329                         .booleanValue());
+330 
+331                 if (isCreatable) {
+332                     resultList.add(tt.getItem());
+333                 }
+334 
+335                 addType(tt.getChildren(), resultList);
+336             }
+337         }
+338     }
+339 
+340     public synchronized Folder getCurrentFolder() {
+341         return currentFolder;
+342     }
+343 
+344     public synchronized List<CmisObject> getCurrentChildren() {
+345         return currentChildren;
+346     }
+347 
+348     public synchronized CmisObject getFromCurrentChildren(String id) {
+349         if ((currentChildren == null) || (currentChildren.isEmpty())) {
+350             return null;
+351         }
+352 
+353         for (CmisObject o : currentChildren) {
+354             if (o.getId().equals(id)) {
+355                 return o;
+356             }
+357         }
+358 
+359         return null;
+360     }
+361 
+362     private synchronized void setCurrentFolder(Folder folder, List<CmisObject> children) {
+363         currentFolder = folder;
+364         currentChildren = children;
+365 
+366         for (FolderListener fl : listenerList.getListeners(FolderListener.class)) {
+367             fl.folderLoaded(new ClientModelEvent(this));
+368         }
+369     }
+370 
+371     public synchronized CmisObject getCurrentObject() {
+372         return currentObject;
+373     }
+374 
+375     private synchronized void setCurrentObject(CmisObject object) {
+376         currentObject = object;
+377 
+378         for (ObjectListener ol : listenerList.getListeners(ObjectListener.class)) {
+379             ol.objectLoaded(new ClientModelEvent(this));
+380         }
+381     }
+382 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientModelEvent.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientModelEvent.html (added) +++ websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientModelEvent.html Tue Apr 3 05:38:43 2012 @@ -0,0 +1,52 @@ + + + + +ClientModelEvent xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench.model;
+20  
+21  import java.util.EventObject;
+22  
+23  public class ClientModelEvent extends EventObject {
+24  
+25  	private static final long serialVersionUID = 1L;
+26  
+27  	public ClientModelEvent(Object source) {
+28  		super(source);
+29  	}
+30  
+31  	public ClientModel getClientModel() {
+32  		if (getSource() instanceof ClientModel) {
+33  			return (ClientModel) getSource();
+34  		}
+35  
+36  		return null;
+37  	}
+38  }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientOperationContext.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientOperationContext.html (added) +++ websites/staging/chemistry/trunk/content/java/0.7.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/model/ClientOperationContext.html Tue Apr 3 05:38:43 2012 @@ -0,0 +1,98 @@ + + + + +ClientOperationContext xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench.model;
+20  
+21  import java.util.Map;
+22  
+23  import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
+24  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+25  
+26  public class ClientOperationContext extends OperationContextImpl {
+27  
+28      private static final long serialVersionUID = 1L;
+29  
+30      public static final String FILTER = "filter";
+31      public static final String INCLUDE_ACLS = "includeAcls";
+32      public static final String INCLUDE_ALLOWABLE_ACTIONS = "includeAllowableActions";
+33      public static final String INCLUDE_POLICIES = "includePolicies";
+34      public static final String INCLUDE_RELATIONSHIPS = "includeRelationships";
+35      public static final String RENDITION_FILTER = "renditionFilter";
+36      public static final String ORDER_BY = "orderBy";
+37      public static final String MAX_ITEMS_PER_PAGE = "maxItemsPerPage";
+38  
+39      public ClientOperationContext(String prefix, Map<String, String> map) {
+40          loadContext(prefix, map);
+41          setIncludePathSegments(false);
+42          setCacheEnabled(true);
+43      }
+44  
+45      public void loadContext(String prefix, Map<String, String> map) {
+46          setFilterString(map.get(prefix + FILTER));
+47          setIncludeAcls(parseBoolean(map.get(prefix + INCLUDE_ACLS), false));
+48          setIncludeAllowableActions(parseBoolean(map.get(prefix + INCLUDE_ALLOWABLE_ACTIONS), false));
+49          setIncludePolicies(parseBoolean(map.get(prefix + INCLUDE_POLICIES), false));
+50          setIncludeRelationships(parseIncludeRelationships(map.get(prefix + INCLUDE_RELATIONSHIPS),
+51                  IncludeRelationships.NONE));
+52          setRenditionFilterString(map.get(prefix + RENDITION_FILTER));
+53          setOrderBy(map.get(prefix + ORDER_BY));
+54          setMaxItemsPerPage(parseInteger(map.get(prefix + MAX_ITEMS_PER_PAGE), 1000));
+55      }
+56  
+57      private boolean parseBoolean(String s, boolean defaultValue) {
+58          return (s == null ? defaultValue : Boolean.parseBoolean(s));
+59      }
+60  
+61      private IncludeRelationships parseIncludeRelationships(String s, IncludeRelationships defaultValue) {
+62          if (s == null) {
+63              return defaultValue;
+64          }
+65  
+66          try {
+67              return IncludeRelationships.fromValue(s);
+68          } catch (Exception e) {
+69              return defaultValue;
+70          }
+71      }
+72  
+73      private int parseInteger(String s, int defaultValue) {
+74          if (s == null) {
+75              return defaultValue;
+76          }
+77  
+78          try {
+79              return Integer.parseInt(s);
+80          } catch (NumberFormatException e) {
+81              return defaultValue;
+82          }
+83      }
+84  }
+
+
+ +