This project has retired. For details please refer to its Attic page.
ObjectDataImpl 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.commons.impl.dataobjects;
20  
21  import java.util.List;
22  
23  import org.apache.chemistry.opencmis.commons.PropertyIds;
24  import org.apache.chemistry.opencmis.commons.data.Acl;
25  import org.apache.chemistry.opencmis.commons.data.AllowableActions;
26  import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
27  import org.apache.chemistry.opencmis.commons.data.ObjectData;
28  import org.apache.chemistry.opencmis.commons.data.PolicyIdList;
29  import org.apache.chemistry.opencmis.commons.data.Properties;
30  import org.apache.chemistry.opencmis.commons.data.PropertyData;
31  import org.apache.chemistry.opencmis.commons.data.RenditionData;
32  import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
33  
34  /**
35   * ObjectData implementation.
36   */
37  public class ObjectDataImpl extends AbstractExtensionData implements ObjectData {
38  
39      private static final long serialVersionUID = 1L;
40  
41      private Properties properties;
42      private ChangeEventInfo changeEventInfo;
43      private List<ObjectData> relationships;
44      private List<RenditionData> renditions;
45      private PolicyIdList policyIds;
46      private AllowableActions allowableActions;
47      private Acl acl;
48      private Boolean isExactAcl;
49  
50      public String getId() {
51          Object value = getFirstValue(PropertyIds.OBJECT_ID);
52          if (value instanceof String) {
53              return (String) value;
54          }
55  
56          return null;
57      }
58  
59      public BaseTypeId getBaseTypeId() {
60          Object value = getFirstValue(PropertyIds.BASE_TYPE_ID);
61          if (value instanceof String) {
62              try {
63                  return BaseTypeId.fromValue((String) value);
64              } catch (Exception e) {
65              }
66          }
67  
68          return null;
69      }
70  
71      public Properties getProperties() {
72          return properties;
73      }
74  
75      public void setProperties(Properties properties) {
76          this.properties = properties;
77      }
78  
79      public ChangeEventInfo getChangeEventInfo() {
80          return changeEventInfo;
81      }
82  
83      public void setChangeEventInfo(ChangeEventInfo changeEventInfo) {
84          this.changeEventInfo = changeEventInfo;
85      }
86  
87      public List<ObjectData> getRelationships() {
88          return relationships;
89      }
90  
91      public void setRelationships(List<ObjectData> relationships) {
92          this.relationships = relationships;
93      }
94  
95      public List<RenditionData> getRenditions() {
96          return renditions;
97      }
98  
99      public void setRenditions(List<RenditionData> renditions) {
100         this.renditions = renditions;
101     }
102 
103     public PolicyIdList getPolicyIds() {
104         return policyIds;
105     }
106 
107     public void setPolicyIds(PolicyIdList policyIds) {
108         this.policyIds = policyIds;
109     }
110 
111     public AllowableActions getAllowableActions() {
112         return allowableActions;
113     }
114 
115     public void setAllowableActions(AllowableActions allowableActions) {
116         this.allowableActions = allowableActions;
117     }
118 
119     public Acl getAcl() {
120         return acl;
121     }
122 
123     public void setAcl(Acl acl) {
124         this.acl = acl;
125     }
126 
127     public Boolean isExactAcl() {
128         return isExactAcl;
129     }
130 
131     public void setIsExactAcl(Boolean isExactACL) {
132         this.isExactAcl = isExactACL;
133     }
134 
135     // ---- internal ----
136 
137     /**
138      * Returns the first value of a property or <code>null</code> if the
139      * property is not set.
140      */
141     private Object getFirstValue(String id) {
142         if ((properties == null) || (properties.getProperties() == null)) {
143             return null;
144         }
145 
146         PropertyData<?> property = properties.getProperties().get(id);
147         if (property == null) {
148             return null;
149         }
150 
151         return property.getFirstValue();
152     }
153 
154     @Override
155     public String toString() {
156         return "Object Data [properties=" + properties + ", allowable actions=" + allowableActions
157                 + ", change event info=" + changeEventInfo + ", ACL=" + acl + ", is exact ACL=" + isExactAcl
158                 + ", policy ids=" + policyIds + ", relationships=" + relationships + ", renditions=" + renditions
159                 + "]" + super.toString();
160     }
161 }