try {
long now = System.currentTimeMillis();
Resource r = discoveryBoss.manuallyAddResource(caller, resType.getId(), request.getParentId(), defaultPc);
if (now > r.getCtime()) {
builder = Response.serverError();
builder.entity(new StringValue("Duplicate resource: manuallyAdded resource under same parent having same properties already exists on server. Note that 'resourceName' is ignored."));
return builder.build();
}
if (request.getResourceName()!=null) {
// resourceName is optional, but if specified, let's update it
r.setName(request.getResourceName());
r = resMgr.updateResource(caller, r);
}
ResourceWithType rwt = fillRWT(r, uriInfo);
UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("/resource/{id}");
URI uri = uriBuilder.build(r.getId());
builder = Response.created(uri);
builder.entity(rwt);
return builder.build();
} catch (InvalidPluginConfigurationClientException e) {
builder = Response.serverError();
builder.entity(new StringValue(e.getMessage()));
e.printStackTrace();
} catch (PluginContainerException e) {
builder = Response.serverError();
builder.entity(new StringValue(e.getMessage()));
e.printStackTrace();
} catch (Exception e) {
builder = Response.serverError();
builder.entity(new StringValue(e.getMessage()));
e.printStackTrace();
}
return builder.build();
}