Package org.apache.ace.client.repository.stateful

Examples of org.apache.ace.client.repository.stateful.StatefulTargetObject


          m_statefulTargetRepository.refresh();
            return null;
        }
    }, false, StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED, StatefulTargetObject.TOPIC_ADDED);

    StatefulTargetObject sgo = findStatefulTarget(targetID);
    assertNotNull("Target not added to repository?!", sgo);
   
    sgo.register();
   
    assertTrue("After registring our target, we assume it to be registered.", sgo.getRegistrationState().equals(RegistrationState.Registered));

    assertEquals("We expect our object's provisioning state to be Idle;", ProvisioningState.Idle, sgo.getProvisioningState());
    }
View Full Code Here


            .setImplementation(new UIExtensionFactory() {
                public Component create(Map<String, Object> context) {
                    VerticalLayout vl = new VerticalLayout();
                    vl.setCaption("Info");
                    final NamedObject namedObject = (NamedObject) context.get("object");
                    final StatefulTargetObject target = (StatefulTargetObject) namedObject.getObject();
                    Label info = new Label(
                        "Target ID          : " + namedObject.getName() + "\n" +
                        "Installed version  : " + (target.getLastInstallVersion() == null ? "(none)" : target.getLastInstallVersion()) + "\n" +
                        "Available version  : " + target.getCurrentVersion() + "\n" +
                        "Store state        : " + target.getStoreState() + "\n" +
                        "Provisioning state : " + target.getProvisioningState() + "\n" +
                        "Registration state : " + target.getRegistrationState());
                    info.setContentMode(Label.CONTENT_PREFORMATTED);
                    vl.addComponent(info);
                    return vl;
                }
            })
View Full Code Here

                m_feature2distributionAssociationRepository.create(getFeature(left), getDistribution(right));
            }

            @Override
            protected void associateFromRight(String left, String right) {
                StatefulTargetObject target = getTarget(right);
                if (!target.isRegistered()) {
                    target.register();
                    target.setAutoApprove(true);
                }
                m_distribution2targetAssociationRepository.create(getDistribution(left), target.getTargetObject());
            }
        });
        m_targetsPanel.setDropHandler(new AssociationDropHandler(m_distributionsPanel, (Table) null) {
            @Override
            protected void associateFromLeft(String left, String right) {
                StatefulTargetObject target = getTarget(right);
                if (!target.isRegistered()) {
                    target.register();
                    target.setAutoApprove(true);
                }
                m_distribution2targetAssociationRepository.create(getDistribution(left), target.getTargetObject());
            }

            @Override
            protected void associateFromRight(String left, String right) {
            }
View Full Code Here

    public Component create(Map<String, Object> context) {
        RepositoryObject object = getRepositoryObjectFromContext(context);

        Component content = new Label("This target is not yet registered, so it can not verify anything.");
        if (object instanceof StatefulTargetObject) {
            StatefulTargetObject statefulTarget = (StatefulTargetObject) object;
            if (statefulTarget.isRegistered()) {
                content = new ManifestArea(statefulTarget.getID(), getManifest(statefulTarget), statefulTarget);
            }
        }

        VerticalLayout result = new VerticalLayout();
        result.setMargin(true);
View Full Code Here

                createBasicTargetObject("testAutoApproveTarget");
                return null;
            }
        }, false, TargetObject.TOPIC_ADDED, TOPIC_ADDED);

        final StatefulTargetObject sgo =
            m_statefulTargetRepository.get(
                m_bundleContext.createFilter("(" + TargetObject.KEY_ID + "=" + "testAutoApproveTarget)")).get(0);

        // Set up some deployment information for the target.
        final FeatureObject g = runAndWaitForEvent(new Callable<FeatureObject>() {
            public FeatureObject call() throws Exception {
                ArtifactObject b = createBasicBundleObject("myBundle", "1.0", null);
                FeatureObject g = createBasicFeatureObject("myFeature");
                DistributionObject l = createBasicDistributionObject("myDistribution");
                m_artifact2featureRepository.create(b, g);
                m_feature2distributionRepository.create(g, l);
                m_distribution2targetRepository.create(l, sgo.getTargetObject());
                return g;
            }
        }, false, ArtifactObject.TOPIC_ADDED, FeatureObject.TOPIC_ADDED, DistributionObject.TOPIC_ADDED,
            Artifact2FeatureAssociation.TOPIC_ADDED, Feature2DistributionAssociation.TOPIC_ADDED,
            Distribution2TargetAssociation.TOPIC_ADDED, TOPIC_STATUS_CHANGED);

        assertTrue("We added some deployment information, so the target should need approval.", sgo.needsApprove());

        sgo.setAutoApprove(true);

        assertTrue("Turning on the autoapprove should not automatically approve whatever was waiting.", sgo.needsApprove());

        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                sgo.approve();
                return null;
            }
        }, false, TOPIC_STATUS_CHANGED);

        assertFalse("We approved the new version by hand, so we should not need approval.", sgo.needsApprove());

        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                ArtifactObject b = createBasicBundleObject("myBundle2", "1.0", null);
                m_artifact2featureRepository.create(b, g);
                return null;
            }
        }, false, ArtifactObject.TOPIC_ADDED, Artifact2FeatureAssociation.TOPIC_ADDED, TOPIC_STATUS_CHANGED,
            TOPIC_STATUS_CHANGED);

        assertFalse("With autoapprove on, adding new deployment information should still not need approval (at least, after the two CHANGED events).", sgo.needsApprove());

        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_statefulTargetRepository.unregister(sgo.getID());
                return null;
            }
        }, false, TOPIC_STATUS_CHANGED, TOPIC_REMOVED);
    }
View Full Code Here

            }, false, RepositoryAdmin.TOPIC_REFRESH);

            assertEquals("After refresh, we expect 1 target based on auditlogdata;", initRepoSize + 1, m_statefulTargetRepository.get().size());
           
            List<StatefulTargetObject> sgoList = m_statefulTargetRepository.get(m_bundleContext.createFilter("(id=another*)"));
            StatefulTargetObject sgo = sgoList.get(0);
            assertTrue("Expected one (anotherTarget) in the list.", sgo != null);

            // should be registered and auto approved
            assertTrue("The automation target operator should have registered anotherTarget.", sgo.isRegistered());
            assertTrue("The automation target operator should have auto-approved anotherTarget.", sgo.getAutoApprove());

            // add a target which will not be autoregistered
            events.clear();
            events.add(new LogEvent("secondTarget", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED, props));
            m_auditLogStore.put(events);

            // do auto target action
            processAuditlog.run();
            assertEquals("After refresh, we expect an additional target based on auditlogdata;", initRepoSize + 2, m_statefulTargetRepository.get().size());

            sgoList = m_statefulTargetRepository.get(m_bundleContext.createFilter("(id=second*)"));
            sgo = sgoList.get(0);

            // second target should not be registered
            assertFalse("The automation target operator should not have registered secondTarget.", sgo.isRegistered());
            assertFalse("The automation target operator should not have auto-approved myTarget.", sgo.getAutoApprove());
        }
        else
        {
            assertTrue("Could not get a reference to the processAuditLog task.", false);
        }
View Full Code Here

        DistributionObject l = createBasicDistributionObject("distribution");

        attr = new HashMap<String, String>();
        attr.put(TargetObject.KEY_ID, "myTarget");

        StatefulTargetObject sgo = m_statefulTargetRepository.preregister(attr, tags);

        m_artifact2featureRepository.create(b1, g);
        m_artifact2featureRepository.create(a1, g);
        m_artifact2featureRepository.create(a2, g);

        m_feature2distributionRepository.create(g, l);

        m_distribution2targetRepository.create(l, sgo.getTargetObject());

        try {
            sgo.approve();
            assertTrue("Without a resource processor for our artifact, approve should go wrong.", false);
        }
        catch (IllegalStateException ise) {
            // expected
        }

        // Now, add a processor for the artifact.
        attr = new HashMap<String, String>();
        attr.put(ArtifactObject.KEY_URL, "http://myprocessor");
        attr.put(BundleHelper.KEY_RESOURCE_PROCESSOR_PID, "my.processor.pid");
        attr.put(BundleHelper.KEY_SYMBOLICNAME, "my.processor.bundle");
        attr.put(ArtifactHelper.KEY_MIMETYPE, BundleHelper.MIMETYPE);

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

        sgo.approve();

        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];
View Full Code Here

        }, false, TOPIC_ADDED);

        ArtifactObject a1 = m_artifactRepository.importArtifact(noTemplateFile.toURI().toURL(), true);
        Artifact2FeatureAssociation a2g = m_artifact2featureRepository.create(a1, go);

        final StatefulTargetObject sgo = findStatefulTarget("templatetarget2");

        // create a deploymentversion
        assertTrue("With the new assignments, the SGO should need approval.", sgo.needsApprove());
       
        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                sgo.approve();
                return null;
            }
        }, false, 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
        m_artifact2featureRepository.remove(a2g);
        a1 = m_artifactRepository.importArtifact(simpleTemplateFile.toURI().toURL(), true);
        a2g = m_artifact2featureRepository.create(a1, go);

        sgo.approve();

        // find the deployment version
        dvo = m_deploymentVersionRepository.getMostRecentDeploymentVersion("templatetarget2");
        // sleep for a while, to allow the OBR to process the file.
        Thread.sleep(250);
View Full Code Here

                m_distribution2targetRepository.create(lo, gwo);
                return null;
            }
        }, false, TOPIC_ADDED);

        StatefulTargetObject sgo = findStatefulTarget(targetId);
        assertNotNull("Failed to find our target in the repository?!", sgo);

        // wait until needsApprove is true; depending on timing, this could have happened before or after the TOPIC_ADDED.
        int attempts = 0;
        while (!sgo.needsApprove() && (attempts++ < 10)) {
            Thread.sleep(100);
        }
       
        assertTrue("With the new assignments, the SGO should need approval.", sgo.needsApprove());
        // create a deploymentversion
        sgo.approve();

        // the preprocessor now has gotten its properties; inspect these
        PropertyResolver target = preprocessor.getProps();
        assertTrue("The property resolver should be able to resolve 'id'.", target.get("id").startsWith(targetId));
        assertTrue("The property resolver should be able to resolve 'name'.", target.get("name").startsWith("mydistribution"));
View Full Code Here

    public Component create(Map<String, Object> context) {
        final RepositoryObject sgo = getRepositoryObjectFromContext(context);

        Component editor;
        if (sgo instanceof StatefulTargetObject) {
            StatefulTargetObject statefulTarget = (StatefulTargetObject) sgo;
            if (statefulTarget.isRegistered()) {
                editor = createTagEditor(sgo);
            }
            else {
                editor = new Label("This target is not yet registered, so you cannot add tags.");
            }
View Full Code Here

TOP

Related Classes of org.apache.ace.client.repository.stateful.StatefulTargetObject

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.