Package org.apache.ace.client.repository.object

Examples of org.apache.ace.client.repository.object.DeploymentVersionObject


        assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[1].getUrl().equals("artifact2");
    }

    @Test( groups = { TestUtils.UNIT } )
    public void testDeploymentRepository() {
        DeploymentVersionObject version11 = createBasicDeploymentVersionObject("target1", "1", new String[] {"artifact1", "artifact2"});
        DeploymentVersionObject version12 = createBasicDeploymentVersionObject("target1", "2", new String[] {"artifact3", "artifact4"});
        // Note the different order in adding the versions for target2.
        DeploymentVersionObject version22 = createBasicDeploymentVersionObject("target2", "2", new String[] {"artifactC", "artifactD"});
        DeploymentVersionObject version21 = createBasicDeploymentVersionObject("target2", "1", new String[] {"artifactA", "artifactB"});

        assert m_deploymentVersionRepository.getDeploymentVersions("NotMyTarget").size() == 0 : "The deployment repository should not return" +
            "any versions when we ask for a target that does not exist, but it returns " + m_deploymentVersionRepository.getDeploymentVersions("NotMyTarget").size();

        List<DeploymentVersionObject> for1 = m_deploymentVersionRepository.getDeploymentVersions("target1");
View Full Code Here


    @Test( groups = { TestUtils.UNIT } )
    public void testDeploymentRepositoryFilter() {

        String gwId = "\\ ( * ) target1)";
        DeploymentVersionObject version1 = createBasicDeploymentVersionObject(gwId, "1", new String[] {"artifact1", "artifact2"});

        List<DeploymentVersionObject> for1 = m_deploymentVersionRepository.getDeploymentVersions( gwId );
        assert for1.size() == 1 : "We expect one version for" + gwId + ", but we find " + for1.size();
        assert for1.get(0) == version1 : "The only version for" + gwId +  "should be version1";
    }
View Full Code Here

                m_repositoryAdmin.commit();
                return null;
            }
        }, false, DeploymentVersionObject.TOPIC_ADDED, TOPIC_STATUS_CHANGED);       

        DeploymentVersionObject dep = m_deploymentVersionRepository.getMostRecentDeploymentVersion(sgo.getID());

        DeploymentArtifact[] toDeploy = dep.getDeploymentArtifacts();

        assertEquals("We expect to find four artifacts to deploy;", 4, toDeploy.length);
        DeploymentArtifact bundle1 = toDeploy[0];
        assertEquals(b1.getURL(), bundle1.getUrl());
       
        DeploymentArtifact bundle2 = toDeploy[1];
        assertEquals(b2.getURL(), bundle2.getUrl());
        assertEquals("true", bundle2.getDirective(DeploymentArtifact.DIRECTIVE_ISCUSTOMIZER));
       
        DeploymentArtifact artifact1 = toDeploy[2];
        assertEquals(a1.getURL(), artifact1.getUrl());
        assertEquals("my.processor.pid", artifact1.getDirective(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID));
       
        DeploymentArtifact artifact2 = toDeploy[3];
        assertEquals(a2.getURL(), artifact2.getUrl());
        assertEquals("my.processor.pid", artifact2.getDirective(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID));
        assertEquals(a2.getResourceId(), artifact2.getDirective(DeploymentArtifact.DIRECTIVE_KEY_RESOURCE_ID));
       
        // Now, add a new version of the processor (ACE-373)
        assertFalse("There should be no changes.", sgo.needsApprove());

        attr = new HashMap<String, String>();
        attr.put(ArtifactObject.KEY_URL, "http://myprocessor/v2");
        attr.put(BundleHelper.KEY_RESOURCE_PROCESSOR_PID, "my.processor.pid");
        attr.put(BundleHelper.KEY_SYMBOLICNAME, "my.processor.bundle");
        attr.put(BundleHelper.KEY_VERSION, "2.0.0");
        attr.put(ArtifactHelper.KEY_MIMETYPE, BundleHelper.MIMETYPE);

        ArtifactObject b3 = m_artifactRepository.create(attr, tags);

        assertTrue("By adding a resource processor, we should have triggered a change that needs to be approved.", sgo.needsApprove());

        sgo.approve();

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
                m_repositoryAdmin.commit();
                return null;
            }
        }, false, DeploymentVersionObject.TOPIC_ADDED, TOPIC_STATUS_CHANGED);

        dep = m_deploymentVersionRepository.getMostRecentDeploymentVersion(sgo.getID());

        toDeploy = dep.getDeploymentArtifacts();

        assertEquals("We expect to find four artifacts to deploy;", 4, toDeploy.length);
        boolean foundBundle = false;
        boolean foundProcessor = false;
        boolean foundArtifact1 = false;
View Full Code Here

                return null;
            }
        }, false, DeploymentVersionObject.TOPIC_ADDED, TOPIC_STATUS_CHANGED)
       
        // find the deployment version
        DeploymentVersionObject dvo = m_deploymentVersionRepository.getMostRecentDeploymentVersion("templatetarget2");
        String inFile = tryGetStringFromURL(findXmlUrlInDeploymentObject(dvo), 10, 100);

        assertEquals(xmlHeader + noTemplateProcessed + xmlFooter, inFile);

        // try the simple template
View Full Code Here

            }
        }, false, Distribution2TargetAssociation.TOPIC_ADDED, TOPIC_STATUS_CHANGED);

        assertEquals(UNKNOWN_VERSION, sgo.getCurrentVersion());

        DeploymentVersionObject deploymentVersionObject = runAndWaitForEvent(new Callable<DeploymentVersionObject>() {
            public DeploymentVersionObject call() throws Exception {
                return createBasicDeploymentVersionObject(targetId, "1", b1, b2, b3);
            }
        }, false, DeploymentVersionObject.TOPIC_ADDED, TOPIC_STATUS_CHANGED);

        assertNotNull(deploymentVersionObject);

        DeploymentArtifact[] deploymentArtifacts = deploymentVersionObject.getDeploymentArtifacts();
        for (DeploymentArtifact deploymentArtifact : deploymentArtifacts) {
            if (deploymentArtifact.getUrl().contains("bundle1")) {
                assertEquals(10L, deploymentArtifact.getSize());
            }
            else if (deploymentArtifact.getUrl().contains("bundle2")) {
View Full Code Here

    public List<Event> getAuditEvents() {
        return m_repository.getAuditEvents(getID());
    }

    public String getCurrentVersion() {
        DeploymentVersionObject version = m_repository.getMostRecentDeploymentVersion(getID());
        if (version == null) {
            return StatefulTargetObject.UNKNOWN_VERSION;
        }
        else {
            return version.getVersion();
        }
    }
View Full Code Here

        }
    }

    public DeploymentArtifact[] getArtifactsFromDeployment() {
        synchronized (m_lock) {
            DeploymentVersionObject mostRecentDeploymentVersion = m_repository.getMostRecentDeploymentVersion(getID());
            if (mostRecentDeploymentVersion != null) {
                return mostRecentDeploymentVersion.getDeploymentArtifacts();
            }
            return new DeploymentArtifact[0];
        }
    }
View Full Code Here

    private void determineStoreState(DeploymentVersionObject deploymentVersionObject) {
        synchronized (m_lock) {
            SortedSet<String> fromShop = new TreeSet<String>();
            ArtifactObject[] artifactsFromShop = m_repository.getNecessaryArtifacts(getID());
            DeploymentVersionObject mostRecentVersion;
            if (deploymentVersionObject == null) {
                mostRecentVersion = m_repository.getMostRecentDeploymentVersion(getID());
            }
            else {
                mostRecentVersion = deploymentVersionObject;
            }
            if (artifactsFromShop == null) {
                if (mostRecentVersion == null) {
                    setStoreState(StoreState.New);
                }
                else {
                    setStoreState(StoreState.Unapproved);
                }
                return;
            }

            for (ArtifactObject ao : artifactsFromShop) {
                fromShop.add(ao.getURL());
            }

            SortedSet<String> fromDeployment = new TreeSet<String>();
            for (DeploymentArtifact da : getArtifactsFromDeployment()) {
                fromDeployment.add(da.getDirective(DeploymentArtifact.DIRECTIVE_KEY_BASEURL));
            }

            if ((mostRecentVersion == null) && fromShop.isEmpty()) {
                setStoreState(StoreState.New);
            }
            else if (fromShop.equals(fromDeployment)) {
                // great, we have the same artifacts. But... do they need to be reprocessed?
                // this might be the case when the target has new tags that affect templates
                for (ArtifactObject ao : artifactsFromShop) {
                    if (m_repository.needsNewVersion(ao, getID(), mostRecentVersion.getVersion())) {
                        setStoreState(StoreState.Unapproved);
                        return;
                    }
                }
                setStoreState(StoreState.Approved);
View Full Code Here

        return result;
    }

    public DeploymentVersionObject getMostRecentDeploymentVersion(String targetID) {
        List<DeploymentVersionObject> versions = getDeploymentVersions(targetID);
        DeploymentVersionObject result = null;
        if ((versions != null) && (versions.size() > 0)) {
            result = versions.get(versions.size() - 1);
        }
        return result;
    }
View Full Code Here

    private void purgeOldDeploymentVersions(int deploymentVersionLimit) {
        Map<String, SortedSet<DeploymentVersionObject>> index = createDeploymentVersionIndex();
        for (Map.Entry<String, SortedSet<DeploymentVersionObject>> entry : index.entrySet()) {
            SortedSet<DeploymentVersionObject> versions = entry.getValue();
            while (versions.size() > deploymentVersionLimit) {
                DeploymentVersionObject head = versions.first();
                // We can be called while unmarshalling the database, hence we need to ensure that we do not use the
                // public API as this one throws an exception while this repository is busy. See ACE-449.
                internalRemove(head);
                versions.remove(head);
            }
View Full Code Here

TOP

Related Classes of org.apache.ace.client.repository.object.DeploymentVersionObject

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.