Commit 991c2dd5 authored by Jörg Richter's avatar Jörg Richter

Fix: client-sync for newly created assoc types (closes #212)

parent 46057572
Pipeline #6490 passed with stages
in 3 minutes and 23 seconds
......@@ -9,7 +9,7 @@ import 'font-awesome/css/font-awesome.css'
import './element-ui'
import './websocket'
console.log('[DMX] 2019/05/20')
console.log('[DMX] 2019/05/21')
// 1) Init dm5 library
// The dm5 library must be inited *before* the dm5-webclient component is instantiated.
......
......@@ -295,7 +295,9 @@ public class WebservicePlugin extends PluginActivator {
@Path("/assoctype")
@Transactional
public AssociationType createAssociationType(AssociationTypeModel model) {
return dmx.createAssociationType(model);
AssociationType assocType = dmx.createAssociationType(model);
me.newAssocType(assocType);
return assocType;
}
@PUT
......@@ -509,6 +511,9 @@ public class WebservicePlugin extends PluginActivator {
// ------------------------------------------------------------------------------------------------- Private Classes
// Note: client-sync for new types is only performed when type is created through REST API, not when type is created
// through Core Service (e.g. while running a migration). This is because message-to-all-but-one requires a request.
// Technically the Core Service is not a JAX-RS root resource, so injection (e.g. the request) does not work there.
private class Messenger {
private String pluginUri;
......@@ -532,6 +537,19 @@ public class WebservicePlugin extends PluginActivator {
}
}
private void newAssocType(AssociationType assocType) {
try {
messageToAllButOne(new JSONObject()
.put("type", "newAssocType")
.put("args", new JSONObject()
.put("assocType", assocType.toJSON())
)
);
} catch (Exception e) {
logger.log(Level.WARNING, "Error while sending a \"newAssocType\" message:", e);
}
}
// ---
private void messageToAllButOne(JSONObject message) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment