This project has retired. For details please refer to its Attic page.
JcrPrivateWorkingCopy 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  
20  package org.apache.chemistry.opencmis.jcr;
21  
22  import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
23  import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
24  import org.apache.commons.logging.Log;
25  import org.apache.commons.logging.LogFactory;
26  
27  import javax.jcr.Node;
28  import javax.jcr.RepositoryException;
29  
30  /**
31   * Instances of this class represent a private working copy of a cmis:document backed by an underlying
32   * JCR <code>Node</code>.
33   */
34  public class JcrPrivateWorkingCopy extends JcrVersionBase {
35      private static final Log log = LogFactory.getLog(JcrPrivateWorkingCopy.class);
36  
37      /**
38       * Name of a private working copy
39       */
40      public static final String PWC_NAME = "pwc";
41  
42      public JcrPrivateWorkingCopy(Node node, JcrTypeManager typeManager, PathManager pathManager,
43              JcrTypeHandlerManager typeHandlerManager) {
44          
45          super(node, typeManager, pathManager, typeHandlerManager);
46      }
47  
48      /**
49       * @return <code>true</code> iff <code>versionName</code> is the name of private working copy.
50       * @see JcrPrivateWorkingCopy#PWC_NAME
51       */
52      public static boolean denotesPwc(String versionName) {
53          return PWC_NAME.equals(versionName);
54      }
55  
56      /**
57       * @param objectId
58       * @return <code>true</code> iff <code>objectId</code> is the id of a private working copy.
59       * @see JcrPrivateWorkingCopy#PWC_NAME
60       */
61      public static boolean isPwc(String objectId) {
62          return objectId.endsWith('/' + PWC_NAME);   
63      }
64  
65      //------------------------------------------< protected >---
66  
67      @Override
68      protected Node getContextNode() {
69          try {
70              return getNode().getNode(Node.JCR_CONTENT);
71          }
72          catch (RepositoryException e) {
73              log.debug(e.getMessage(), e);
74              throw new CmisObjectNotFoundException(e.getMessage(), e);
75          }
76      }
77  
78      @Override
79      protected String getPwcId() throws RepositoryException {
80          return getObjectId();
81      }
82  
83      @Override
84      protected String getObjectId() throws RepositoryException {
85          return getVersionSeriesId() + '/' + PWC_NAME;
86      }
87  
88      @Override
89      protected String getVersionLabel() throws RepositoryException {
90          return PWC_NAME;
91      }
92  
93      @Override
94      protected boolean isLatestVersion() throws RepositoryException {
95          return false;
96      }
97  
98      @Override
99      protected boolean isMajorVersion() throws RepositoryException {
100         return false;
101     }
102 
103     @Override
104     protected boolean isLatestMajorVersion() throws RepositoryException {
105         return false; 
106     }
107 
108     @Override
109     protected String getCheckInComment() {
110         return "";
111     }
112 
113 }