Search in sources :

Example 6 with ApplicationArchive

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);
}
Also used : ApplicationArchive(com.openmeap.model.dto.ApplicationArchive)

Example 7 with ApplicationArchive

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);
}
Also used : MessagesEvent(com.openmeap.event.MessagesEvent) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive) File(java.io.File)

Example 8 with ApplicationArchive

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;
}
Also used : ApplicationVersion(com.openmeap.model.dto.ApplicationVersion) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive)

Example 9 with ApplicationArchive

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()));
        }
    }
}
Also used : InvalidPropertiesException(com.openmeap.model.InvalidPropertiesException) MessagesEvent(com.openmeap.event.MessagesEvent) PersistenceException(javax.persistence.PersistenceException) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive)

Example 10 with ApplicationArchive

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;
}
Also used : EventHandlingException(com.openmeap.event.EventHandlingException) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive) Result(com.openmeap.services.dto.Result)

Aggregations

ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)19 File (java.io.File)6 MessagesEvent (com.openmeap.event.MessagesEvent)5 Application (com.openmeap.model.dto.Application)5 GlobalSettings (com.openmeap.model.dto.GlobalSettings)5 ApplicationVersion (com.openmeap.model.dto.ApplicationVersion)4 Deployment (com.openmeap.model.dto.Deployment)4 IOException (java.io.IOException)4 PersistenceException (javax.persistence.PersistenceException)4 DigestException (com.openmeap.digest.DigestException)3 EventHandlingException (com.openmeap.event.EventHandlingException)3 InvalidPropertiesException (com.openmeap.model.InvalidPropertiesException)3 ClusterNotificationException (com.openmeap.cluster.ClusterNotificationException)2 GenericRuntimeException (com.openmeap.util.GenericRuntimeException)2 FileInputStream (java.io.FileInputStream)2 ZipFile (java.util.zip.ZipFile)2 FileItem (org.apache.commons.fileupload.FileItem)2 ClusterHandlingException (com.openmeap.cluster.ClusterHandlingException)1 ModelEntity (com.openmeap.model.ModelEntity)1 ModelManager (com.openmeap.model.ModelManager)1