This project has retired. For details please refer to its Attic page.
Tools 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.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  /**
30   * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
31   * 
32   */
33  public class Tools {
34      
35      private Tools() {
36      }
37  
38      public static void print(RepositoryInfo repositoryInfo) {
39          if (repositoryInfo == null) {
40              return;
41          }
42  
43          System.out.println("-------------");
44          System.out.println("Id:               " + repositoryInfo.getId());
45          System.out.println("Name:             " + repositoryInfo.getName());
46          System.out.println("CMIS Version:     " + repositoryInfo.getCmisVersionSupported());
47          System.out.println("Product:          " + repositoryInfo.getVendorName() + " / "
48                  + repositoryInfo.getProductName() + " " + repositoryInfo.getProductVersion());
49          System.out.println("Root Folder:      " + repositoryInfo.getRootFolderId());
50          System.out.println("Capabilities:     " + repositoryInfo.getCapabilities());
51          System.out.println("ACL Capabilities: " + repositoryInfo.getAclCapabilities());
52          System.out.println("-------------");
53      }
54  
55      public static void printTypes(String title, List<TypeDefinitionContainer> typeContainerList) {
56          System.out.println("-------------");
57          System.out.println(title);
58          System.out.println("-------------");
59  
60          printTypes(typeContainerList, 0);
61      }
62  
63      private static void printTypes(List<TypeDefinitionContainer> typeContainerList, int level) {
64          if (typeContainerList == null) {
65              return;
66          }
67  
68          for (TypeDefinitionContainer container : typeContainerList) {
69              for (int i = 0; i < level; i++) {
70                  System.out.print("  ");
71              }
72  
73              container.getTypeDefinition().getId();
74              System.out.println(container.getTypeDefinition().getId());
75  
76              printTypes(container.getChildren(), level + 1);
77          }
78      }
79  
80      public static void print(String title, List<ObjectInFolderContainer> containerList) {
81          System.out.println("-------------");
82          System.out.println(title);
83          System.out.println("-------------");
84  
85          print(containerList, 0);
86      }
87  
88      private static void print(List<ObjectInFolderContainer> containerList, int level) {
89          if (containerList == null) {
90              return;
91          }
92  
93          for (ObjectInFolderContainer container : containerList) {
94              for (int i = 0; i < level; i++) {
95                  System.out.print("  ");
96              }
97  
98              Properties properties = container.getObject().getObject().getProperties();
99              System.out.println(properties.getProperties().get(PropertyIds.NAME).getFirstValue() + " ("
100                     + properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue() + ")");
101 
102             print(container.getChildren(), level + 1);
103         }
104     }
105 }