use of com.openmeap.model.dto.ApplicationArchive in project OpenMEAP by OpenMEAP.
the class AbstractArchiveFileEventNotifier method addRequestParameters.
protected void addRequestParameters(ModelEntity modelEntity, Map<String, Object> parms) {
ApplicationArchive archive = (ApplicationArchive) modelEntity;
String hash = archive.getHash();
String hashType = archive.getHashAlgorithm();
parms.put(UrlParamConstants.APPARCH_HASH, hash);
parms.put(UrlParamConstants.APPARCH_HASH_ALG, hashType);
}
use of com.openmeap.model.dto.ApplicationArchive in project OpenMEAP by OpenMEAP.
the class DeploymentAddModifyNotifier method notify.
@Override
public <E extends Event<Deployment>> void notify(final E event, List<ProcessingEvent> events) throws ClusterNotificationException {
ApplicationArchive archive = (ApplicationArchive) ((Deployment) event.getPayload()).getApplicationArchive();
File archiveFile = archive.getFile(getModelManager().getGlobalSettings().getTemporaryStoragePath());
if (!archiveFile.exists()) {
String msg = String.format("The archive file %s cannot be found. This could be because you opted to fill in the version details yourself.", archiveFile.getAbsoluteFile());
logger.warn(msg);
events.add(new MessagesEvent(msg));
return;
}
super.notify(event, events);
}
use of com.openmeap.model.dto.ApplicationArchive in project OpenMEAP by OpenMEAP.
the class ModelManagerImplTest method newValidAppVersion.
/**
* Encapsulated so I can make a bunch of minor variations on a valid app version
* to test the model manager rigorously
* @param app
* @return
*/
ApplicationVersion newValidAppVersion(Application app) {
ApplicationVersion version = new ApplicationVersion();
version.setIdentifier(UUID.randomUUID().toString());
version.setArchive(new ApplicationArchive());
version.getArchive().setApplication(app);
version.getArchive().setUrl("ApplicationArchive.url.3");
version.getArchive().setHashAlgorithm("SHA1");
version.getArchive().setHash("ApplicationArchive.hash.3");
version.getArchive().setBytesLength(1000);
version.getArchive().setBytesLengthUncompressed(1000);
version.setCreateDate(null);
version.setNotes(null);
version.setApplication(app);
return version;
}
use of com.openmeap.model.dto.ApplicationArchive in project OpenMEAP by OpenMEAP.
the class AddModifyApplicationVersionBacking method processApplicationVersionFromParameters.
private void processApplicationVersionFromParameters(Application app, ApplicationVersion version, List<ProcessingEvent> events, Map<Object, Object> parameterMap) {
// then create a new archive for it.
if (version.getPk() == null) {
version.setArchive(new ApplicationArchive());
version.getArchive().setApplication(app);
version.setApplication(app);
}
fillInApplicationVersionFromParameters(app, version, events, parameterMap);
if (version != null && version.getArchive() == null) {
events.add(new MessagesEvent("Application archive could not be created. Not creating empty version."));
} else {
try {
modelManager.begin();
version.setLastModifier(firstValue("userPrincipalName", parameterMap));
ApplicationArchive savedArchive = version.getArchive();
version.setArchive(null);
savedArchive = modelManager.addModify(savedArchive, events);
version.setArchive(savedArchive);
version = modelManager.addModify(version, events);
app.addVersion(version);
app = modelManager.addModify(app, events);
modelManager.commit(events);
modelManager.refresh(app, events);
events.add(new MessagesEvent("Application version successfully created/modified!"));
} catch (InvalidPropertiesException ipe) {
modelManager.rollback();
logger.error("Unable to add/modify version " + version.getIdentifier(), ipe);
events.add(new MessagesEvent("Unable to add/modify version - " + ipe.getMessage()));
} catch (PersistenceException pe) {
modelManager.rollback();
logger.error("Unable to add/modify version " + version.getIdentifier(), pe);
events.add(new MessagesEvent("Unable to add/modify version - " + pe.getMessage()));
}
}
}
use of com.openmeap.model.dto.ApplicationArchive in project OpenMEAP by OpenMEAP.
the class ServiceManagementServlet method handleArchiveEvent.
@SuppressWarnings(value = { "rawtypes", "unchecked" })
private Result handleArchiveEvent(EventHandler eventHandler, Event event, Map<Object, Object> paramMap) throws IOException {
String hash = firstValue(UrlParamConstants.APPARCH_HASH, paramMap);
String hashType = firstValue(UrlParamConstants.APPARCH_HASH_ALG, paramMap);
logger.info("Received request archive upload notification {}:{}", hashType, hash);
Result result = null;
if (hash != null && hashType != null) {
ApplicationArchive arch = new ApplicationArchive();
arch.setHash(hash);
arch.setHashAlgorithm(hashType);
try {
paramMap.put("archive", arch);
eventHandler.handle(event);
result = new Result(Result.Status.SUCCESS);
} catch (EventHandlingException che) {
String msg = "Exception occurred handing the ArchiveUploadEvent";
logger.error(msg, che);
result = new Result(Result.Status.FAILURE, msg);
}
} else {
String msg = "Either the hash(" + hash + ") or the hashType(" + hashType + ") was null. Both are needed to process an archive event";
logger.error(msg);
result = new Result(Result.Status.FAILURE, msg);
}
return result;
}
Aggregations