Search in sources :

Example 1 with Deployment

use of com.openmeap.model.dto.Deployment in project OpenMEAP by OpenMEAP.

the class ApplicationManagementPortTypeImplTest method testConnectionOpen_verifyInitialVersionIdentifierRecognized.

/**
 * Verify that no exceptions are thrown and no update returned
 * when the version SLIC reports is the same as the initial version.
 */
@Test
public void testConnectionOpen_verifyInitialVersionIdentifierRecognized() throws Exception {
    thrown = false;
    request.getApplication().setVersionId("ApplicationVersion.identifier.bundled");
    com.openmeap.model.dto.Application app = modelManager.getModelService().findByPrimaryKey(Application.class, 1L);
    Iterator<Deployment> i = new ArrayList<Deployment>(app.getDeployments()).iterator();
    try {
        modelManager.begin();
        while (i.hasNext()) {
            Deployment d = i.next();
            modelManager.delete(d, null);
        }
        modelManager.commit();
    } catch (Exception e) {
        modelManager.rollback();
        throw new Exception(e);
    }
    try {
        response = appMgmtSvc.connectionOpen(request);
    } catch (WebServiceException wse) {
        thrown = true;
    }
    Assert.assertTrue("No update should be returned here", response.getUpdate() == null);
    Assert.assertTrue("The originally bundled application version id should not trigger an exception", thrown == false);
}
Also used : WebServiceException(com.openmeap.protocol.WebServiceException) Deployment(com.openmeap.model.dto.Deployment) Application(com.openmeap.model.dto.Application) WebServiceException(com.openmeap.protocol.WebServiceException) Test(org.junit.Test)

Example 2 with Deployment

use of com.openmeap.model.dto.Deployment in project OpenMEAP by OpenMEAP.

the class DeploymentListingsBacking method process.

public Collection<ProcessingEvent> process(ProcessingContext context, Map<Object, Object> templateVariables, Map<Object, Object> parameterMap) {
    List<ProcessingEvent> events = new ArrayList<ProcessingEvent>();
    templateVariables.put(FormConstants.PROCESS_TARGET, PROCESS_TARGET);
    String appId = firstValue(FormConstants.APP_ID, parameterMap);
    String appVerId = firstValue("versionId", parameterMap);
    String deploymentType = firstValue("deploymentType", parameterMap);
    String processTarget = firstValue(FormConstants.PROCESS_TARGET, parameterMap);
    Application app = null;
    try {
        app = modelManager.getModelService().findByPrimaryKey(Application.class, Long.valueOf(appId));
    } catch (NumberFormatException nfe) {
        events.add(new MessagesEvent("A valid applicationId must be supplied to either view or create deployments."));
    }
    events.add(new AddSubNavAnchorEvent(new Anchor("?bean=addModifyAppPage&applicationId=" + app.getId(), "View/Modify Application", "View/Modify Application")));
    events.add(new AddSubNavAnchorEvent(new Anchor("?bean=appVersionListingsPage&applicationId=" + app.getId(), "Version Listings", "Version Listings")));
    // TODO: I'm pretty sure I should create new deployments elsewhere and forward to here from there.
    if (deploymentType != null && PROCESS_TARGET.compareTo(processTarget) == 0 && app != null) {
        ApplicationVersion version = null;
        try {
            version = modelManager.getModelService().findByPrimaryKey(ApplicationVersion.class, Long.valueOf(appVerId));
        } catch (NumberFormatException nfe) {
            events.add(new MessagesEvent("A valid versionId must be supplied to create a deployment."));
        }
        if (version != null) {
            Deployment depl = createDeployment(firstValue("userPrincipalName", parameterMap), version, deploymentType);
            try {
                modelManager.begin();
                depl = modelManager.addModify(depl, events);
                modelManager.commit(events);
                events.add(new MessagesEvent("Deployment successfully completed."));
            } catch (Exception pe) {
                modelManager.rollback();
                Throwable root = ExceptionUtils.getRootCause(pe);
                events.add(new MessagesEvent(String.format("An exception was thrown creating the deployment: %s %s", root.getMessage(), ExceptionUtils.getStackTrace(root))));
            }
        }
    }
    // making sure to order the deployments by date
    if (app != null && app.getDeployments() != null) {
        List<Deployment> deployments = modelManager.getModelService().findDeploymentsByApplication(app);
        Collections.sort(deployments, new Deployment.DateComparator());
        templateVariables.put("deployments", deployments);
        GlobalSettings settings = modelManager.getGlobalSettings();
        Map<String, String> urls = new HashMap<String, String>();
        for (Deployment depl : deployments) {
            urls.put(depl.getApplicationArchive().getHash(), depl.getApplicationArchive().getDownloadUrl(settings));
        }
        templateVariables.put("deployments", deployments);
        templateVariables.put("archiveUrls", urls);
    }
    return events;
}
Also used : ApplicationVersion(com.openmeap.model.dto.ApplicationVersion) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AddSubNavAnchorEvent(com.openmeap.admin.web.events.AddSubNavAnchorEvent) Deployment(com.openmeap.model.dto.Deployment) GlobalSettings(com.openmeap.model.dto.GlobalSettings) InvalidPropertiesException(com.openmeap.model.InvalidPropertiesException) PersistenceException(javax.persistence.PersistenceException) Anchor(com.openmeap.web.html.Anchor) MessagesEvent(com.openmeap.event.MessagesEvent) ProcessingEvent(com.openmeap.event.ProcessingEvent) Application(com.openmeap.model.dto.Application)

Example 3 with Deployment

use of com.openmeap.model.dto.Deployment in project OpenMEAP by OpenMEAP.

the class DeploymentListingsBacking method createDeployment.

private Deployment createDeployment(String creator, ApplicationVersion version, String deploymentType) {
    GlobalSettings settings = modelManager.getGlobalSettings();
    Deployment depl = new Deployment();
    depl.setType(Deployment.Type.valueOf(deploymentType));
    depl.setApplicationArchive(version.getArchive());
    depl.setCreateDate(new java.util.Date());
    depl.setCreator(creator);
    depl.setVersionIdentifier(version.getIdentifier());
    version.getApplication().addDeployment(depl);
    return depl;
}
Also used : Deployment(com.openmeap.model.dto.Deployment) GlobalSettings(com.openmeap.model.dto.GlobalSettings)

Example 4 with Deployment

use of com.openmeap.model.dto.Deployment in project OpenMEAP by OpenMEAP.

the class DeploymentAddModifyNotifier method addRequestParameters.

@Override
protected void addRequestParameters(ModelEntity modelEntity, Map<String, Object> parms) {
    ApplicationArchive archive = (ApplicationArchive) (((Deployment) modelEntity).getApplicationArchive());
    parms.put(UrlParamConstants.APPARCH_FILE, archive.getFile(getModelManager().getGlobalSettings().getTemporaryStoragePath()));
    super.addRequestParameters(archive, parms);
}
Also used : Deployment(com.openmeap.model.dto.Deployment) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive)

Example 5 with Deployment

use of com.openmeap.model.dto.Deployment in project OpenMEAP by OpenMEAP.

the class ModelServiceImpl method findDeploymentsByApplication.

@Override
public List<Deployment> findDeploymentsByApplication(Application app) {
    Query q = entityManager.createQuery("select d " + "from Deployment d " + "inner join fetch d.applicationArchive aa " + "inner join d.application a " + "where a.name=:name");
    q.setParameter("name", app.getName());
    try {
        @SuppressWarnings(value = { "unchecked" }) List<Deployment> deployments = (List<Deployment>) q.getResultList();
        return deployments;
    } catch (NoResultException nre) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) Deployment(com.openmeap.model.dto.Deployment) List(java.util.List) NoResultException(javax.persistence.NoResultException)

Aggregations

Deployment (com.openmeap.model.dto.Deployment)16 Application (com.openmeap.model.dto.Application)8 ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)4 GlobalSettings (com.openmeap.model.dto.GlobalSettings)4 MessagesEvent (com.openmeap.event.MessagesEvent)3 ApplicationVersion (com.openmeap.model.dto.ApplicationVersion)3 Anchor (com.openmeap.web.html.Anchor)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 NoResultException (javax.persistence.NoResultException)3 Query (javax.persistence.Query)3 Test (org.junit.Test)3 AddSubNavAnchorEvent (com.openmeap.admin.web.events.AddSubNavAnchorEvent)2 ProcessingEvent (com.openmeap.event.ProcessingEvent)2 InvalidPropertiesException (com.openmeap.model.InvalidPropertiesException)2 WebServiceException (com.openmeap.protocol.WebServiceException)2 List (java.util.List)2 PersistenceException (javax.persistence.PersistenceException)2 ClusterNotificationException (com.openmeap.cluster.ClusterNotificationException)1 DigestException (com.openmeap.digest.DigestException)1