Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 44643 invoked from network); 29 Jul 2010 17:14:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Jul 2010 17:14:58 -0000 Received: (qmail 27625 invoked by uid 500); 29 Jul 2010 17:14:58 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 27587 invoked by uid 500); 29 Jul 2010 17:14:57 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 27579 invoked by uid 99); 29 Jul 2010 17:14:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jul 2010 17:14:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jul 2010 17:14:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A45C023889ED; Thu, 29 Jul 2010 17:13:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r980513 [3/15] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/ chemistry-opencmis-server-bindings/src/main/java/org/apache... Date: Thu, 29 Jul 2010 17:13:30 -0000 To: chemistry-commits@incubator.apache.org From: fguillaume@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100729171331.A45C023889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java?rev=980513&r1=980512&r2=980513&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java Thu Jul 29 17:13:28 2010 @@ -1,48 +1,48 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.inmemory.server; - -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "cmisExtensionType", propOrder = { - "s", "i", "f" -}) -public class ExtensionSample { - private String s; - private int i; - private double f; - - public ExtensionSample() { - s = "This is an example for a CMIS extension."; - i = 42; - f = Math.PI; - } - - public String getString() { - return s; - } - - public int getInt() { - return i; - } - - public double getDouble() { - return f; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.inmemory.server; + +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "cmisExtensionType", propOrder = { + "s", "i", "f" +}) +public class ExtensionSample { + private String s; + private int i; + private double f; + + public ExtensionSample() { + s = "This is an example for a CMIS extension."; + i = 42; + f = Math.PI; + } + + public String getString() { + return s; + } + + public int getInt() { + return i; + } + + public double getDouble() { + return f; + } +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java?rev=980513&r1=980512&r2=980513&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java Thu Jul 29 17:13:28 2010 @@ -1,172 +1,172 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.inmemory.server; - -import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.data.Properties; -import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition; -import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer; -import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument; - -/** - * Common functionality for all service implementations - * - * @author Jens - * - */ -public class InMemoryAbstractServiceImpl { - - protected StoreManager fStoreManager; - - protected InMemoryAbstractServiceImpl(StoreManager storeManager) { - fStoreManager = storeManager; - } - - /** - * check if repository is known and that object exists. To avoid later calls - * to again retrieve the object from the id return the retrieved object for - * later use. - * - * @param repositoryId - * repository id - * @param objectId - * object id - * @return object for objectId - */ - protected StoredObject checkStandardParameters(String repositoryId, String objectId) { - - ObjectStore objStore = fStoreManager.getObjectStore(repositoryId); - - if (objStore == null) - throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId); - - StoredObject so = objStore.getObjectById(objectId); - - if (so == null) - throw new CmisObjectNotFoundException("Unknown object id: " + objectId); - - return so; - } - - protected StoredObject checkExistingObjectId(ObjectStore objStore, String objectId) { - - StoredObject so = objStore.getObjectById(objectId); - - if (so == null) - throw new CmisObjectNotFoundException("Unknown object id: " + objectId); - - return so; - } - - protected void checkRepositoryId(String repositoryId) { - ObjectStore objStore = fStoreManager.getObjectStore(repositoryId); - - if (objStore == null) - throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId); - } - - protected TypeDefinition getTypeDefinition(String repositoryId, Properties properties) { - String typeId = (String) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue(); - TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId); - if (typeDefC == null) - throw new RuntimeException("Cannot create object, a type with id " + typeId + " is unknown"); - - return typeDefC.getTypeDefinition(); - } - - protected TypeDefinition getTypeDefinition(String repositoryId, StoredObject obj) { - - TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, obj.getTypeId()); - return typeDefC.getTypeDefinition(); - } - - /** - * We allow checkin, cancel, checkout operations on a single version as well - * as on a version series This method returns the versioned document - * (version series) in each case - * - * @param value - * version or version series id of a document - * @return version series id - */ - protected VersionedDocument getVersionedDocumentOfObjectId(StoredObject so) { - - VersionedDocument verDoc; - if (so instanceof DocumentVersion) { - // get document the version is contained in to c - verDoc = ((DocumentVersion) so).getParentDocument(); - } else { - verDoc = (VersionedDocument) so; - } - - return verDoc; - } - - protected VersionedDocument testIsNotCheckedOutBySomeoneElse(StoredObject so, String user) { - checkIsVersionableObject(so); - VersionedDocument verDoc = getVersionedDocumentOfObjectId(so); - if (verDoc.isCheckedOut()) - testCheckedOutByCurrentUser(user, verDoc); - - return verDoc; - } - - protected VersionedDocument testHasProperCheckedOutStatus(StoredObject so, String user) { - - checkIsVersionableObject(so); - VersionedDocument verDoc = getVersionedDocumentOfObjectId(so); - - checkHasUser(user); - - testIsCheckedOut(verDoc); - testCheckedOutByCurrentUser(user, verDoc); - - return verDoc; - } - - protected void checkIsVersionableObject(StoredObject so) { - if (!(so instanceof VersionedDocument || so instanceof DocumentVersion)) - throw new RuntimeException( - "Object is of a versionable type but not instance of VersionedDocument or DocumentVersion."); - } - - protected void checkHasUser(String user) { - if (null == user || user.length() == 0) - throw new CmisPermissionDeniedException("Object can't be checked-in, no user is given."); - } - - protected void testCheckedOutByCurrentUser(String user, VersionedDocument verDoc) { - if (!user.equals(verDoc.getCheckedOutBy())) - throw new CmisUpdateConflictException("Object can't be checked-in, user " + verDoc.getCheckedOutBy() - + " has checked out the document."); - } - - protected void testIsCheckedOut(VersionedDocument verDoc) { - if (!verDoc.isCheckedOut()) - throw new CmisUpdateConflictException("Canot check-in: Document " + verDoc.getId() + " is not checked out."); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.inmemory.server; + +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.data.Properties; +import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition; +import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer; +import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument; + +/** + * Common functionality for all service implementations + * + * @author Jens + * + */ +public class InMemoryAbstractServiceImpl { + + protected StoreManager fStoreManager; + + protected InMemoryAbstractServiceImpl(StoreManager storeManager) { + fStoreManager = storeManager; + } + + /** + * check if repository is known and that object exists. To avoid later calls + * to again retrieve the object from the id return the retrieved object for + * later use. + * + * @param repositoryId + * repository id + * @param objectId + * object id + * @return object for objectId + */ + protected StoredObject checkStandardParameters(String repositoryId, String objectId) { + + ObjectStore objStore = fStoreManager.getObjectStore(repositoryId); + + if (objStore == null) + throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId); + + StoredObject so = objStore.getObjectById(objectId); + + if (so == null) + throw new CmisObjectNotFoundException("Unknown object id: " + objectId); + + return so; + } + + protected StoredObject checkExistingObjectId(ObjectStore objStore, String objectId) { + + StoredObject so = objStore.getObjectById(objectId); + + if (so == null) + throw new CmisObjectNotFoundException("Unknown object id: " + objectId); + + return so; + } + + protected void checkRepositoryId(String repositoryId) { + ObjectStore objStore = fStoreManager.getObjectStore(repositoryId); + + if (objStore == null) + throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId); + } + + protected TypeDefinition getTypeDefinition(String repositoryId, Properties properties) { + String typeId = (String) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue(); + TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId); + if (typeDefC == null) + throw new RuntimeException("Cannot create object, a type with id " + typeId + " is unknown"); + + return typeDefC.getTypeDefinition(); + } + + protected TypeDefinition getTypeDefinition(String repositoryId, StoredObject obj) { + + TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, obj.getTypeId()); + return typeDefC.getTypeDefinition(); + } + + /** + * We allow checkin, cancel, checkout operations on a single version as well + * as on a version series This method returns the versioned document + * (version series) in each case + * + * @param value + * version or version series id of a document + * @return version series id + */ + protected VersionedDocument getVersionedDocumentOfObjectId(StoredObject so) { + + VersionedDocument verDoc; + if (so instanceof DocumentVersion) { + // get document the version is contained in to c + verDoc = ((DocumentVersion) so).getParentDocument(); + } else { + verDoc = (VersionedDocument) so; + } + + return verDoc; + } + + protected VersionedDocument testIsNotCheckedOutBySomeoneElse(StoredObject so, String user) { + checkIsVersionableObject(so); + VersionedDocument verDoc = getVersionedDocumentOfObjectId(so); + if (verDoc.isCheckedOut()) + testCheckedOutByCurrentUser(user, verDoc); + + return verDoc; + } + + protected VersionedDocument testHasProperCheckedOutStatus(StoredObject so, String user) { + + checkIsVersionableObject(so); + VersionedDocument verDoc = getVersionedDocumentOfObjectId(so); + + checkHasUser(user); + + testIsCheckedOut(verDoc); + testCheckedOutByCurrentUser(user, verDoc); + + return verDoc; + } + + protected void checkIsVersionableObject(StoredObject so) { + if (!(so instanceof VersionedDocument || so instanceof DocumentVersion)) + throw new RuntimeException( + "Object is of a versionable type but not instance of VersionedDocument or DocumentVersion."); + } + + protected void checkHasUser(String user) { + if (null == user || user.length() == 0) + throw new CmisPermissionDeniedException("Object can't be checked-in, no user is given."); + } + + protected void testCheckedOutByCurrentUser(String user, VersionedDocument verDoc) { + if (!user.equals(verDoc.getCheckedOutBy())) + throw new CmisUpdateConflictException("Object can't be checked-in, user " + verDoc.getCheckedOutBy() + + " has checked out the document."); + } + + protected void testIsCheckedOut(VersionedDocument verDoc) { + if (!verDoc.isCheckedOut()) + throw new CmisUpdateConflictException("Canot check-in: Document " + verDoc.getId() + " is not checked out."); + } + +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java?rev=980513&r1=980512&r2=980513&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java Thu Jul 29 17:13:28 2010 @@ -1,117 +1,117 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.inmemory.server; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.GregorianCalendar; -import java.util.List; - -import org.apache.chemistry.opencmis.commons.data.ExtensionsData; -import org.apache.chemistry.opencmis.commons.data.ObjectData; -import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer; -import org.apache.chemistry.opencmis.commons.data.ObjectList; -import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; -import org.apache.chemistry.opencmis.commons.enums.ChangeType; -import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; -import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl; -import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl; -import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl; -import org.apache.chemistry.opencmis.commons.server.CallContext; -import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler; -import org.apache.chemistry.opencmis.commons.spi.Holder; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class InMemoryDiscoveryServiceImpl extends InMemoryAbstractServiceImpl{ - - private static Log LOG = LogFactory.getLog(InMemoryDiscoveryServiceImpl.class); - - AtomLinkInfoProvider fAtomLinkProvider; - InMemoryNavigationServiceImpl fNavigationService; // real implementation of - // the service - InMemoryRepositoryServiceImpl fRepositoryService; - - public InMemoryDiscoveryServiceImpl(StoreManager storeManager, InMemoryRepositoryServiceImpl repSvc, - InMemoryNavigationServiceImpl navSvc) { - super(storeManager); - fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager); - fNavigationService = navSvc; - fRepositoryService = repSvc; - } - - public ObjectList getContentChanges(CallContext context, String repositoryId, Holder changeLogToken, - Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeAcl, - BigInteger maxItems, ExtensionsData extension, ObjectInfoHandler objectInfos) { - // dummy implementation using hard coded values - - RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null); - String rootFolderId = rep.getRootFolderId(); - - ObjectListImpl objList = new ObjectListImpl(); - List tempRes = fNavigationService.getDescendants(context, repositoryId, rootFolderId, - BigInteger.valueOf(3), filter, false, IncludeRelationships.NONE, null, false, extension, null); - - // convert ObjectInFolderContainerList to objectList - List lod = new ArrayList(); - for (ObjectInFolderContainer obj : tempRes) { - convertList(lod, obj); - } - objList.setObjects(lod); - objList.setNumItems(BigInteger.valueOf(lod.size())); - - // To be able to provide all Atom links in the response we need - // additional information: - fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, null, objectInfos, objList); - return objList; - } - - private void convertList(List lod, ObjectInFolderContainer obj) { - lod.add(obj.getObject().getObject()); - // add dummy event info - ObjectData oif = obj.getObject().getObject(); - ObjectDataImpl oifImpl = (ObjectDataImpl) oif; - ChangeEventInfoDataImpl changeEventInfo = new ChangeEventInfoDataImpl(); - changeEventInfo.setChangeType(ChangeType.UPDATED); - changeEventInfo.setChangeTime(new GregorianCalendar()); - oifImpl.setChangeEventInfo(changeEventInfo); - if (null != obj.getChildren()) { - for (ObjectInFolderContainer oifc : obj.getChildren()) { - convertList(lod, oifc); - } - } - } - - public ObjectList query(CallContext context, String repositoryId, String statement, Boolean searchAllVersions, - Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, - BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { - - LOG.debug("start query()"); - checkRepositoryId(repositoryId); - String user = context.getUsername(); - ObjectList res; - - res = fStoreManager.query(user, repositoryId, statement, searchAllVersions, includeAllowableActions, - includeRelationships, renditionFilter, maxItems, skipCount); - LOG.debug("stop query()"); - return res; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.inmemory.server; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.List; + +import org.apache.chemistry.opencmis.commons.data.ExtensionsData; +import org.apache.chemistry.opencmis.commons.data.ObjectData; +import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer; +import org.apache.chemistry.opencmis.commons.data.ObjectList; +import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; +import org.apache.chemistry.opencmis.commons.enums.ChangeType; +import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl; +import org.apache.chemistry.opencmis.commons.server.CallContext; +import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler; +import org.apache.chemistry.opencmis.commons.spi.Holder; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class InMemoryDiscoveryServiceImpl extends InMemoryAbstractServiceImpl{ + + private static Log LOG = LogFactory.getLog(InMemoryDiscoveryServiceImpl.class); + + AtomLinkInfoProvider fAtomLinkProvider; + InMemoryNavigationServiceImpl fNavigationService; // real implementation of + // the service + InMemoryRepositoryServiceImpl fRepositoryService; + + public InMemoryDiscoveryServiceImpl(StoreManager storeManager, InMemoryRepositoryServiceImpl repSvc, + InMemoryNavigationServiceImpl navSvc) { + super(storeManager); + fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager); + fNavigationService = navSvc; + fRepositoryService = repSvc; + } + + public ObjectList getContentChanges(CallContext context, String repositoryId, Holder changeLogToken, + Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeAcl, + BigInteger maxItems, ExtensionsData extension, ObjectInfoHandler objectInfos) { + // dummy implementation using hard coded values + + RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null); + String rootFolderId = rep.getRootFolderId(); + + ObjectListImpl objList = new ObjectListImpl(); + List tempRes = fNavigationService.getDescendants(context, repositoryId, rootFolderId, + BigInteger.valueOf(3), filter, false, IncludeRelationships.NONE, null, false, extension, null); + + // convert ObjectInFolderContainerList to objectList + List lod = new ArrayList(); + for (ObjectInFolderContainer obj : tempRes) { + convertList(lod, obj); + } + objList.setObjects(lod); + objList.setNumItems(BigInteger.valueOf(lod.size())); + + // To be able to provide all Atom links in the response we need + // additional information: + fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, null, objectInfos, objList); + return objList; + } + + private void convertList(List lod, ObjectInFolderContainer obj) { + lod.add(obj.getObject().getObject()); + // add dummy event info + ObjectData oif = obj.getObject().getObject(); + ObjectDataImpl oifImpl = (ObjectDataImpl) oif; + ChangeEventInfoDataImpl changeEventInfo = new ChangeEventInfoDataImpl(); + changeEventInfo.setChangeType(ChangeType.UPDATED); + changeEventInfo.setChangeTime(new GregorianCalendar()); + oifImpl.setChangeEventInfo(changeEventInfo); + if (null != obj.getChildren()) { + for (ObjectInFolderContainer oifc : obj.getChildren()) { + convertList(lod, oifc); + } + } + } + + public ObjectList query(CallContext context, String repositoryId, String statement, Boolean searchAllVersions, + Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, + BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { + + LOG.debug("start query()"); + checkRepositoryId(repositoryId); + String user = context.getUsername(); + ObjectList res; + + res = fStoreManager.query(user, repositoryId, statement, searchAllVersions, includeAllowableActions, + includeRelationships, renditionFilter, maxItems, skipCount); + LOG.debug("stop query()"); + return res; + } + +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java?rev=980513&r1=980512&r2=980513&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java Thu Jul 29 17:13:28 2010 @@ -1,125 +1,125 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.inmemory.server; - -import org.apache.chemistry.opencmis.commons.data.ExtensionsData; -import org.apache.chemistry.opencmis.commons.data.ObjectData; -import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition; -import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; -import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException; -import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl; -import org.apache.chemistry.opencmis.commons.server.CallContext; -import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager; -import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject; -import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class InMemoryMultiFilingServiceImpl extends InMemoryAbstractServiceImpl { - - private static final Log LOG = LogFactory.getLog(InMemoryMultiFilingServiceImpl.class.getName()); - - AtomLinkInfoProvider fAtomLinkProvider; - - public InMemoryMultiFilingServiceImpl(StoreManager storeMgr) { - super(storeMgr); - fAtomLinkProvider = new AtomLinkInfoProvider(storeMgr); - } - - public void addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId, - Boolean allVersions, ExtensionsData extension, ObjectInfoHandler objectInfos) { - - LOG.debug("Begin addObjectToFolder()"); - - StoredObject[] so2 = checkParams(repositoryId, objectId, folderId); - if (allVersions != null && allVersions.booleanValue() == false) - throw new CmisNotSupportedException( - "Cannot add object to folder, version specific filing is not supported."); - StoredObject so = so2[0]; - StoredObject folder = so2[1]; - checkObjects(so, folder); - - Folder newParent = (Folder) folder; - MultiFiling obj = (MultiFiling) so; - obj.addParent(newParent); - - if (context.isObjectInfoRequired()) { - ObjectInfoImpl objectInfo = new ObjectInfoImpl(); - fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo); - fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfo); - objectInfos.addObjectInfo(objectInfo); - } - - LOG.debug("End addObjectToFolder()"); - } - - public void removeObjectFromFolder(CallContext context, String repositoryId, String objectId, - String folderId, ExtensionsData extension, ObjectInfoHandler objectInfos) { - - LOG.debug("Begin removeObjectFromFolder()"); - - StoredObject so = checkStandardParameters(repositoryId, objectId); - ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId); - StoredObject folder = checkExistingObjectId(objectStore, folderId); - - checkObjects(so, folder); - Folder parent = (Folder) folder; - MultiFiling obj = (MultiFiling) so; - obj.removeParent(parent); - - // To be able to provide all Atom links in the response we need - // additional information: - if (context.isObjectInfoRequired()) { - ObjectInfoImpl objectInfo = new ObjectInfoImpl(); - fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo); - fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfo); - objectInfos.addObjectInfo(objectInfo); - } - - LOG.debug("End removeObjectFromFolder()"); - } - - private StoredObject[] checkParams(String repositoryId, String objectId, String folderId) { - StoredObject[] so = new StoredObject[2]; - so[0] = checkStandardParameters(repositoryId, objectId); - ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId); - so[1] = checkExistingObjectId(objectStore, folderId); - return so; - } - - private void checkObjects(StoredObject so, StoredObject folder) { - if (!(so instanceof MultiFiling)) - throw new CmisConstraintException("Cannot add object to folder, object id " + so.getId() - + " is not a multi-filed object."); - - if ((so instanceof Folder)) - throw new CmisConstraintException("Cannot add object to folder, object id " + folder.getId() - + " is a folder and folders are not multi-filed."); - - if (!(folder instanceof Folder)) - throw new CmisConstraintException("Cannot add object to folder, folder id " + folder.getId() - + " does not refer to a folder."); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.inmemory.server; + +import org.apache.chemistry.opencmis.commons.data.ExtensionsData; +import org.apache.chemistry.opencmis.commons.data.ObjectData; +import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition; +import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; +import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException; +import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl; +import org.apache.chemistry.opencmis.commons.server.CallContext; +import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager; +import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject; +import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class InMemoryMultiFilingServiceImpl extends InMemoryAbstractServiceImpl { + + private static final Log LOG = LogFactory.getLog(InMemoryMultiFilingServiceImpl.class.getName()); + + AtomLinkInfoProvider fAtomLinkProvider; + + public InMemoryMultiFilingServiceImpl(StoreManager storeMgr) { + super(storeMgr); + fAtomLinkProvider = new AtomLinkInfoProvider(storeMgr); + } + + public void addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId, + Boolean allVersions, ExtensionsData extension, ObjectInfoHandler objectInfos) { + + LOG.debug("Begin addObjectToFolder()"); + + StoredObject[] so2 = checkParams(repositoryId, objectId, folderId); + if (allVersions != null && allVersions.booleanValue() == false) + throw new CmisNotSupportedException( + "Cannot add object to folder, version specific filing is not supported."); + StoredObject so = so2[0]; + StoredObject folder = so2[1]; + checkObjects(so, folder); + + Folder newParent = (Folder) folder; + MultiFiling obj = (MultiFiling) so; + obj.addParent(newParent); + + if (context.isObjectInfoRequired()) { + ObjectInfoImpl objectInfo = new ObjectInfoImpl(); + fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo); + fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfo); + objectInfos.addObjectInfo(objectInfo); + } + + LOG.debug("End addObjectToFolder()"); + } + + public void removeObjectFromFolder(CallContext context, String repositoryId, String objectId, + String folderId, ExtensionsData extension, ObjectInfoHandler objectInfos) { + + LOG.debug("Begin removeObjectFromFolder()"); + + StoredObject so = checkStandardParameters(repositoryId, objectId); + ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId); + StoredObject folder = checkExistingObjectId(objectStore, folderId); + + checkObjects(so, folder); + Folder parent = (Folder) folder; + MultiFiling obj = (MultiFiling) so; + obj.removeParent(parent); + + // To be able to provide all Atom links in the response we need + // additional information: + if (context.isObjectInfoRequired()) { + ObjectInfoImpl objectInfo = new ObjectInfoImpl(); + fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo); + fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfo); + objectInfos.addObjectInfo(objectInfo); + } + + LOG.debug("End removeObjectFromFolder()"); + } + + private StoredObject[] checkParams(String repositoryId, String objectId, String folderId) { + StoredObject[] so = new StoredObject[2]; + so[0] = checkStandardParameters(repositoryId, objectId); + ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId); + so[1] = checkExistingObjectId(objectStore, folderId); + return so; + } + + private void checkObjects(StoredObject so, StoredObject folder) { + if (!(so instanceof MultiFiling)) + throw new CmisConstraintException("Cannot add object to folder, object id " + so.getId() + + " is not a multi-filed object."); + + if ((so instanceof Folder)) + throw new CmisConstraintException("Cannot add object to folder, object id " + folder.getId() + + " is a folder and folders are not multi-filed."); + + if (!(folder instanceof Folder)) + throw new CmisConstraintException("Cannot add object to folder, folder id " + folder.getId() + + " does not refer to a folder."); + } + +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native