This project has retired. For details please refer to its
Attic page.
MultiFilingServiceImpl xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.client.bindings.spi.atompub;
2021import java.io.OutputStream;
2223import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
24import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
25import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
26import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
27import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
28import org.apache.chemistry.opencmis.commons.impl.Constants;
29import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
30import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
3132/**33 * MultiFiling Service AtomPub client.34 */35publicclassMultiFilingServiceImplextendsAbstractAtomPubService implements MultiFilingService {
3637/**38 * Constructor.39 */40publicMultiFilingServiceImpl(BindingSession session) {
41 setSession(session);
42 }
4344publicvoid addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
45 ExtensionsData extension) {
46if (objectId == null) {
47thrownew CmisInvalidArgumentException("Object id must be set!");
48 }
4950// find the link51 String link = loadLink(repositoryId, folderId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);
5253if (link == null) {
54 throwLinkException(repositoryId, folderId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);
55 }
5657 UrlBuilder url = new UrlBuilder(link);
58 url.addParameter(Constants.PARAM_ALL_VERSIONS, allVersions);
5960// set up object and writer61finalAtomEntryWriter entryWriter = newAtomEntryWriter(createIdObject(objectId));
6263// post addObjectToFolder request64 post(url, Constants.MEDIATYPE_ENTRY, new HttpUtils.Output() {
65publicvoid write(OutputStream out) throws Exception {
66 entryWriter.write(out);
67 }
68 });
69 }
7071publicvoid removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
72if (objectId == null) {
73thrownew CmisInvalidArgumentException("Object id must be set!");
74 }
7576// find the link77 String link = loadCollection(repositoryId, Constants.COLLECTION_UNFILED);
7879if (link == null) {
80thrownew CmisObjectNotFoundException("Unknown repository or unfiling not supported!");
81 }
8283 UrlBuilder url = new UrlBuilder(link);
84 url.addParameter(Constants.PARAM_REMOVE_FROM, folderId);
8586// set up object and writer87finalAtomEntryWriter entryWriter = newAtomEntryWriter(createIdObject(objectId));
8889// post removeObjectFromFolder request90 post(url, Constants.MEDIATYPE_ENTRY, new HttpUtils.Output() {
91publicvoid write(OutputStream out) throws Exception {
92 entryWriter.write(out);
93 }
94 });
95 }
96 }