You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/02/16 17:04:07 UTC
svn commit: r910572 [29/36] - in /incubator/chemistry/trunk/opencmis: ./
_dev/ opencmis-client/ opencmis-client/opencmis-client-api/
opencmis-client/opencmis-client-api/src/
opencmis-client/opencmis-client-api/src/main/
opencmis-client/opencmis-client-...
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,93 @@
+/*
+ * 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.opencmis.inmemory.server;
+
+import java.math.BigInteger;
+import java.util.List;
+
+import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.opencmis.commons.api.TypeDefinitionList;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.commons.provider.RepositoryService;
+import org.apache.opencmis.inmemory.RepositoryServiceImpl;
+import org.apache.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisRepositoryService;
+
+public class InMemoryRepositoryService implements CmisRepositoryService {
+ StoreManager fStoreManager;
+ RepositoryService fRepositoryService; // real implementation of the service
+
+ InMemoryRepositoryService(StoreManager storeManager) {
+ fStoreManager = storeManager;
+ fRepositoryService = new RepositoryServiceImpl(fStoreManager);
+ }
+
+ public RepositoryInfoData getRepositoryInfo(CallContext context, String repositoryId,
+ ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ return fRepositoryService.getRepositoryInfo(repositoryId, extension);
+ }
+
+ public List<RepositoryInfoData> getRepositoryInfos(CallContext context, ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ return fRepositoryService.getRepositoryInfos(extension);
+ }
+
+ public TypeDefinitionList getTypeChildren(CallContext context, String repositoryId,
+ String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount,
+ ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ return fRepositoryService.getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems, skipCount, extension);
+ }
+
+ public TypeDefinition getTypeDefinition(CallContext context, String repositoryId,
+ String typeId, ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ return fRepositoryService.getTypeDefinition(repositoryId, typeId, extension);
+ }
+
+ public List<TypeDefinitionContainer> getTypeDescendants(CallContext context, String repositoryId,
+ String typeId, BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ return fRepositoryService.getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions, extension);
+ }
+
+ public RepositoryService getRepositoryService() {
+ return fRepositoryService;
+ }
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryService.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryVersioningService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryVersioningService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryVersioningService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryVersioningService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,149 @@
+/*
+ * 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.opencmis.inmemory.server;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.enums.IncludeRelationships;
+import org.apache.opencmis.commons.provider.AccessControlList;
+import org.apache.opencmis.commons.provider.ContentStreamData;
+import org.apache.opencmis.commons.provider.Holder;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.ObjectService;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.VersioningService;
+import org.apache.opencmis.inmemory.VersioningServiceImpl;
+import org.apache.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisVersioningService;
+import org.apache.opencmis.server.spi.ObjectInfoHolder;
+
+public class InMemoryVersioningService implements CmisVersioningService {
+ private static final Log LOG = LogFactory.getLog(CmisVersioningService.class.getName());
+
+ StoreManager fStoreManager;
+ VersioningService fVersioningService; // real implementation of the service
+ ObjectService fObjectService; // real implementation of the service
+ CallContextConfigReader fCfgReader = null;
+ AtomLinkInfoProvider fAtomLinkProvider;
+
+ public InMemoryVersioningService(StoreManager storeManager, ObjectService objectService) {
+ fStoreManager = storeManager;
+ fObjectService = objectService;
+ fVersioningService = new VersioningServiceImpl(fStoreManager, objectService);
+ fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
+ }
+
+
+ public void cancelCheckOut(CallContext context, String repositoryId, String objectId,
+ ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ fVersioningService.cancelCheckOut(repositoryId, objectId, extension);
+
+ }
+
+ public ObjectData checkIn(CallContext context, String repositoryId, Holder<String> objectId,
+ Boolean major, PropertiesData properties, ContentStreamData contentStream,
+ String checkinComment, List<String> policies, AccessControlList addAces,
+ AccessControlList removeAces, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ fVersioningService.checkIn(repositoryId, objectId, major, properties, contentStream,
+ checkinComment, policies, addAces, removeAces, extension);
+
+ ObjectData objData = null;
+ // To be able to provide all Atom links in the response we need additional information:
+ fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, objectId.getValue(), objectInfos);
+ if (context.getBinding().equals(CallContext.BINDING_ATOMPUB)) {
+ objData = fObjectService.getObject(repositoryId, objectId.getValue(), "*", false,
+ IncludeRelationships.NONE, null, false, false, extension);
+ }
+
+ return objData;
+ }
+
+ public ObjectData checkOut(CallContext context, String repositoryId, Holder<String> objectId,
+ ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHolder objectInfos) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ fVersioningService.checkOut(repositoryId, objectId, extension, contentCopied);
+
+ // To be able to provide all Atom links in the response we need additional information:
+ fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, objectId.getValue(), objectInfos);
+
+ return null;
+ }
+
+ public List<ObjectData> getAllVersions(CallContext context, String repositoryId,
+ String versionSeriesId, String filter, Boolean includeAllowableActions,
+ ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ List<ObjectData> res = fVersioningService.getAllVersions(repositoryId, versionSeriesId, filter, includeAllowableActions, extension);
+
+ // To be able to provide all Atom links in the response we need additional information:
+ fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, versionSeriesId, objectInfos);
+ for (ObjectData od : res) {
+ fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, od.getId(), objectInfos);
+ }
+ return res;
+ }
+
+ public ObjectData getObjectOfLatestVersion(CallContext context, String repositoryId,
+ String versionSeriesId, Boolean major, String filter, Boolean includeAllowableActions,
+ IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
+ Boolean includeAcl, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ ObjectData res = fVersioningService.getObjectOfLatestVersion(repositoryId, versionSeriesId, major, filter,
+ includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds,
+ includeAcl, extension);
+
+ // To be able to provide all Atom links in the response we need additional information:
+ fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, versionSeriesId, objectInfos);
+
+ return res;
+ }
+
+ public PropertiesData getPropertiesOfLatestVersion(CallContext context, String repositoryId,
+ String versionSeriesId, Boolean major, String filter, ExtensionsData extension) {
+
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(new CallContextConfigReader(context));
+
+ PropertiesData res = fVersioningService.getPropertiesOfLatestVersion(repositoryId, versionSeriesId, major, filter, extension);
+
+ return res;
+ }
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryVersioningService.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/RuntimeContext.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/RuntimeContext.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/RuntimeContext.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/RuntimeContext.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.opencmis.inmemory.server;
+
+import org.apache.opencmis.inmemory.ConfigMap;
+
+
+/**
+ * This class uses a thread local storage to store the runtime context. The runtime
+ * context can be accessed from everywhere using thread local storage access The runtime
+ * context is only valid during the lifetime of a single request.
+ * @author jens
+ *
+ */
+public class RuntimeContext {
+ public static class ThreadLocalRuntimeConfig extends ThreadLocal<ConfigMap> {
+
+ public void attachCfg(ConfigMap cfgMap) {
+ set(cfgMap);
+ }
+
+ public synchronized String getConfigValue(String key) {
+ return get().get(key) ;
+ }
+ };
+
+ private static ThreadLocalRuntimeConfig CONN = new ThreadLocalRuntimeConfig();
+
+ public static ThreadLocalRuntimeConfig getRuntimeConfig() {
+ return CONN;
+ }
+
+ public static String getRuntimeConfigValue(String key) {
+ return CONN.getConfigValue(key);
+ }
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/RuntimeContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,255 @@
+/*
+ * 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.opencmis.inmemory.server;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.opencmis.commons.impl.dataobjects.ProviderObjectFactoryImpl;
+import org.apache.opencmis.commons.provider.NavigationService;
+import org.apache.opencmis.commons.provider.ObjectService;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.commons.provider.RepositoryService;
+import org.apache.opencmis.inmemory.ConfigConstants;
+import org.apache.opencmis.inmemory.MapConfigReader;
+import org.apache.opencmis.inmemory.NavigationServiceImpl;
+import org.apache.opencmis.inmemory.ObjectServiceImpl;
+import org.apache.opencmis.inmemory.RepositoryServiceImpl;
+import org.apache.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.opencmis.inmemory.storedobj.impl.StoreManagerFactory;
+import org.apache.opencmis.inmemory.storedobj.impl.StoreManagerImpl;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CmisDiscoveryService;
+import org.apache.opencmis.server.spi.CmisNavigationService;
+import org.apache.opencmis.server.spi.CmisObjectService;
+import org.apache.opencmis.server.spi.CmisRepositoryService;
+import org.apache.opencmis.server.spi.CmisVersioningService;
+import org.apache.opencmis.util.repository.ObjectGenerator;
+
+public class ServiceFactory extends AbstractServicesFactory {
+
+ private static final Log LOG = LogFactory.getLog(ServiceFactory.class.getName());
+ private static StoreManager STORE_MANAGER; // singleton root of everything
+ public static StoreManager getInstance() {
+ if (null == STORE_MANAGER)
+ throw new RuntimeException("Application not initialized correctly");
+ return STORE_MANAGER;
+ }
+
+ private InMemoryRepositoryService fRepositoryService;
+ private InMemoryNavigationService fNavigationService;
+ private InMemoryObjectService fObjectService;
+ private InMemoryVersioningService fVersioningService;
+ private InMemoryDiscoveryService fDiscoveryService;
+
+ @Override
+ public void init(Map<String, String> parameters) {
+ LOG.info("Initializing in-memory repository...");
+
+ // initialize in-memory management
+ String repositoryClassName = (String) parameters.get(ConfigConstants.REPOSITORY_CLASS);
+ if (null==repositoryClassName)
+ repositoryClassName = StoreManagerImpl.class.getName();
+
+ if (null == STORE_MANAGER)
+ STORE_MANAGER = StoreManagerFactory.createInstance(repositoryClassName);
+
+ MapConfigReader cfgReader = new MapConfigReader(parameters);
+ STORE_MANAGER.setConfigReader(cfgReader);
+ String repositoryId = parameters.get(ConfigConstants.REPOSITORY_ID);
+
+ List<String> allAvailableRepositories = STORE_MANAGER.getAllRepositoryIds();
+
+ // init existing repositories
+ for (String existingRepId : allAvailableRepositories)
+ STORE_MANAGER.initRepository(existingRepId, false);
+
+ // create repository
+ if (null != repositoryId) {
+ if (allAvailableRepositories.contains(repositoryId))
+ LOG.warn("Repostory " + repositoryId + " already exists and will not be created.");
+ else {
+ STORE_MANAGER.createRepository(repositoryId);
+ // then create/initialize type system
+ String typeCreatorClassName = parameters.get(ConfigConstants.TYPE_CREATOR_CLASS);
+ STORE_MANAGER.initTypeSystem(repositoryId, typeCreatorClassName);
+ // then init repository (note: loads root folder which requires cmis:folder type available)
+
+ STORE_MANAGER.initRepository(repositoryId, true);
+ }
+ }
+
+ if (repositoryId != null) {
+ String repoInfoCreatorClassName = parameters.get(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS);
+ STORE_MANAGER.initRepositoryInfo(repositoryId, repoInfoCreatorClassName);
+ }
+
+ // initialize services
+ fRepositoryService = new InMemoryRepositoryService(STORE_MANAGER);
+ fNavigationService = new InMemoryNavigationService(STORE_MANAGER);
+ fObjectService = new InMemoryObjectService(STORE_MANAGER);
+ fVersioningService = new InMemoryVersioningService(STORE_MANAGER, fObjectService.getObjectService());
+ // Begin temporary implementation for discover service
+ fDiscoveryService = new InMemoryDiscoveryService(STORE_MANAGER, fRepositoryService.getRepositoryService(), fNavigationService.getNavigationService());
+ // End temporary implementation
+
+ // With some special configuration settings fill the repository with some documents and folders if is empty
+ if (!allAvailableRepositories.contains(repositoryId))
+ fillRepositoryIfConfigured(cfgReader, repositoryId);
+
+ LOG.info("...initialized in-memory repository.");
+ }
+
+ @Override
+ public void destroy() {
+ LOG.info("Destroyed in-memory repository.");
+ }
+
+ @Override
+ public CmisRepositoryService getRepositoryService() {
+ return fRepositoryService;
+ }
+
+ @Override
+ public CmisNavigationService getNavigationService() {
+ return fNavigationService;
+ }
+
+ @Override
+ public CmisObjectService getObjectService() {
+ return fObjectService;
+ }
+
+ @Override
+ public CmisVersioningService getVersioningService() {
+ return fVersioningService;
+ }
+
+ @Override
+ public CmisDiscoveryService getDiscoveryService() {
+ return fDiscoveryService;
+ }
+
+ private void fillRepositoryIfConfigured(MapConfigReader cfgReader, String repositoryId) {
+
+ String doFillRepositoryStr = cfgReader.get(ConfigConstants.USE_REPOSITORY_FILER);
+ boolean doFillRepository = doFillRepositoryStr == null ? false : Boolean
+ .parseBoolean(doFillRepositoryStr);
+
+ if (!doFillRepository)
+ return;
+
+ ProviderObjectFactory objectFactory = new ProviderObjectFactoryImpl();
+ NavigationService navSvc = new NavigationServiceImpl(STORE_MANAGER);
+ ObjectService objSvc = new ObjectServiceImpl(STORE_MANAGER);
+ RepositoryService repSvc = new RepositoryServiceImpl(STORE_MANAGER);
+
+ String levelsStr = cfgReader.get(ConfigConstants.FILLER_DEPTH);
+ int levels = 1;
+ if (null!=levelsStr)
+ levels = Integer.parseInt(levelsStr);
+
+ String docsPerLevelStr = cfgReader.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
+ int docsPerLevel = 1;
+ if (null!=docsPerLevelStr)
+ docsPerLevel = Integer.parseInt(docsPerLevelStr);
+
+ String childrenPerLevelStr = cfgReader.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
+ int childrenPerLevel = 2;
+ if (null!=childrenPerLevelStr)
+ childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
+
+ String documentTypeId = cfgReader.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
+ if (null == documentTypeId)
+ documentTypeId = BaseObjectTypeIds.CMIS_DOCUMENT.value();
+
+ String folderTypeId = cfgReader.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
+ if (null == folderTypeId)
+ folderTypeId = BaseObjectTypeIds.CMIS_FOLDER.value();
+
+ int contentSizeKB = 0;
+ String contentSizeKBStr = cfgReader.get(ConfigConstants.FILLER_CONTENT_SIZE);
+ if (null!=contentSizeKBStr)
+ contentSizeKB = Integer.parseInt(contentSizeKBStr);
+
+ // Create a hierarchy of folders and fill it with some documents
+ ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repositoryId);
+
+ gen.setNumberOfDocumentsToCreatePerFolder(docsPerLevel);
+
+ // Set the type id for all created documents:
+ gen.setDocumentTypeId(documentTypeId);
+
+ // Set the type id for all created folders:
+ gen.setFolderTypeId(folderTypeId);
+
+ // Set contentSize
+ gen.setContentSizeInKB(contentSizeKB);
+
+ // set properties that need to be filled
+ // set the properties the generator should fill with values for documents:
+ // Note: must be valid properties in configured document and folder type
+
+ List<String> propsToSet = readPropertiesToSetFromConfig(cfgReader,
+ ConfigConstants.FILLER_DOCUMENT_PROPERTY);
+ if (null != propsToSet)
+ gen.setDocumentPropertiesToGenerate(propsToSet);
+
+ propsToSet = readPropertiesToSetFromConfig(cfgReader,
+ ConfigConstants.FILLER_FOLDER_PROPERTY);
+ if (null != propsToSet)
+ gen.setFolderPropertiesToGenerate(propsToSet);
+
+ // Simulate a runtime context with configuration parameters
+ // Attach the CallContext to a thread local context that can be accessed from everywhere
+ RuntimeContext.getRuntimeConfig().attachCfg(cfgReader);
+
+ // Build the tree
+ RepositoryInfoData rep = repSvc.getRepositoryInfo(repositoryId, null);
+ String rootFolderId = rep.getRootFolderId();
+
+ try {
+ gen.createFolderHierachy(levels, childrenPerLevel, rootFolderId);
+ // Dump the tree
+ gen.dumpFolder(rootFolderId, "*");
+ } catch (Exception e) {
+ LOG.error("Could not create folder hierarchy with documents. " + e);
+ e.printStackTrace();
+ }
+
+ }
+
+ private List<String> readPropertiesToSetFromConfig(MapConfigReader cfgReader, String keyPrefix) {
+ List<String> propsToSet = new ArrayList<String>();
+ for (int i=0; ; ++i) {
+ String propertyKey = keyPrefix + Integer.toString(i);
+ String propertyToAdd = cfgReader.get(propertyKey);
+ if (null == propertyToAdd)
+ break;
+ else
+ propsToSet.add(propertyToAdd);
+ }
+ return propsToSet;
+ }
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/ServiceFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,94 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import java.util.List;
+
+/**
+ * A folder is a StoredObject that that has a path and children. Children can be
+ * folder or documents
+ *
+ * @author Jens
+ */
+public interface Children {
+
+ /**
+ * Create a subfolder in an existing folder. This call persists parent and child folder
+ * as transactional step.
+ *
+ * @param folder
+ * new child folder
+ */
+ public void addChildFolder(Folder folder);
+
+ /**
+ * Add a document to a folder. This call persists the folder and the document as a
+ * transactional step.
+ *
+ * @param doc
+ * document to be added
+ */
+ public void addChildDocument(Document doc);
+
+ /**
+ * Add a versioned document to a folder. This call persists the folder and the document as a
+ * transactional step.
+ *
+ * @param doc
+ * document to be added
+ */
+ public void addChildDocument(VersionedDocument doc);
+
+ /**
+ * get all the children of this folder. To support paging an initial offset and a
+ * maximum number of childrent to retrieve can be passed
+ *
+ * @param maxItems
+ * max. number of items to return
+ * @param skipCount
+ * initial offset where to start fetching
+ * @return
+ * list of children objects
+ */
+ public List<StoredObject> getChildren(int maxItems, int skipCount);
+
+ /**
+ * get all the children of this folder which are folders. To support paging an
+ * initial offset and a maximum number of childrent to retrieve can be passed.
+ *
+ * @param maxItems
+ * max. number of items to return
+ * @param skipCount
+ * initial offset where to start fetching
+ * @return
+ * list of children folders
+ */
+ public List<Folder> getFolderChildren(int maxItems, int skipCount);
+
+ /**
+ * indicate if a child with the given name exists in this folder
+ *
+ * @param name
+ * name to check
+ * @return
+ * true if the name exists in the folderas child, false otherwise
+ */
+ public boolean hasChild(String name);
+
+}
\ No newline at end of file
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Children.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import org.apache.opencmis.commons.provider.ContentStreamData;
+
+public interface Content {
+ /**
+ * retrieve the content of a document
+ * @return
+ * object containing mime-type, length and a stream with content
+ */
+ ContentStreamData getContent();
+
+ /**
+ * Assign content do a document. Existing content gets overwritten.
+ * The document is not yet persisted in the new state.
+ * @param content
+ * content to be assigned to the document.
+ * @param mustPersist
+ * persist document (set to false if content is set during creation of a document)
+ */
+ void setContent(ContentStreamData content, boolean mustPersist);
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Content.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Document.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Document.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Document.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Document.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,33 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+
+/**
+ * A document is a concrete object (meaning it can be stored) and has
+ * content. It also has a path (is contained in a parent folder)
+ *
+ * @author Jens
+ *
+ */
+
+public interface Document extends StoredObject, Path, Content {
+
+}
+
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Document.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+/**
+ * A DocumentVersion is a concrete version of a versioned document. It has an id,
+ * is stored in the object store, has content and adds versioning functionality.
+ * It does not have a path. It inherits also properties so each version may have
+ * its own properties.
+ *
+ * @author Jens
+ *
+ */
+public interface DocumentVersion extends Version, Content, StoredObject {
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/DocumentVersion.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Folder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Folder.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Folder.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Folder.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import java.util.List;
+
+/**
+ * A folder is a concrete object (meaning it can be stored) and has
+ * Each folder is contained in a parent folder. The parent folder for
+ * the special root folder is null.
+ *
+ * @author Jens
+ *
+ */
+
+public interface Folder extends Children, Path, StoredObject {
+
+ /**
+ * return a list of allowed types of children in this folder
+ * @return
+ */
+ List<String> getAllowedChildObjectTypeIds();
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Folder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/ObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/ObjectStore.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/ObjectStore.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/ObjectStore.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,114 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import java.util.List;
+
+/**
+ * @author Jens
+ *
+ * This is the interface an implementation must provide to store any kind of CMIS
+ * objects. The ObjectStore is the topmost container of all CMIS object that get
+ * persisted. It is comparable to a file system, one object store exists per
+ * repository id. The object store allows access objects by an id. In addition a
+ * object can be retrieved by path. Typically the object store owns the list of
+ * object ids and maintains the path hierarchy.
+ */
+public interface ObjectStore {
+
+ /**
+ * Get the root folder of this object store
+ * @return
+ * the root folder of this store
+ */
+ Folder getRootFolder();
+
+ /**
+ * return an object by path.
+ * @param path
+ * the path to the object
+ * @return
+ * the stored object with this path
+ */
+ StoredObject getObjectByPath(String path);
+
+ /**
+ * get an object by its id
+ * @param folderId
+ * the id of the object
+ * @return
+ * the object identified by this id
+ */
+ StoredObject getObjectById(String folderId);
+
+ /**
+ * Deletes an object from the store. For a folders the folder must be empty.
+ * @param objectId
+ */
+ void deleteObject(String objectId);
+
+ /**
+ * Create a document as initial step. The document is created but still temporary
+ * It is not yet persisted and does not have an id yet. After this call additional
+ * actions can take place (like assigning properties and a type) before it is
+ * persisted.
+ *
+ * @param name
+ * name of the document
+ * @return
+ * document object
+ */
+ Document createDocument(String name);
+
+ /**
+ * Create a folder as initial step. The folder is created but still temporary
+ * It is not yet persisted and does not have an id yet. After this call additional
+ * actions can take place (like assigning properties and a type) before it is
+ * persisted.
+ *
+ * @param name
+ * name of the folder
+ * @return
+ * folder object
+ */
+ Folder createFolder(String name);
+
+ /**
+ * Create a document that supports versions as initial step. The document is created
+ * but still temporary. It is not yet persisted and does not have an id yet. After
+ * this call additional actions can take place (like assigning properties and a type)
+ * before it is persisted.
+ *
+ * @param name
+ * name of the document
+ * @return
+ * versioned document object
+ */
+ VersionedDocument createVersionedDocument(String name);
+
+ /**
+ * Return a list of all documents that are checked out in the repository.
+ *
+ * @param orderBy
+ * orderBy specification according to CMIS spec.
+ * @return
+ * list of checked out documents in the repository
+ */
+ List<VersionedDocument> getCheckedOutDocuments(String orderBy);
+}
\ No newline at end of file
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/ObjectStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Path.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Path.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Path.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Path.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+
+/**
+ * Path is the capability of an object to get accessed by a path in addition to the identifier.
+ * Paths are hierachical, each object with a path has a parent where the parent is always a
+ * folder. Paths do not exist on its own but are part of other objects (documents and folders).
+ *
+ * @author Jens
+ */
+public interface Path {
+
+ /**
+ * character indicating how folders are separated within a path string. This char must not be a
+ * valid character of an object name.
+ */
+ public static final String PATH_SEPARATOR = "/";
+
+ /**
+ * @return
+ */
+ String getPath();
+
+ /**
+ * @return
+ */
+ Folder getParent();
+
+ /** Put the document in a folder and set the parent. This method should not
+ * be used to file a document in a folder. It is used internally when a document
+ * is filed to the folder. The document does not get persisted in this call.
+ *
+ * @param parent
+ * parent folder of the document to be assigned.
+ */
+ void setParent(Folder parent);
+
+ /**
+ * Move an object to a different folder. Source and target object are persisted in this
+ * call as part of a transactional step.
+ *
+ * @param newParent
+ * new parent folder for the object
+ */
+ public void move(Folder newParent);
+
+}
\ No newline at end of file
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Path.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,174 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.inmemory.ConfigMap;
+import org.apache.opencmis.inmemory.RepositoryInfo;
+
+/**
+ * interface to a repository implementation. This interface is the entry point to a
+ * repository that can persist CMIS objects. Using this interface the type information
+ * can be retrieved or set, a repository can be created or for a given repository the
+ * store can be retrieved.
+ *
+ * @author Jens
+ */
+public interface StoreManager {
+
+ /**
+ * return a list of all available repositories
+ * @return
+ */
+ List<String> getAllRepositoryIds();
+
+ /**
+ * Initialize the store for the given repository (first call done on a StoreManager after creation)
+ * @param repositoryId
+ * id of repository to initialize
+ * @param isCreated
+ * true if the repository was just created and is initialized for the first time
+ * false if it existed before and is reloaded
+ */
+ public void initRepository(String repositoryId, boolean isCreated);
+
+ /**
+ * get the object store for the given repository id.
+ *
+ * @param repositoryId
+ * @return the object store in which objects for this repository are stored.
+ */
+ ObjectStore getObjectStore(String repositoryId);
+
+ /**
+ * create a new repository with the given id
+ *
+ * @param repositoryId
+ * id of repository
+ */
+ void createRepository(String repositoryId);
+
+ /**
+ * load an existing repository with the given id
+ *
+ * @param repositoryId
+ * id of repository
+ */
+ RepositoryInfo loadRepository(String repositoryId);
+
+
+ /**
+ * retrieve a parameter that a client has attached to a session
+ *
+ * @param parameter
+ * name of the parameter
+ * @return
+ * value of the parameter
+ */
+ String getParameter(String parameter);
+
+ /**
+ * retrieve a list with all type definitions.
+ * @param repositoryId
+ * id of repository
+ * @return
+ * map with type definition
+ */
+ Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId);
+
+ /**
+ * Retrieve a type definition for a give repository and type id
+ *
+ * @param repositoryId
+ * id of repository
+ * @param typeId
+ * id of type definition
+ * @return
+ * type definition
+ */
+ TypeDefinitionContainer getTypeById(String repositoryId, String typeId);
+
+ /**
+ * Retrieve a factory to create CMIS data structures used as containers
+ *
+ * @return
+ * factory object
+ */
+ ProviderObjectFactory getObjectFactory();
+
+ /**
+ * Retrieve a list of root types in the repositories. Root types are available by
+ * definition and need to to be created by a client. CMIS supports documents,
+ * folders, relations and policies as root types
+ *
+ * @param repositoryId
+ * id of repository
+ * @return
+ * list of root types
+ */
+ List<TypeDefinitionContainer> getRootTypes(String repositoryId);
+
+ /**
+ * Retrieve the repository information for a repository
+ *
+ * @param repositoryId
+ * id of repository
+ * @return
+ * repository information
+ */
+ RepositoryInfoData getRepositoryInfo(String repositoryId);
+
+ /**
+ * Initialize the type system. Helper class to create types in the repository
+ * implemented in an implementation specific way. CMIS does not yet provide a
+ * standard to create type definitions. The SPI will call this method in case
+ * a class name was attached to the session. The implementation of this method
+ * should call initTypeSystem of the StoreManager to add the types to the
+ * system.
+ *
+ * @param repositoryId
+ * id of repository where this type gets stored
+ * @param typeCreatorClassName
+ * class implementing the type creation, the class must implement the interface
+ * TypeCreator
+ *
+ */
+ void initTypeSystem(String repositoryId, String typeCreatorClassName);
+
+ /**
+ * Initialize the repository information. A client can assign specific values that
+ * should be set for subsequent getRepositoryInfo() call. Mainly uses for unit tests.
+ *
+ * @param repoInfoCreatorClassName
+ * class name of class setting repository information. The class must implement
+ * the interface RepositoryInfoCreator
+ */
+ void initRepositoryInfo(String repositoryInfo, String repoInfoCreatorClassName);
+
+ /**
+ * Assign a reader that can retrieve context parameters to this repository manager
+ * @param session
+ */
+ void setConfigReader(ConfigMap configMap);
+}
\ No newline at end of file
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,219 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+
+/**
+ * Stored Object interface is common part that all objects handled by CMIS (Documents, Folders,
+ * Relations, Policies, ACLs) share. Objects that implement this interface are always concrete
+ * and can live in the object store. A stored object always has an id, a name and properties.
+ *
+ * @author Jens
+ */
+
+public interface StoredObject {
+
+ /**
+ * Retrieve the id of this object.
+ *
+ * @return
+ * id of this object
+ */
+ String getId();
+
+ /**
+ * Retrieve the name of this object
+ *
+ * @return
+ * name of this object
+ */
+ String getName();
+
+ /**
+ * Set the name of this document. This method does not persist the object.
+ *
+ * @param name
+ * name that is assigned to this object
+ */
+ void setName(String name);
+
+ /**
+ * Retrieve the type of this document.
+ *
+ * @return
+ * Id of the type identifying the type of this object
+ */
+ String getTypeId();
+
+ /**
+ * Set the type of this document. This method does not persist the object.
+ *
+ * @param type
+ * id of the type this object gets assigned.
+ */
+ void setTypeId(String type);
+
+ /**
+ * Retrieve the user who created the document
+ *
+ * @return
+ * user who created the document.
+ */
+ String getCreatedBy();
+
+ /**
+ * Set the user who last modified the object. This method does not persist the object.
+ *
+ * @param createdBy
+ * user who last modified the document
+ */
+ void setCreatedBy(String createdBy);
+
+ /**
+ * Retrieve the user who last modified the document
+ *
+ * @return
+ * user who last modified the document.
+ */
+ String getModifiedBy();
+
+ /**
+ * Set the user who last modified the object. This method does not persist the object.
+ *
+ * @param modifiedBy
+ * user who last modified the document
+ */
+ void setModifiedBy(String modifiedBy);
+
+ GregorianCalendar getCreatedAt();
+
+ /**
+ * Assign date and time when the object was created. Usually you should not call this
+ * method externally. This method does not persist the object.
+ *
+ * @param createdAt
+ * date the object was created
+ */
+ void setCreatedAt(GregorianCalendar createdAt);
+
+ /**
+ * Retrieve date and time when the object was last modified.
+ * @return
+ * date the object was last modified
+ */
+ GregorianCalendar getModifiedAt();
+
+ /**
+ * Assign current date and time when the object was last modified. Usually you should not call this
+ * method externally. This method does not persist the object.
+ */
+ void setModifiedAtNow();
+
+ /** Get the repository id of this object where the object is stored.
+ * @return
+ */
+ String getRepositoryId();
+
+ /**
+ * Assign a repository where this object will be stored. This method does not persist the object.
+ *
+ * @param repositoryId
+ * id of the repository
+ */
+ void setRepositoryId(String repositoryId);
+
+ /**
+ * Retrieve the list of properties
+ * @return
+ */
+ Map<String, PropertyData<?>> getProperties();
+
+ /**
+ * Assign the properties to an object. This method does not persist the object.
+ *
+ * @param props
+ * properties to be assigned
+ */
+ void setProperties(Map<String, PropertyData<?>> props);
+
+ /**
+ * Retrieve a change token uniquely identifying the state of the object when it was
+ * persisted (used for optimistic locking)
+ *
+ * @return
+ * String identifying the change token
+ */
+ String getChangeToken();
+
+ /**
+ * Persist the object so that it can be later retrieved by its id. Assign an id to the object
+ */
+ void persist();
+
+ /**
+ * Rename an object
+ * @param newName
+ * the new name of the object
+ */
+ void rename(String newName);
+
+ /**
+ * Create all system base properties that need to be stored with every object in the repository
+ * This method is called when a new object is created to record all of the capturing data like the
+ * creation time, creator etc.
+ *
+ * @param properties
+ * The properties passed by the client, containing, name, type, etc
+ * @param user
+ * The user creating the document
+ */
+ void createSystemBasePropertiesWhenCreated(Map<String, PropertyData<?>> properties, String user);
+
+ /**
+ * Update all system base properties that need to be stored with every object in the repository
+ * This method is called when an object is is updated to record all of the capturing data like the
+ * modification time, updating user etc.
+ *
+ * @param properties
+ * The properties passed by the client, containing, name, type, etc
+ * @param user
+ * The user creating the document
+ */
+ void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user);
+
+ void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+ List<String> requestedIds);
+
+ /**
+ * Set all properties which are not system properties. These are the properties as defined in Type
+ * system definition. This method is called when an object is created or updated. The
+ * implementation must ignore the system properties.
+ *
+ * @param properties
+ * Set of properties as set by the client, including system parameters
+ */
+ void setCustomProperties(Map<String, PropertyData<?>> properties);
+
+}
\ No newline at end of file
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoredObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Version.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Version.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Version.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Version.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,43 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+/**
+ * The interface version adds the version specific functionality to an object. It
+ * has minor and major versions, stores a comment and has a label
+ * @author Jens
+ *
+ */
+public interface Version {
+
+ boolean isMajor();
+
+ boolean isPwc();
+
+ /**
+ * make the private working copy an official version.
+ */
+ void commit(boolean isMajor);
+
+ String getCheckinComment();
+
+ String getVersionLabel();
+
+ VersionedDocument getParentDocument();
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/Version.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,55 @@
+/*
+ * 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.opencmis.inmemory.storedobj.api;
+
+import java.util.List;
+
+import org.apache.opencmis.commons.enums.VersioningState;
+import org.apache.opencmis.commons.provider.ContentStreamData;
+
+/**
+ * A version series is a concrete object (meaning it can be stored) and has
+ * methods for check-out and checkin. It has a path (is contained in a folder)
+ * In contrast to a non-versioned document it has no content, but versions
+ * instead.
+ *
+ * @author Jens
+ *
+ */
+public interface VersionedDocument extends Path, StoredObject {
+
+ DocumentVersion addVersion(ContentStreamData content, VersioningState verState, String user);
+
+ boolean isCheckedOut();
+
+ void cancelCheckOut(String user);
+
+ DocumentVersion checkOut(ContentStreamData content, String user);
+
+ void checkIn(boolean isMajor, String checkinComment, String user);
+
+ List<DocumentVersion> getAllVersions(String filter);
+
+ DocumentVersion getLatestVersion(boolean major);
+
+ String getCheckedOutBy();
+
+ DocumentVersion getPwc();
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/VersionedDocument.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,131 @@
+/*
+ * 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.opencmis.inmemory.storedobj.impl;
+
+import org.apache.opencmis.inmemory.NameValidator;
+import org.apache.opencmis.inmemory.storedobj.api.Document;
+import org.apache.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.opencmis.inmemory.storedobj.api.Path;
+import org.apache.opencmis.inmemory.storedobj.api.VersionedDocument;
+
+/**
+ * InMemory Stored Object
+ *
+ * @author Jens
+ *
+ */
+
+/**
+ * StoredPathObject is the common superclass of all objects hold in the repository that are
+ * identified by a path, these are: Documents and Folders
+ */
+
+public abstract class AbstractPathImpl extends StoredObjectImpl implements
+ Path {
+
+ protected FolderImpl fParent;
+ protected ObjectStoreImpl fObjStore;
+
+ protected AbstractPathImpl(ObjectStoreImpl objStore) {
+ fObjStore = objStore;
+ }
+
+ public String getId() {
+ return getPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
+ */
+ public String getPath() {
+ StringBuffer path= new StringBuffer(getName());
+ if (null == getParent())
+ path.replace(0, path.length(), PATH_SEPARATOR); // root folder--> set /
+ else {
+ Folder f = getParent();
+ while (f.getParent() != null) {
+ path.insert(0, PATH_SEPARATOR);
+ path.insert(0, f.getName());
+ f = f.getParent();
+ }
+ path.insert(0, PATH_SEPARATOR);
+ }
+// if (LOG.isDebugEnabled())
+// LOG.debug("getPath() returns: " + path.toString());
+ return path.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent()
+ */
+ public Folder getParent() {
+ return fParent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath#setParent(org.apache.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
+ */
+ public void setParent(Folder parent) {
+ fParent = (FolderImpl) parent;
+ }
+
+ public void rename(String newName) {
+ if (!NameValidator.isValidId(newName))
+ throw new IllegalArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+ if (getParent() == null)
+ throw new IllegalArgumentException("Root folder cannot be renamed.");
+ if (getParent().hasChild(newName))
+ throw new IllegalArgumentException("Cannot rename object to " + newName
+ + ". This path already exists.");
+
+ String oldPath = getPath();
+ setName(newName);
+ String newPath = getPath();
+ fObjStore.changePath(this, oldPath, newPath);
+ }
+
+ public void move(Folder newParent) {
+ // we delegate this to the folder class because we need access to the global map to move
+ if (this instanceof Document || this instanceof VersionedDocument)
+ fParent.moveChildDocument((Document) this, newParent);
+ else {// it must be a folder
+ if (getParent() == null)
+ throw new IllegalArgumentException("Root folder cannot be moved.");
+ if (newParent == null)
+ throw new IllegalArgumentException("null is not a valid move target.");
+ if (newParent.hasChild(getName()))
+ throw new IllegalArgumentException(
+ "Cannot move folder, this name already exists in target.");
+
+ String oldPath = getPath(); // old path
+ setParent(newParent);
+ String newPath = getPath(); // new path
+
+ fObjStore.renameAllIdsWithPrefix(oldPath, newPath);
+// fId = newPath;
+ }
+// fId = getPath(); // as we use path the id will change
+ }
+
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/AbstractPathImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,78 @@
+package org.apache.opencmis.inmemory.storedobj.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.util.List;
+
+import org.apache.opencmis.commons.provider.ContentStreamData;
+
+public class ContentStreamDataImpl implements ContentStreamData {
+
+ private int fLength;
+
+ private String fMimeType;
+
+ private String fFileName;
+
+ byte[] fContent;
+
+ public void setContent (InputStream in) throws IOException {
+ if (null == in) {
+ fContent = null; // delete content
+ fLength = 0;
+ } else {
+ byte[] buffer = new byte[ 0xFFFF ];
+ ByteArrayOutputStream contentStream = new ByteArrayOutputStream();
+ for ( int len=0; (len = in.read(buffer)) != -1; ) {
+ contentStream.write( buffer, 0, len );
+ fLength += len;
+ }
+ fContent = contentStream.toByteArray();
+ fLength = contentStream.size();
+ contentStream.close();
+ }
+ in.close();
+ }
+
+ public BigInteger getLength() {
+ return BigInteger.valueOf(fLength);
+ }
+
+ public String getMimeType() {
+ return fMimeType;
+ }
+
+ public void setMimeType(String fMimeType) {
+ this.fMimeType = fMimeType;
+ }
+
+ public String getFileName() {
+ return fFileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fFileName = fileName;
+ }
+
+ public String getFilename() {
+ return fFileName;
+ }
+
+ public InputStream getStream() {
+ if (null == fContent)
+ return null;
+ else
+ return new ByteArrayInputStream(fContent);
+ }
+
+ public List<Object> getExtensions() {
+ return null;
+ }
+
+ public void setExtensions(List<Object> extensions) {
+ // not implemented
+ }
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,129 @@
+/*
+ * 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.opencmis.inmemory.storedobj.impl;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.provider.ContentStreamData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+import org.apache.opencmis.inmemory.FilterParser;
+import org.apache.opencmis.inmemory.storedobj.api.Document;
+
+/**
+ * InMemory Stored Document A document is a stored object that has a path and (optional) content
+ *
+ * @author Jens
+ *
+ */
+
+public class DocumentImpl extends AbstractPathImpl implements Document{
+ private ContentStreamDataImpl fContent;
+
+ private static final Log LOG = LogFactory.getLog(AbstractPathImpl.class.getName());
+
+ DocumentImpl(ObjectStoreImpl objStore) { // visibility should be package
+ super(objStore);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.opencmis.client.provider.spi.inmemory.IDocument#getContent()
+ */
+ public ContentStreamData getContent() {
+ return fContent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.opencmis.client.provider.spi.inmemory.IDocument#setContent(org.apache.opencmis.client.provider
+ * .ContentStreamData)
+ */
+ public void setContent(ContentStreamData content, boolean mustPersist) {
+
+ if (null == content) {
+ fContent = null;
+ } else {
+ fContent = new ContentStreamDataImpl();
+ fContent.setFileName(content.getFilename());
+ fContent.setMimeType(content.getMimeType());
+ try {
+ fContent.setContent(content.getStream());
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Failed to get content from InputStream" , e);
+ }
+ }
+ }
+
+ public void persist() {
+ // The in-memory provider doesn't have to do anything here, but sets the id
+ fId = getPath();
+ }
+
+ public void fillProperties(List<PropertyData<?>> properties, ProviderObjectFactory objFactory,
+ List<String> requestedIds) {
+
+ super.fillProperties(properties, objFactory, requestedIds);
+
+ // fill the version related properties (versions should override this but the spec requires some
+ // properties always to be set
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_LATEST_VERSION, requestedIds)) {
+ properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_VERSION, true));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_MAJOR_VERSION, requestedIds)) {
+ properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_MAJOR_VERSION, true));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, requestedIds)) {
+ properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION, true));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_ID, requestedIds)) {
+ // return id of document itself
+ properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_ID, getId()));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
+ properties.add(objFactory.createPropertyBooleanData(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT, false));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
+ properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY, (String)null));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
+ properties.add(objFactory.createPropertyIdData(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID, (String)null));
+ }
+ if (FilterParser.isContainedInFilter(PropertyIds.CMIS_CHECKIN_COMMENT, requestedIds)) {
+ properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_CHECKIN_COMMENT, (String)null));
+ }
+
+ // optional:
+// if (FilterParser.isContainedInFilter(PropertyIds.CMIS_VERSION_LABEL, requestedIds)) {
+// properties.add(objFactory.createPropertyStringData(PropertyIds.CMIS_VERSION_LABEL, ""));
+// }
+
+
+ }
+
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/DocumentImpl.java
------------------------------------------------------------------------------
svn:eol-style = native