Package org.jboss.dna.connector.store.jpa.model.common

Examples of org.jboss.dna.connector.store.jpa.model.common.WorkspaceEntity


    public void process( DeleteBranchRequest request ) {
        logger.trace(request.toString());
        Location actualLocation = null;
        try {
            // Find the workspace ...
            WorkspaceEntity workspace = getExistingWorkspace(request.inWorkspace(), request);
            if (workspace == null) return;
            Long workspaceId = workspace.getId();
            assert workspaceId != null;

            Location location = request.at();
            ActualLocation actual = getActualLocation(workspaceId, location);
            actualLocation = actual.location;
View Full Code Here


        logger.trace(request.toString());
        Location actualOldLocation = null;
        Location actualNewLocation = null;
        try {
            // Find the workspaces ...
            WorkspaceEntity workspace = getExistingWorkspace(request.inWorkspace(), request);
            if (workspace == null) return;
            Long workspaceId = workspace.getId();
            assert workspaceId != null;

            Location fromLocation = request.from();
            ActualLocation actualLocation = getActualLocation(workspaceId, fromLocation);
            String fromUuidString = actualLocation.uuid;
View Full Code Here

    @Override
    public void process( VerifyWorkspaceRequest request ) {
        // Find the workspace ...
        String workspaceName = request.workspaceName();
        if (workspaceName == null) workspaceName = nameOfDefaultWorkspace;
        WorkspaceEntity workspace = getExistingWorkspace(workspaceName, request);
        if (workspace != null) {
            Long workspaceId = workspace.getId();
            assert workspaceId != null;
            ActualLocation actual = getActualLocation(workspaceId, Location.create(pathFactory.createRootPath()));
            request.setActualRootLocation(actual.location);
            request.setActualWorkspaceName(workspace.getName());
        }
    }
View Full Code Here

                    request.setError(new InvalidWorkspaceException(msg));
                    return;
            }
        }
        // Create the workspace ...
        WorkspaceEntity entity = workspaces.create(name);
        request.setActualWorkspaceName(entity.getName());
        // Create the root node ...
        Location root = Location.create(pathFactory.createRootPath());
        request.setActualRootLocation(getActualLocation(entity.getId(), root).location);
    }
View Full Code Here

                    request.setError(new InvalidWorkspaceException(msg));
                    return;
            }
        }
        String fromWorkspaceName = request.nameOfWorkspaceToBeCloned();
        WorkspaceEntity fromWorkspace = workspaces.get(fromWorkspaceName, false);
        if (fromWorkspace == null) {
            switch (request.cloneConflictBehavior()) {
                case SKIP_CLONE:
                    break;
                case DO_NOT_CLONE:
                default:
                    String msg = JpaConnectorI18n.workspaceDoesNotExist.text(getSourceName(), fromWorkspaceName);
                    request.setError(new InvalidRequestException(msg));
                    return;
            }
        }

        // Create the workspace ...
        WorkspaceEntity intoWorkspace = workspaces.create(name);
        String newWorkspaceName = intoWorkspace.getName();
        request.setActualWorkspaceName(newWorkspaceName);

        if (fromWorkspace != null) {
            // Copy the workspace into the new workspace, via bulk insert statements ..
            Long fromWorkspaceId = fromWorkspace.getId();
            Long intoWorkspaceId = intoWorkspace.getId();
            Query query = entities.createNamedQuery("ChildEntity.findInWorkspace");
            query.setParameter("workspaceId", fromWorkspaceId);
            List<ChildEntity> childEntities = query.getResultList();
            for (ChildEntity child : childEntities) {
                ChildId origId = child.getId();
                ChildId copyId = new ChildId(intoWorkspaceId, origId.getParentUuidString(), origId.getChildUuidString());
                ChildEntity copy = new ChildEntity(copyId, child.getIndexInParent(), child.getChildNamespace(),
                                                   child.getChildName());
                copy.setAllowsSameNameChildren(child.getAllowsSameNameChildren());
                copy.setSameNameSiblingIndex(child.getSameNameSiblingIndex());
                entities.persist(copy);
            }
            entities.flush();

            query = entities.createNamedQuery("PropertiesEntity.findInWorkspace");
            query.setParameter("workspaceId", fromWorkspaceId);
            List<PropertiesEntity> properties = query.getResultList();
            for (PropertiesEntity property : properties) {
                NodeId copyId = new NodeId(intoWorkspaceId, property.getId().getUuidString());
                PropertiesEntity copy = new PropertiesEntity(copyId);
                copy.setCompressed(property.isCompressed());
                copy.setData(property.getData());
                copy.setPropertyCount(property.getPropertyCount());
                copy.setReferentialIntegrityEnforced(property.isReferentialIntegrityEnforced());
                Collection<LargeValueId> ids = property.getLargeValues();
                if (ids.size() != 0) {
                    copy.getLargeValues().addAll(ids);
                }
                entities.persist(copy);
            }
            entities.flush();

            query = entities.createNamedQuery("ReferenceEntity.findInWorkspace");
            query.setParameter("workspaceId", fromWorkspaceId);
            List<ReferenceEntity> references = query.getResultList();
            for (ReferenceEntity reference : references) {
                ReferenceId from = reference.getId();
                ReferenceId copy = new ReferenceId(fromWorkspaceId, from.getFromUuidString(), from.getToUuidString());
                entities.persist(new ReferenceEntity(copy));
            }
            entities.flush();
        }

        // Finish up the request ...
        Location root = Location.create(pathFactory.createRootPath(), rootNodeUuid);
        request.setActualRootLocation(getActualLocation(intoWorkspace.getId(), root).location);
    }
View Full Code Here

     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DestroyWorkspaceRequest)
     */
    @Override
    public void process( DestroyWorkspaceRequest request ) {
        // Verify the workspace exists ...
        WorkspaceEntity workspace = getExistingWorkspace(request.workspaceName(), request);
        if (workspace == null) return;
        Long workspaceId = workspace.getId();
        assert workspaceId != null;

        // Delete the workspace ...
        workspaces.destroy(workspace.getName());

        // Delete all the entities from this workspace ...
        Query delete = entities.createQuery("delete PropertiesEntity entity where entity.id.workspaceId = :workspaceId");
        delete.setParameter("workspaceId", workspaceId);
        delete.executeUpdate();
View Full Code Here

        super.close();
    }

    protected WorkspaceEntity getExistingWorkspace( String workspaceName,
                                                    Request request ) {
        WorkspaceEntity workspace = workspaces.get(workspaceName, false);
        if (workspace == null) {
            // Is this a predefined workspace?
            for (String name : predefinedWorkspaceNames) {
                if (workspaceName.equals(name)) {
                    // Create it anyway ...
View Full Code Here

     * @param workspaceName the name of the workspace; may not be null
     * @return the workspace entity, or null if there already was a workspace with the supplied name
     */
    public WorkspaceEntity create( String workspaceName ) {
        assert workspaceName != null;
        WorkspaceEntity entity = cache.get(workspaceName);
        if (entity != null) return null;
        entity = WorkspaceEntity.findByName(entityManager, workspaceName, false);
        if (entity != null) return null;
        // Create one ...
        entity = WorkspaceEntity.findByName(entityManager, workspaceName, true);
View Full Code Here

     * @return the workspace entity, or null if no workspace existed with the supplied name and <code>createIfRequired</code> was
     *         false
     */
    public WorkspaceEntity get( String workspaceName,
                                boolean createIfRequired ) {
        WorkspaceEntity entity = cache.get(workspaceName);
        if (entity == null) {
            entity = WorkspaceEntity.findByName(entityManager, workspaceName, createIfRequired);
            if (entity != null) {
                cache.put(workspaceName, entity);
            }
View Full Code Here

     * @param workspaceName the name of the workspace; may not be null
     * @return true if the workspace record was found and removed, or false if there was no workspace with the supplied name
     */
    public boolean destroy( String workspaceName ) {
        assert workspaceName != null;
        WorkspaceEntity entity = cache.remove(workspaceName);
        if (entity == null) {
            entity = WorkspaceEntity.findByName(entityManager, workspaceName, false);
        }
        if (entity != null) {
            entityManager.remove(entity);
View Full Code Here

TOP

Related Classes of org.jboss.dna.connector.store.jpa.model.common.WorkspaceEntity

Copyright © 2018 www.massapicom. 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.