Examples of ObjectStore


Examples of com.google.code.gaeom.ObjectStore

  public void testSharedCaching()
  {
    TestCache tc = new TestCache();
    tc.name = "Fred";
   
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss1 = os.beginSession();
   
    Key key = oss1.store(tc).now();
   
    ObjectStoreSession oss2 = os.beginSession();

    TestCache tc2 = (TestCache)oss2.load(key).now();
   
    assertTrue("same instance", tc == tc2);
  }
View Full Code Here

Examples of com.google.code.gaeom.ObjectStore

    A a = new A();

    a.name = "Fred";
    a.b.name = "Flintstone";

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Key key = oss.store(a).now();

    ObjectStoreSession oss2 = os.beginSession();

    A a2 = (A) oss2.load(key).now();

    assertEquals(a.name, a2.name);
    assertNotNull(a2.b);
View Full Code Here

Examples of com.google.code.gaeom.ObjectStore

    A a = new A();

    a.name = "Fred";
    a.b.name = "Flintstone";

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Key key = oss.store(a).now();
    oss.delete(a.b).now();

    ObjectStoreSession oss2 = os.beginSession();

    oss2.load(key).retries(1).now();
    assertTrue(false);
  }
View Full Code Here

Examples of com.google.code.gaeom.ObjectStore

    family.addHead(new Person("Kim"));
    family.addChild(new Person("Sam"));
    family.addChild(new Person("Maggie"));
    family.addChild(new Person("Katy"));

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Key key = oss.store(family).now();

    ObjectStoreSession oss2 = os.beginSession();

    Family family2 = (Family) oss2.load(key).now();

    assertEquals(family.name, family2.name);
    assertEquals(family.heads.size(), family2.heads.size());
View Full Code Here

Examples of org.apache.cayenne.access.ObjectStore

                .getSharedSnapshotCache() : new DataRowStore(
                dataDomain.getName(),
                dataDomain.getProperties(),
                eventManager);

        DataContext context = new DataContext(parent, new ObjectStore(snapshotCache));
        context.setValidatingObjectsOnCommit(dataDomain.isValidatingObjectsOnCommit());
        context.setQueryCache(injector.getInstance(Key.get(
                QueryCache.class,
                BaseContext.QUERY_CACHE_INJECTION_KEY)));
        return context;
View Full Code Here

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore

    public void deleteObject(CallContext context, String repositoryId, String objectId,
            Boolean allVersions, ExtensionsData extension) {

        LOG.debug("start deleteObject()");
        validator.deleteObject(context, repositoryId, objectId, allVersions, extension);
        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        LOG.debug("delete object for id: " + objectId);

        // check if it is the root folder
        if (objectId.equals(objectStore.getRootFolder().getId())) {
            throw new CmisNotSupportedException("You can't delete a root folder");
        }

        objectStore.deleteObject(objectId, allVersions, context.getUsername());
        LOG.debug("stop deleteObject()");
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore

        }
        if (null == continueOnFailure) {
            continueOnFailure = false;
        }

        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);

        if (null == so) {
            throw new CmisInvalidArgumentException("Cannot delete object with id  " + folderId + ". Object does not exist.");
        }

        if (!(so instanceof Folder)) {
            throw new CmisInvalidArgumentException("deleteTree can only be invoked on a folder, but id " + folderId
                    + " does not refer to a folder");
        }

        if (unfileObjects == UnfileObject.UNFILE) {
            throw new CmisNotSupportedException("This repository does not support unfile operations.");
        }

        // check if it is the root folder
        if (folderId.equals(objectStore.getRootFolder().getId())) {
            throw new CmisNotSupportedException("You can't delete a root folder");
        }

        // recursively delete folder
        deleteRecursive(objectStore, (Folder) so, continueOnFailure, allVersions, failedToDeleteIds, context.getUsername());
View Full Code Here

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore

        LOG.debug("start getObjectByPath()");
        validator.getObjectByPath(context, repositoryId, path, extension);
        String user = context.getUsername();

        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        StoredObject so = objectStore.getObjectByPath(path, user);

        if (so == null) {
            throw new CmisObjectNotFoundException("Unknown path: " + path);
        }
View Full Code Here

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore

        LOG.debug("start moveObject()");
        StoredObject[] sos = validator.moveObject(context, repositoryId, objectId, targetFolderId, sourceFolderId, extension);
        StoredObject so = sos[0];
        Folder targetFolder = null;
        Folder sourceFolder = null;
        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        Filing spo = null;
        String user = context.getUsername();

        if (null == so) {
            throw new CmisObjectNotFoundException("Unknown object: " + objectId.getValue());
        } else if (so instanceof Filing) {
            spo = (Filing) so;
        } else {
            throw new CmisInvalidArgumentException("Object must be folder or document: " + objectId.getValue());
        }

        StoredObject soTarget = objectStore.getObjectById(targetFolderId);
        if (null == soTarget) {
            throw new CmisObjectNotFoundException("Unknown target folder: " + targetFolderId);
        } else if (soTarget instanceof Folder) {
            targetFolder = (Folder) soTarget;
        } else {
            throw new CmisNotSupportedException("Destination " + targetFolderId
                    + " of a move operation must be a folder");
        }

        StoredObject soSource = objectStore.getObjectById(sourceFolderId);
        if (null == soSource) {
            throw new CmisObjectNotFoundException("Unknown source folder: " + sourceFolderId);
        } else if (soSource instanceof Folder) {
            sourceFolder = (Folder) soSource;
        } else {
View Full Code Here

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore

        String user = context.getUsername();
        TypeDefinition typeDef = getTypeDefinition(repositoryId, properties);
        validator.createDocument(context, repositoryId, folderId, extension);

        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        Map<String, PropertyData<?>> propMap = properties.getProperties();
        // get name from properties
        PropertyData<?> pd = propMap.get(PropertyIds.NAME);
        String name = (String) pd.getFirstValue();

        // Validation stuff
        TypeValidator.validateRequiredSystemProperties(properties);
   
        Folder folder = null;
        if (null != folderId) {
            StoredObject so = objectStore.getObjectById(folderId);

            if (null == so) {
                throw new CmisInvalidArgumentException(" Cannot create document, folderId: " + folderId + " is invalid");
            }

            if (so instanceof Folder) {
                folder = (Folder) so;
            } else {
                throw new CmisInvalidArgumentException("Can't creat document, folderId does not refer to a folder: "
                        + folderId);
            }

            TypeValidator.validateAllowedChildObjectTypes(typeDef, folder.getAllowedChildObjectTypeIds());
        }

        // check if the given type is a document type
        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT)) {
            throw new CmisInvalidArgumentException("Cannot create a document, with a non-document type: " + typeDef.getId());
        }

        // check name syntax
        if (!NameValidator.isValidId(name)) {
            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
        }

        TypeValidator.validateVersionStateForCreate((DocumentTypeDefinition) typeDef, versioningState);

        // set properties that are not set but have a default:
        Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
        if (propMapNew != propMap) {
            properties = new PropertiesImpl(propMapNew.values());
            propMap = propMapNew;
        }

        TypeValidator.validateProperties(typeDef, properties, true);

        // set user, creation date, etc.
        if (user == null) {
            user = "unknown";
        }

        StoredObject so = null;

        // check if content stream parameters are set and if not set some defaults
        if (null != contentStream && (contentStream.getFileName() == null || contentStream.getFileName().length() == 0 ||
            contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)) {
            ContentStreamImpl cs = new ContentStreamImpl();
            cs.setStream(contentStream.getStream());
            if (contentStream.getFileName() == null || contentStream.getFileName().length() == 0) {
                cs.setFileName(name);
            } else {
                cs.setFileName(contentStream.getFileName());
            }
            cs.setLength(contentStream.getBigLength());
            if (contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0) {
                cs.setMimeType("application/octet-stream");
            } else {
                cs.setMimeType(contentStream.getMimeType());
            }
            cs.setExtensions(contentStream.getExtensions());
            contentStream = cs;
        }

        // Now we are sure to have document type definition:
        if (((DocumentTypeDefinition) typeDef).isVersionable()) {
          DocumentVersion version = objectStore.createVersionedDocument(name,  propMap,
                user, folder, addACEs, removeACEs, contentStream, versioningState);
            version.persist();
            so = version; // return the version and not the version series to caller
        } else {
          Document doc = objectStore.createDocument(name, propMap, user, folder, addACEs, removeACEs);
          doc.setContent(contentStream, false);
            doc.persist();
            so = doc;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.