This project has retired. For details please refer to its Attic page.
MultiFilingServiceImpl 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.spi.browser;
20  
21  import java.io.OutputStream;
22  
23  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
24  import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
25  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
26  import org.apache.chemistry.opencmis.commons.impl.Constants;
27  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
28  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
29  
30  /**
31   * MultiFiling Service Browser Binding client.
32   */
33  public class MultiFilingServiceImpl extends AbstractBrowserBindingService implements MultiFilingService {
34  
35      /**
36       * Constructor.
37       */
38      public MultiFilingServiceImpl(BindingSession session) {
39          setSession(session);
40      }
41  
42      public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
43              ExtensionsData extension) {
44          // build URL
45          UrlBuilder url = getObjectUrl(repositoryId, objectId);
46  
47          // prepare form data
48          final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_ADD_OBJECT_TO_FOLDER);
49          formData.addParameter(Constants.PARAM_FOLDER_ID, folderId);
50          formData.addParameter(Constants.PARAM_ALL_VERSIONS, allVersions);
51  
52          // send and parse
53          postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
54              public void write(OutputStream out) throws Exception {
55                  formData.write(out);
56              }
57          });
58      }
59  
60      public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
61          // build URL
62          UrlBuilder url = getObjectUrl(repositoryId, objectId);
63  
64          // prepare form data
65          final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_REMOVE_OBJECT_FROM_FOLDER);
66          formData.addParameter(Constants.PARAM_FOLDER_ID, folderId);
67  
68          // send and parse
69          postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
70              public void write(OutputStream out) throws Exception {
71                  formData.write(out);
72              }
73          });
74      }
75  }