View Javadoc

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.client.bindings.framework;
20  
21  import java.util.List;
22  
23  import org.apache.chemistry.opencmis.commons.PropertyIds;
24  import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
25  import org.apache.chemistry.opencmis.commons.data.Properties;
26  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
27  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
28  
29  public class Tools {
30  
31      private Tools() {
32      }
33  
34      public static void print(RepositoryInfo repositoryInfo) {
35          if (repositoryInfo == null) {
36              return;
37          }
38  
39          System.out.println("-------------");
40          System.out.println("Id:               " + repositoryInfo.getId());
41          System.out.println("Name:             " + repositoryInfo.getName());
42          System.out.println("CMIS Version:     " + repositoryInfo.getCmisVersionSupported());
43          System.out.println("Product:          " + repositoryInfo.getVendorName() + " / "
44                  + repositoryInfo.getProductName() + " " + repositoryInfo.getProductVersion());
45          System.out.println("Root Folder:      " + repositoryInfo.getRootFolderId());
46          System.out.println("Capabilities:     " + repositoryInfo.getCapabilities());
47          System.out.println("ACL Capabilities: " + repositoryInfo.getAclCapabilities());
48          System.out.println("-------------");
49      }
50  
51      public static void printTypes(String title, List<TypeDefinitionContainer> typeContainerList) {
52          System.out.println("-------------");
53          System.out.println(title);
54          System.out.println("-------------");
55  
56          printTypes(typeContainerList, 0);
57      }
58  
59      private static void printTypes(List<TypeDefinitionContainer> typeContainerList, int level) {
60          if (typeContainerList == null) {
61              return;
62          }
63  
64          for (TypeDefinitionContainer container : typeContainerList) {
65              for (int i = 0; i < level; i++) {
66                  System.out.print("  ");
67              }
68  
69              container.getTypeDefinition().getId();
70              System.out.println(container.getTypeDefinition().getId());
71  
72              printTypes(container.getChildren(), level + 1);
73          }
74      }
75  
76      public static void print(String title, List<ObjectInFolderContainer> containerList) {
77          System.out.println("-------------");
78          System.out.println(title);
79          System.out.println("-------------");
80  
81          print(containerList, 0);
82      }
83  
84      private static void print(List<ObjectInFolderContainer> containerList, int level) {
85          if (containerList == null) {
86              return;
87          }
88  
89          for (ObjectInFolderContainer container : containerList) {
90              for (int i = 0; i < level; i++) {
91                  System.out.print("  ");
92              }
93  
94              Properties properties = container.getObject().getObject().getProperties();
95              System.out.println(properties.getProperties().get(PropertyIds.NAME).getFirstValue() + " ("
96                      + properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue() + ")");
97  
98              print(container.getChildren(), level + 1);
99          }
100     }
101 }