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