Skip to content

Commit

Permalink
#188 ensure backwards compatilbity of RestApiCidsServerAction, unwrap…
Browse files Browse the repository at this point in the history
… GenericResourceWithContentType
  • Loading branch information
p-a-s-c-a-l committed Jan 19, 2017
1 parent 5a9ae9b commit fa703e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import de.cismet.cids.server.search.CidsServerSearch;
import de.cismet.cids.server.ws.SSLConfig;

import de.cismet.cidsx.server.api.types.GenericResourceWithContentType;
import de.cismet.cidsx.server.search.builtin.legacy.LightweightMetaObjectsByQuerySearch;

import de.cismet.netutil.Proxy;
Expand Down Expand Up @@ -2277,7 +2278,20 @@ public Object executeTask(final User user,
}

try {
return getResponsePOST("executeTask", queryParams, Object.class); // NOI18N
final Object response = getResponsePOST("executeTask", queryParams, Object.class); // NOI18N

// ensure backwards compatilbity of RestApiCidsServerAction, unwrap GenericResourceWithContentType
if ((response != null) && GenericResourceWithContentType.class.isAssignableFrom(response.getClass())) {
final GenericResourceWithContentType reponseWithContentType = (GenericResourceWithContentType)
response;
if (LOG.isDebugEnabled()) {
LOG.debug("unwrapping response of type '" + reponseWithContentType.getContentType()
+ "' of action '" + taskname + "'");
}
return reponseWithContentType.getRes();
}

return response;
} catch (final UniformInterfaceException ex) {
if (LOG.isDebugEnabled()) {
LOG.debug("exception during request, remapping", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,7 @@ public Object executeTask(final User user,
+ webResource.toString());
}

// FIXME: Fails if the action does nor return APPLICATION_JSON
builder.type(MediaType.MULTIPART_FORM_DATA_TYPE).accept(MediaType.APPLICATION_JSON_TYPE);

FormDataMultiPart multiPartData = new FormDataMultiPart();
Expand Down Expand Up @@ -2423,6 +2424,7 @@ public Object executeTask(final User user,
+ taskResult.getContentType() + "'");
}

// TODO: unwrap / deserialize result depending on conent type!
return taskResult.getRes();
}

Expand Down

0 comments on commit fa703e4

Please sign in to comment.