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.server.impl.webservices;
20  
21  import org.apache.chemistry.opencmis.commons.data.Acl;
22  import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
23  import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
24  import org.apache.chemistry.opencmis.commons.impl.jaxb.ACLServicePort;
25  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisACLType;
26  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAccessControlListType;
27  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
28  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
29  import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumACLPropagation;
30  import org.apache.chemistry.opencmis.commons.server.CmisService;
31  
32  import javax.annotation.Resource;
33  
34  import javax.jws.WebService;
35  
36  import javax.xml.ws.WebServiceContext;
37  import javax.xml.ws.soap.MTOM;
38  
39  
40  /**
41   * CMIS ACL Service.
42   */
43  @MTOM
44  @WebService( endpointInterface = "org.apache.chemistry.opencmis.commons.impl.jaxb.ACLServicePort" )
45  public class AclService extends AbstractService implements ACLServicePort
46  {
47      @Resource
48      public WebServiceContext wsContext;
49  
50      public CmisACLType applyACL( String repositoryId, String objectId, CmisAccessControlListType addAces,
51          CmisAccessControlListType removeAces, EnumACLPropagation aclPropagation, CmisExtensionType extension )
52          throws CmisException
53      {
54          CmisService service = null;
55  
56          try
57          {
58              service = getService( wsContext, repositoryId );
59  
60              Acl acl = service.applyAcl( repositoryId, objectId, convert( addAces, null ), convert( removeAces, null ),
61                      convert( AclPropagation.class, aclPropagation ), convert( extension ) );
62  
63              if ( acl == null )
64              {
65                  return null;
66              }
67  
68              CmisACLType result = new CmisACLType(  );
69              result.setACL( convert( acl ) );
70              result.setExact( acl.isExact(  ) );
71  
72              return result;
73          }
74          catch ( Exception e )
75          {
76              throw convertException( e );
77          }
78          finally
79          {
80              closeService( service );
81          }
82      }
83  
84      public CmisACLType getACL( String repositoryId, String objectId, Boolean onlyBasicPermissions,
85          CmisExtensionType extension ) throws CmisException
86      {
87          CmisService service = null;
88  
89          try
90          {
91              service = getService( wsContext, repositoryId );
92  
93              Acl acl = service.getAcl( repositoryId, objectId, onlyBasicPermissions, convert( extension ) );
94  
95              if ( acl == null )
96              {
97                  return null;
98              }
99  
100             CmisACLType result = new CmisACLType(  );
101             result.setACL( convert( acl ) );
102             result.setExact( acl.isExact(  ) );
103 
104             return result;
105         }
106         catch ( Exception e )
107         {
108             throw convertException( e );
109         }
110         finally
111         {
112             closeService( service );
113         }
114     }
115 }