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);
}
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;
}
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;
}
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);
}
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;
}
}
Aggregations