Search in sources :

Example 1 with ApplicationInstallation

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

the class ModelServiceRefreshNotifier method makeRequest.

/**
	 * This MUST remain state-less
	 * 
	 * @param <T>
	 * @param thisUrl
	 * @param obj
	 */
@Override
protected void makeRequest(final URL url, final Event<ModelEntity> mesg) throws ClusterNotificationException {
    com.openmeap.http.HttpResponse httpResponse = null;
    String simpleName = null;
    String thisUrl = url.toString() + "/" + ServletNameConstants.SERVICE_MANAGEMENT + "/";
    ModelEntity obj = mesg.getPayload();
    // I am not using obj.getClass().getSimpleName() because of Hibernate Proxy object wrapping
    if (obj instanceof Application)
        simpleName = "Application";
    else if (obj instanceof ApplicationVersion)
        simpleName = "ApplicationVersion";
    else if (obj instanceof ApplicationArchive)
        simpleName = "ApplicationArchive";
    else if (obj instanceof ApplicationInstallation)
        simpleName = "ApplicationInstallation";
    else if (obj instanceof GlobalSettings)
        simpleName = "GlobalSettings";
    else
        return;
    Hashtable<String, Object> parms = new Hashtable<String, Object>();
    parms.put(UrlParamConstants.ACTION, ModelEntityEventAction.MODEL_REFRESH.getActionName());
    parms.put(UrlParamConstants.AUTH_TOKEN, newAuthToken());
    parms.put(UrlParamConstants.REFRESH_TYPE, simpleName);
    parms.put(UrlParamConstants.REFRESH_OBJ_PKID, obj.getPk());
    try {
        logger.debug("Refresh post to {} for {} with id {}", new Object[] { thisUrl, simpleName, obj.getPk() });
        httpResponse = getHttpRequestExecuter().postData(thisUrl, parms);
        Utils.consumeInputStream(httpResponse.getResponseBody());
        int statusCode = httpResponse.getStatusCode();
        if (statusCode != 200) {
            String exMesg = "HTTP " + statusCode + " returned for refresh post to " + thisUrl + " for " + simpleName + " with id " + obj.getPk();
            logger.error(exMesg);
            throw new ClusterNotificationException(url, exMesg);
        }
    } catch (Exception e) {
        String exMesg = "Refresh post to " + thisUrl + " for " + simpleName + " with id " + obj.getPk() + " threw an exception";
        logger.error(exMesg, e);
        throw new ClusterNotificationException(url, exMesg, e);
    }
}
Also used : ApplicationVersion(com.openmeap.model.dto.ApplicationVersion) Hashtable(java.util.Hashtable) ClusterNotificationException(com.openmeap.cluster.ClusterNotificationException) GlobalSettings(com.openmeap.model.dto.GlobalSettings) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive) ClusterNotificationException(com.openmeap.cluster.ClusterNotificationException) ApplicationInstallation(com.openmeap.model.dto.ApplicationInstallation) ModelEntity(com.openmeap.model.ModelEntity) Application(com.openmeap.model.dto.Application)

Example 2 with ApplicationInstallation

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

the class ModelManagerImplTest method testAddModifyApplicationInstallation.

@Test
public void testAddModifyApplicationInstallation() throws Exception {
    ApplicationInstallation ai = new ApplicationInstallation();
    ai.setApplicationVersion(modelManager.getModelService().findAppVersionByNameAndId("Application.name", "ApplicationVersion.identifier.1"));
    ai.setUuid("AppInst.name.1");
    modelManager.begin().addModify(ai, null);
    modelManager.commit();
    ai = modelManager.getModelService().findByPrimaryKey(ApplicationInstallation.class, "AppInst.name.1");
    Assert.assertTrue(ai != null);
}
Also used : ApplicationInstallation(com.openmeap.model.dto.ApplicationInstallation) Test(org.junit.Test)

Aggregations

ApplicationInstallation (com.openmeap.model.dto.ApplicationInstallation)2 ClusterNotificationException (com.openmeap.cluster.ClusterNotificationException)1 ModelEntity (com.openmeap.model.ModelEntity)1 Application (com.openmeap.model.dto.Application)1 ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)1 ApplicationVersion (com.openmeap.model.dto.ApplicationVersion)1 GlobalSettings (com.openmeap.model.dto.GlobalSettings)1 Hashtable (java.util.Hashtable)1 Test (org.junit.Test)1