Commit be7c852f authored by Jörg Richter's avatar Jörg Richter

Revise REST API (no underscores) (#341)

BREAKING CHANGES

2 general changes:
- In resource names `-` is used instead of `_`
- Query parameters are camel case (not underscore), just like the corresponding Java/JS variables;
  no conversion required anymore

Examples of new requests:
```
POST /accesscontrol/user-account
POST /topicmaps?name=...&topicmapTypeUri=...
```

Traversal:
```
...?assocTypeUri=...&myRoleTypeUri=...&othersRoleTypeUri=...&othersTopicTypeUri=...
```

Include assoc children:
```
...?assocChildren=true
```

As long as plugin/script authors make use of the dmx-api JS library no adaptions will be required.
parent e06d629a
Pipeline #10617 passed with stages
in 8 minutes and 21 seconds
......@@ -235,7 +235,7 @@ public class AccessControlPlugin extends PluginActivator implements AccessContro
// === User Accounts ===
@POST
@Path("/user_account")
@Path("/user-account")
@Transactional
@Override
public Topic createUserAccount(Credentials cred) {
......
......@@ -39,7 +39,7 @@ import java.util.logging.Logger;
* - the Caching plugin sets the <code>Cache-Control</code> response header
* - the Timestamps plugin sets the <code>Last-Modified</code> response header
* <li>Load child topics of the response object(s) if requested with the <code>children</code> and
* <code>assoc_children</code> query parameters.
* <code>assocChildren</code> query parameters.
* <li>Fire the <code>CoreEvent.PRE_SEND_XXX</code> events for all response object(s) and objects contained in response
* directives. This let plugins operate on the response on a per-object basis, e.g.
* - the Geomaps plugin enriches an Address topic with its geo coordinate
......@@ -234,7 +234,7 @@ class JerseyResponseFilter implements ContainerResponseFilter {
}
private boolean getIncludeAssocChildren(ContainerRequest request) {
return getBooleanQueryParameter(request, "assoc_children");
return getBooleanQueryParameter(request, "assocChildren");
}
// ---
......
......@@ -74,9 +74,9 @@ export default ({store}) => {
} else if (object.typeUri === 'dmx.core.assoc_type') {
return `/core/assoctype/${object.uri}`
} else if (object.isTopic()) {
return `/core/topic/${object.id}?children=true&assoc_children=true`
return `/core/topic/${object.id}?children=true&assocChildren=true`
} else if (object.isAssoc()) {
return `/core/assoc/${object.id}?children=true&assoc_children=true`
return `/core/assoc/${object.id}?children=true&assocChildren=true`
}
throw Error('unexpected object')
}
......
......@@ -8,7 +8,7 @@
</div>
<div class="field">
<div class="field-label">Released</div>
Jul 26, 2020
Jul 27, 2020
</div>
<div class="field">
<div class="field-label">License</div>
......
......@@ -82,7 +82,7 @@ public class TopicmapsPlugin extends PluginActivator implements TopicmapsService
@Transactional
@Override
public Topic createTopicmap(@QueryParam("name") String name,
@QueryParam("topicmap_type_uri") String topicmapTypeUri,
@QueryParam("topicmapTypeUri") String topicmapTypeUri,
ViewProps viewProps) {
try {
logger.info("Creating topicmap \"" + name + "\", topicmapTypeUri=\"" + topicmapTypeUri + "\", viewProps=" +
......
......@@ -9,7 +9,7 @@ import extraElementUI from './element-ui'
import 'font-awesome/css/font-awesome.css'
import './websocket'
console.log('[DMX] 2020/07/26')
console.log('[DMX] 2020/07/27')
// 1) Init dm5 library
// The dm5 library must be inited *before* the dm5-webclient component is instantiated.
......
......@@ -108,8 +108,8 @@ public class WebservicePlugin extends PluginActivator {
@GET
@Path("/topics/query/{query}")
public QueryResult queryTopicsFulltext(@PathParam("query") String query,
@QueryParam("topic_type_uri") String topicTypeUri,
@QueryParam("search_child_topics") boolean searchChildTopics) {
@QueryParam("topicTypeUri") String topicTypeUri,
@QueryParam("searchChildTopics") boolean searchChildTopics) {
return dmx.queryTopicsFulltext(query, topicTypeUri, searchChildTopics);
}
......@@ -167,10 +167,10 @@ public class WebservicePlugin extends PluginActivator {
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/assoc/{assoc_type_uri}/{topic1_id}/{topic2_id}/{role_type1_uri}/{role_type2_uri}")
public Assoc getAssocBetweenTopicAndTopic(@PathParam("assoc_type_uri") String assocTypeUri,
@PathParam("topic1_id") long topic1Id, @PathParam("topic2_id") long topic2Id,
@PathParam("role_type1_uri") String roleTypeUri1, @PathParam("role_type2_uri") String roleTypeUri2) {
@Path("/assoc/{assocTypeUri}/{topic1Id}/{topic2Id}/{roleType1Uri}/{roleType2Uri}")
public Assoc getAssocBetweenTopicAndTopic(@PathParam("assocTypeUri") String assocTypeUri,
@PathParam("topic1Id") long topic1Id, @PathParam("topic2Id") long topic2Id,
@PathParam("roleType1Uri") String roleTypeUri1, @PathParam("roleType2Uri") String roleTypeUri2) {
return dmx.getAssocBetweenTopicAndTopic(assocTypeUri, topic1Id, topic2Id, roleTypeUri1, roleTypeUri2);
}
......@@ -178,16 +178,16 @@ public class WebservicePlugin extends PluginActivator {
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/assocs/{topic1_id}/{topic2_id}")
public List<Assoc> getAssocs(@PathParam("topic1_id") long topic1Id, @PathParam("topic2_id") long topic2Id) {
@Path("/assocs/{topic1Id}/{topic2Id}")
public List<Assoc> getAssocs(@PathParam("topic1Id") long topic1Id, @PathParam("topic2Id") long topic2Id) {
return dmx.getAssocs(topic1Id, topic2Id);
}
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/assocs/{assoc_type_uri}/{topic1_id}/{topic2_id}")
public List<Assoc> getAssocs(@PathParam("topic1_id") long topic1Id, @PathParam("topic2_id") long topic2Id,
@PathParam("assoc_type_uri") String assocTypeUri) {
@Path("/assocs/{assocTypeUri}/{topic1Id}/{topic2Id}")
public List<Assoc> getAssocs(@PathParam("topic1Id") long topic1Id, @PathParam("topic2Id") long topic2Id,
@PathParam("assocTypeUri") String assocTypeUri) {
return dmx.getAssocs(topic1Id, topic2Id, assocTypeUri);
}
......@@ -224,7 +224,7 @@ public class WebservicePlugin extends PluginActivator {
// === Topic Types ===
// ### TODO: change URI templates to "/topic_type" / "/assoc_type"
// ### TODO: change URI templates to "/topic-types" / "/assoc-types"
@GET
@Path("/topictype/{uri}")
......@@ -350,11 +350,11 @@ public class WebservicePlugin extends PluginActivator {
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/topic/{id}/related-topics")
public List<RelatedTopic> getTopicRelatedTopics(@PathParam("id") long topicId,
@QueryParam("assoc_type_uri") String assocTypeUri,
@QueryParam("my_role_type_uri") String myRoleTypeUri,
@QueryParam("others_role_type_uri") String othersRoleTypeUri,
@QueryParam("others_topic_type_uri") String othersTopicTypeUri) {
public List<RelatedTopic> getTopicRelatedTopics(@PathParam("id") long topicId,
@QueryParam("assocTypeUri") String assocTypeUri,
@QueryParam("myRoleTypeUri") String myRoleTypeUri,
@QueryParam("othersRoleTypeUri") String othersRoleTypeUri,
@QueryParam("othersTopicTypeUri") String othersTopicTypeUri) {
Topic topic = dmx.getTopic(topicId);
return getRelatedTopics(topic, "topic", assocTypeUri, myRoleTypeUri, othersRoleTypeUri, othersTopicTypeUri);
}
......@@ -362,11 +362,11 @@ public class WebservicePlugin extends PluginActivator {
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/topic/{id}/related-assocs")
public List<RelatedAssoc> getTopicRelatedAssocs(@PathParam("id") long topicId,
@QueryParam("assoc_type_uri") String assocTypeUri,
@QueryParam("my_role_type_uri") String myRoleTypeUri,
@QueryParam("others_role_type_uri") String othersRoleTypeUri,
@QueryParam("others_assoc_type_uri") String othersAssocTypeUri) {
public List<RelatedAssoc> getTopicRelatedAssocs(@PathParam("id") long topicId,
@QueryParam("assocTypeUri") String assocTypeUri,
@QueryParam("myRoleTypeUri") String myRoleTypeUri,
@QueryParam("othersRoleTypeUri") String othersRoleTypeUri,
@QueryParam("othersAssocTypeUri") String othersAssocTypeUri) {
Topic topic = dmx.getTopic(topicId);
return getRelatedAssocs(topic, "topic", assocTypeUri, myRoleTypeUri, othersRoleTypeUri, othersAssocTypeUri);
}
......@@ -382,11 +382,11 @@ public class WebservicePlugin extends PluginActivator {
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/assoc/{id}/related-topics")
public List<RelatedTopic> getAssocRelatedTopics(@PathParam("id") long assocId,
@QueryParam("assoc_type_uri") String assocTypeUri,
@QueryParam("my_role_type_uri") String myRoleTypeUri,
@QueryParam("others_role_type_uri") String othersRoleTypeUri,
@QueryParam("others_topic_type_uri") String othersTopicTypeUri) {
public List<RelatedTopic> getAssocRelatedTopics(@PathParam("id") long assocId,
@QueryParam("assocTypeUri") String assocTypeUri,
@QueryParam("myRoleTypeUri") String myRoleTypeUri,
@QueryParam("othersRoleTypeUri") String othersRoleTypeUri,
@QueryParam("othersTopicTypeUri") String othersTopicTypeUri) {
Assoc assoc = dmx.getAssoc(assocId);
return getRelatedTopics(assoc, "association", assocTypeUri, myRoleTypeUri, othersRoleTypeUri,
othersTopicTypeUri);
......@@ -395,11 +395,11 @@ public class WebservicePlugin extends PluginActivator {
// Note: the "children" query parameter is handled by the core's JerseyResponseFilter
@GET
@Path("/assoc/{id}/related-assocs")
public List<RelatedAssoc> getAssocRelatedAssocs(@PathParam("id") long assocId,
@QueryParam("assoc_type_uri") String assocTypeUri,
@QueryParam("my_role_type_uri") String myRoleTypeUri,
@QueryParam("others_role_type_uri") String othersRoleTypeUri,
@QueryParam("others_assoc_type_uri") String othersAssocTypeUri) {
public List<RelatedAssoc> getAssocRelatedAssocs(@PathParam("id") long assocId,
@QueryParam("assocTypeUri") String assocTypeUri,
@QueryParam("myRoleTypeUri") String myRoleTypeUri,
@QueryParam("othersRoleTypeUri") String othersRoleTypeUri,
@QueryParam("othersAssocTypeUri") String othersAssocTypeUri) {
Assoc assoc = dmx.getAssoc(assocId);
return getRelatedAssocs(assoc, "association", assocTypeUri, myRoleTypeUri, othersRoleTypeUri,
othersAssocTypeUri);
......
......@@ -100,7 +100,7 @@ public class WorkspacesPlugin extends PluginActivator implements WorkspacesServi
@Transactional
@Override
public Topic createWorkspace(@QueryParam("name") final String name, @QueryParam("uri") final String uri,
@QueryParam("sharing_mode_uri") final SharingMode sharingMode) {
@QueryParam("sharingModeUri") final SharingMode sharingMode) {
final String operation = "Creating workspace \"" + name + "\" ";
final String info = "(uri=" + uri + ", sharingMode=" + sharingMode + ")";
try {
......@@ -232,10 +232,10 @@ public class WorkspacesPlugin extends PluginActivator implements WorkspacesServi
// Note: the "children" query parameter is handled by core's JerseyResponseFilter
@GET
@Path("/{id}/topics/{topic_type_uri}")
@Path("/{id}/topics/{topicTypeUri}")
@Override
public List<Topic> getAssignedTopics(@PathParam("id") long workspaceId,
@PathParam("topic_type_uri") String topicTypeUri) {
@PathParam("topicTypeUri") String topicTypeUri) {
// TODO: optimization. Use getRelatedTopics() by using "Workspace Assignment" type.
List<Topic> topics = dmx.getTopicsByType(topicTypeUri);
applyWorkspaceFilter(topics.iterator(), workspaceId);
......@@ -244,10 +244,10 @@ public class WorkspacesPlugin extends PluginActivator implements WorkspacesServi
// Note: the "children" query parameter is handled by core's JerseyResponseFilter
@GET
@Path("/{id}/assocs/{assoc_type_uri}")
@Path("/{id}/assocs/{assocTypeUri}")
@Override
public List<Assoc> getAssignedAssocs(@PathParam("id") long workspaceId,
@PathParam("assoc_type_uri") String assocTypeUri) {
@PathParam("assocTypeUri") String assocTypeUri) {
List<Assoc> assocs = dmx.getAssocsByType(assocTypeUri);
applyWorkspaceFilter(assocs.iterator(), workspaceId);
return assocs;
......
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