This project has retired. For details please refer to its Attic page.
ObjectComplianceCheck 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.checks;
20  
21  import java.util.Map;
22  
23  import org.apache.chemistry.opencmis.client.api.CmisObject;
24  import org.apache.chemistry.opencmis.client.api.Document;
25  import org.apache.chemistry.opencmis.client.api.Folder;
26  import org.apache.chemistry.opencmis.client.api.Session;
27  import org.apache.chemistry.opencmis.tck.CmisTestResultStatus;
28  import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
29  
30  /**
31   * This class checks an object for CMIS specification compliance.
32   */
33  public class ObjectComplianceCheck extends AbstractSessionTest {
34  
35      private String objectId;
36  
37      public ObjectComplianceCheck(String objectId) throws Exception {
38          this.objectId = objectId;
39      }
40  
41      @Override
42      public void init(Map<String, String> parameters) {
43          super.init(parameters);
44          setName("Object Compliance Check");
45      }
46  
47      @Override
48      public void run(Session session) throws Exception {
49          CmisObject object = session.getObject(objectId, SELECT_ALL_NO_CACHE_OC);
50          String[] propertiesToCheck = getAllProperties(object);
51  
52          addResult(checkObject(session, object, propertiesToCheck, "Object check: " + object.getId()));
53  
54          if (object instanceof Document) {
55              addResult(checkVersionHistory(session, object, propertiesToCheck,
56                      "Version history check: " + object.getId()));
57          } else if (object instanceof Folder) {
58              addResult(checkChildren(session, (Folder) object, "Folder children check: " + object.getId()));
59          }
60  
61          if (getResults().isEmpty()) {
62              addResult(createResult(CmisTestResultStatus.OK, "Object seems to be compliant! Id: " + object.getId()));
63          }
64      }
65  }