use of com.openmeap.model.event.ModelEntityEvent in project OpenMEAP by OpenMEAP.
the class ModelManagerImpl method addModify.
@Override
public <T extends ModelEntity> T addModify(T entity, List<ProcessingEvent> events) throws InvalidPropertiesException, PersistenceException {
T revised = entity;
authorize(entity, determineCreateUpdateAction(entity));
ModelEntityEvent event = new ModelEntityEvent(ModelServiceOperation.SAVE_OR_UPDATE, entity);
stashModelEntityEventTillCommit(event);
callEventNotifiers(CutPoint.BEFORE_OPERATION, event, events);
revised = (T) event.getPayload();
revised = (T) _addModify(revised, events);
event.setPayload(revised);
callEventNotifiers(CutPoint.AFTER_OPERATION, event, events);
revised = (T) event.getPayload();
validate(revised);
return revised;
}
use of com.openmeap.model.event.ModelEntityEvent in project OpenMEAP by OpenMEAP.
the class ModelManagerImpl method processModelEntityEventQueue.
private void processModelEntityEventQueue(CutPoint cutPoint, List<ProcessingEvent> events) {
List<ModelEntityEvent> modelEvents;
if ((modelEvents = eventQueue.get(Thread.currentThread())) != null) {
int size = modelEvents.size();
for (int i = 0; i < size; i++) {
ModelEntityEvent event = modelEvents.get(i);
callEventNotifiers(cutPoint, event, events);
}
}
}
use of com.openmeap.model.event.ModelEntityEvent in project OpenMEAP by OpenMEAP.
the class ModelManagerImpl method delete.
@Override
public <T extends ModelEntity> ModelManager delete(T entity, List<ProcessingEvent> events) {
authorize(entity, Authorizer.Action.DELETE);
ModelEntityEvent event = new ModelEntityEvent(ModelServiceOperation.DELETE, entity);
stashModelEntityEventTillCommit(event);
callEventNotifiers(CutPoint.BEFORE_OPERATION, event, events);
_delete(entity, events);
callEventNotifiers(CutPoint.AFTER_OPERATION, event, events);
return this;
}
use of com.openmeap.model.event.ModelEntityEvent in project OpenMEAP by OpenMEAP.
the class AbstractModelServiceClusterServiceMgmtNotifier method makeRequest.
@Override
protected void makeRequest(URL url, Event<T> message) throws ClusterNotificationException {
try {
ModelEntityEvent event = (ModelEntityEvent) message;
T modelEntity = (T) event.getPayload();
String authToken = newAuthToken();
Hashtable<String, Object> parms = new Hashtable<String, Object>();
;
parms.put(UrlParamConstants.CLUSTERNODE_KEY, url.toString());
String sendUrl = url.toString() + "/" + ServletNameConstants.SERVICE_MANAGEMENT + "/?" + UrlParamConstants.ACTION + "=" + getEventActionName() + "&" + UrlParamConstants.AUTH_TOKEN + "=" + authToken;
addRequestParameters(modelEntity, parms);
logger.debug("Notification to {} with params {}", sendUrl, parms);
HttpResponse response = this.getHttpRequestExecuter().postData(sendUrl, parms);
int statusCode = response.getStatusCode();
logger.debug("Notification to {} returned status code {}", sendUrl, statusCode);
if (statusCode != 200) {
String responseText = Utils.readInputStream(response.getResponseBody(), FormConstants.CHAR_ENC_DEFAULT);
logger.error(responseText);
throw new ClusterNotificationException(url, String.format("Notification to %s returned status code %s and response text was ", sendUrl, statusCode));
} else {
Utils.consumeInputStream(response.getResponseBody());
}
} catch (Exception e) {
throw new ClusterNotificationException(url, e.getMessage(), e);
}
}
use of com.openmeap.model.event.ModelEntityEvent in project OpenMEAP by OpenMEAP.
the class ModelManagerImpl method refresh.
@Override
public <T extends ModelEntity> ModelManager refresh(T obj2Refresh, List<ProcessingEvent> events) throws PersistenceException {
ModelEntityEvent event = new ModelEntityEvent(ModelServiceOperation.REFRESH, obj2Refresh);
stashModelEntityEventTillCommit(event);
callEventNotifiers(CutPoint.BEFORE_OPERATION, event, events);
modelService.refresh(obj2Refresh);
callEventNotifiers(CutPoint.AFTER_OPERATION, event, events);
return this;
}
Aggregations