本文整理了Java中org.xowl.infra.server.xsp.XSPReplyUtils
类的一些代码示例,展示了XSPReplyUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSPReplyUtils
类的具体详情如下:
包路径:org.xowl.infra.server.xsp.XSPReplyUtils
类名称:XSPReplyUtils
暂无
代码示例来源:origin: org.xowl.platform/xowl-service-connection
/**
* Responds to the request to delete a previously spawned parametric connector
*
* @param connectorId The identifier of the connector to delete
* @return The response
*/
private HttpResponse onMessageDeleteConnector(String connectorId) {
XSPReply reply = delete(connectorId);
return XSPReplyUtils.toHttpResponse(reply, null);
}
代码示例来源:origin: org.xowl.platform/xowl-satellite-base
/**
* Updates the content of this job
*
* @param definition The JSON definition
* @param factory The factory for the result
*/
void update(ASTNode definition, XOWLFactory factory) {
for (ASTNode member : definition.getChildren()) {
String head = IOUtils.unescape(member.getChildren().get(0).getValue());
head = head.substring(1, head.length() - 1);
if ("status".equals(head)) {
String value = IOUtils.unescape(member.getChildren().get(1).getValue());
this.status = value.substring(1, value.length() - 1);
} else if ("timeScheduled".equals(head)) {
String value = IOUtils.unescape(member.getChildren().get(1).getValue());
this.timeScheduled = value.substring(1, value.length() - 1);
} else if ("timeRun".equals(head)) {
String value = IOUtils.unescape(member.getChildren().get(1).getValue());
this.timeRun = value.substring(1, value.length() - 1);
} else if ("timeCompleted".equals(head)) {
String value = IOUtils.unescape(member.getChildren().get(1).getValue());
this.timeCompleted = value.substring(1, value.length() - 1);
} else if ("result".equals(head)) {
ASTNode value = member.getChildren().get(1);
if (!value.getChildren().isEmpty())
result = XSPReplyUtils.parseJSONResult(value, factory);
}
}
}
}
代码示例来源:origin: org.xowl.platform/xowl-service-connection
@Override
public HttpResponse handle(SecurityService securedService, HttpApiRequest request) {
return XSPReplyUtils.toHttpResponse(XSPReplyUnsupported.instance(), null);
}
代码示例来源:origin: org.xowl.platform/xowl-satellite-base
ASTNode value = member.getChildren().get(1);
if (!value.getChildren().isEmpty())
result = XSPReplyUtils.parseJSONResult(value, factory);
代码示例来源:origin: org.xowl.platform/xowl-service-domain
/**
* Responds to the request to delete a previously spawned parametric connector
*
* @param parameters The request parameters
* @return The response
*/
private HttpResponse onMessageDeleteConnector(Map<String, String[]> parameters) {
String[] ids = parameters.get("id");
if (ids == null || ids.length == 0)
return new HttpResponse(HttpURLConnection.HTTP_BAD_REQUEST, HttpConstants.MIME_TEXT_PLAIN, "Expected an id parameter");
XSPReply reply = delete(ids[0]);
return XSPReplyUtils.toHttpResponse(reply, null);
}
代码示例来源:origin: org.xowl.platform/xowl-kernel-impl
/**
* Responds to a request for the list of available metrics
*
* @param securityService The current security service
* @return The metrics
*/
private HttpResponse onMessageGetMetricList(SecurityService securityService) {
XSPReply reply = securityService.checkAction(ACTION_GET_METRICS);
if (!reply.isSuccess())
return XSPReplyUtils.toHttpResponse(reply, null);
// get all the metrics
boolean first = true;
StringBuilder builder = new StringBuilder("[");
for (Metric metric : getMetrics()) {
if (!first)
builder.append(", ");
first = false;
builder.append(metric.serializedJSON());
}
builder.append("]");
return new HttpResponse(HttpURLConnection.HTTP_OK, HttpConstants.MIME_JSON, builder.toString());
}
代码示例来源:origin: org.xowl.platform/xowl-service-impact
@Override
public HttpResponse handle(SecurityService securityService, HttpApiRequest request) {
if (!HttpConstants.METHOD_POST.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected POST method");
byte[] content = request.getContent();
if (content == null || content.length == 0)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_FAILED_TO_READ_CONTENT), null);
BufferedLogger logger = new BufferedLogger();
ASTNode root = JSONLDLoader.parseJSON(logger, new String(content, IOUtils.CHARSET));
if (root == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_CONTENT_PARSING_FAILED, logger.getErrorsAsString()), null);
return XSPReplyUtils.toHttpResponse(perform(new XOWLImpactAnalysisSetup(root)), null);
}
代码示例来源:origin: org.xowl.platform/xowl-kernel-impl
@Override
public HttpResponse handle(SecurityService securityService, HttpApiRequest request) {
XSPReply reply = securityService.checkAction(ACTION_GET_LOG);
if (!reply.isSuccess())
return XSPReplyUtils.toHttpResponse(reply, null);
if (!HttpConstants.METHOD_GET.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected GET method");
StringBuilder builder = new StringBuilder("[");
boolean first = true;
for (PlatformLogMessage message : buffer.getMessages()) {
if (!first)
builder.append(", ");
first = false;
builder.append(message.serializedJSON());
}
builder.append("]");
return new HttpResponse(HttpURLConnection.HTTP_OK, HttpConstants.MIME_JSON, builder.toString());
}
代码示例来源:origin: org.xowl.platform/xowl-service-lts
return XSPReplyUtils.toHttpResponse(retrieve(id), null);
if (quads[0].equals("metadata"))
return onMessageGetArtifactMetadata(id);
String[] archetypes = parameters.get("archetype");
if (lives != null && lives.length > 0)
return XSPReplyUtils.toHttpResponse(getLiveArtifacts(), null);
else if (bases != null && bases.length > 0)
return XSPReplyUtils.toHttpResponse(getArtifactsForBase(bases[0]), null);
else if (archetypes != null && archetypes.length > 0)
return XSPReplyUtils.toHttpResponse(getArtifactsForArchetype(archetypes[0]), null);
else
return XSPReplyUtils.toHttpResponse(getAllArtifacts(), null);
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
return XSPReplyUtils.toHttpResponse(registerOutput(specId, artifactId), null);
case HttpConstants.METHOD_DELETE:
return XSPReplyUtils.toHttpResponse(unregisterOutput(specId, artifactId), null);
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
return XSPReplyUtils.toHttpResponse(registerInput(specId, artifactId), null);
case HttpConstants.METHOD_DELETE:
return XSPReplyUtils.toHttpResponse(unregisterInput(specId, artifactId), null);
代码示例来源:origin: org.xowl.platform/xowl-connector-semanticweb
String contentType = request.getContentType();
if (name == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_EXPECTED_QUERY_PARAMETERS, "'name'"), null);
if (base == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_EXPECTED_QUERY_PARAMETERS, "'base'"), null);
if (version == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_EXPECTED_QUERY_PARAMETERS, "'version'"), null);
if (archetype == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_EXPECTED_QUERY_PARAMETERS, "'archetype'"), null);
if (contentType == null || contentType.isEmpty())
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_EXPECTED_HEADER_CONTENT_TYPE), null);
int index = contentType.indexOf(";");
if (index != -1)
XSPReply reply = loader.load(new InputStreamReader(new ByteArrayInputStream(request.getContent())), resource, contentType);
if (!reply.isSuccess())
return XSPReplyUtils.toHttpResponse(reply, null);
代码示例来源:origin: org.xowl.platform/xowl-kernel-impl
/**
* Responds to a request for the policy resource
*
* @param request The web API request to handle
* @return The HTTP response
*/
private HttpResponse handleRequestPolicy(HttpApiRequest request) {
if (request.getUri().equals(apiUri + "/policy")) {
if (!HttpConstants.METHOD_GET.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected GET method");
return XSPReplyUtils.toHttpResponse(getPolicy().getConfiguration(), null);
}
if (request.getUri().startsWith(apiUri + "/policy/actions/")) {
String rest = request.getUri().substring(apiUri.length() + "/policy/actions/".length());
String actionId = URIUtils.decodeComponent(rest);
if (actionId.isEmpty())
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
if (!HttpConstants.METHOD_PUT.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected PUT method");
String definition = new String(request.getContent(), IOUtils.CHARSET);
return XSPReplyUtils.toHttpResponse(getPolicy().setPolicy(actionId, definition), null);
}
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
}
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
return XSPReplyUtils.toHttpResponse(delete(neighbourId), null);
if (!HttpConstants.METHOD_GET.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected GET method");
return XSPReplyUtils.toHttpResponse(getNeighbourManifest(neighbourId), null);
if (!HttpConstants.METHOD_POST.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected POST method");
return XSPReplyUtils.toHttpResponse(archive(neighbourId), null);
return XSPReplyUtils.toHttpResponse(restart(neighbourId), null);
rest = rest.substring("manifest/inputs/".length(), rest.length() - "/artifacts".length());
String specId = URIUtils.decodeComponent(rest);
return XSPReplyUtils.toHttpResponse(getNeighbourInputsFor(neighbourId, specId), null);
return XSPReplyUtils.toHttpResponse(getNeighbourOutputsFor(neighbourId, specId), null);
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
String content = new String(request.getContent(), IOUtils.CHARSET);
if (content.isEmpty())
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_FAILED_TO_READ_CONTENT), null);
BufferedLogger logger = new BufferedLogger();
ASTNode root = JSONLDLoader.parseJSON(logger, content);
if (root == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_CONTENT_PARSING_FAILED, logger.getErrorsAsString()), null);
CollaborationSpecification specification = new CollaborationSpecification(root);
JobExecutionService executionService = Register.getComponent(JobExecutionService.class);
if (executionService == null)
return XSPReplyUtils.toHttpResponse(XSPReplyServiceUnavailable.instance(), null);
return XSPReplyUtils.toHttpResponse(executionService.schedule(new CollaborationSpawnJob(specification)), null);
代码示例来源:origin: org.xowl.platform/xowl-service-connection
String descriptorId = request.getParameter("descriptor");
if (descriptorId == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_EXPECTED_QUERY_PARAMETERS, "'descriptor'"), null);
String content = new String(request.getContent(), IOUtils.CHARSET);
if (content.isEmpty())
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_FAILED_TO_READ_CONTENT), null);
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_CONTENT_PARSING_FAILED, logger.getErrorsAsString()), null);
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_PARAMETER_RANGE, "'descriptor' is not the identifier of a recognized connector descriptor"), null);
ConnectorServiceData specification = new ConnectorServiceData(descriptor, root);
if (!specification.getIdentifier().equals(connectorId))
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_PARAMETER_RANGE, "'identifier' is not the same as URI parameter"), null);
XSPReply reply = spawn(descriptor, specification);
if (!reply.isSuccess())
return XSPReplyUtils.toHttpResponse(reply, null);
return new HttpResponse(HttpURLConnection.HTTP_OK, HttpConstants.MIME_JSON, ((XSPReplyResult<ConnectorService>) reply).getData().serializedJSON());
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
String content = new String(request.getContent(), IOUtils.CHARSET);
if (content.isEmpty())
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_FAILED_TO_READ_CONTENT), null);
BufferedLogger logger = new BufferedLogger();
ASTNode root = JSONLDLoader.parseJSON(logger, content);
if (root == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_CONTENT_PARSING_FAILED, logger.getErrorsAsString()), null);
ArtifactSpecification specification = new ArtifactSpecification(root);
return XSPReplyUtils.toHttpResponse(addInputSpecification(specification), null);
if (!HttpConstants.METHOD_DELETE.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected DELETE method");
return XSPReplyUtils.toHttpResponse(removeInputSpecification(specId), null);
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
String content = new String(request.getContent(), IOUtils.CHARSET);
if (content.isEmpty())
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_FAILED_TO_READ_CONTENT), null);
BufferedLogger logger = new BufferedLogger();
ASTNode root = JSONLDLoader.parseJSON(logger, content);
if (root == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_CONTENT_PARSING_FAILED, logger.getErrorsAsString()), null);
ArtifactSpecification specification = new ArtifactSpecification(root);
return XSPReplyUtils.toHttpResponse(addOutputSpecification(specification), null);
if (!HttpConstants.METHOD_DELETE.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected DELETE method");
return XSPReplyUtils.toHttpResponse(removeOutputSpecification(specId), null);
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
String content = new String(request.getContent(), IOUtils.CHARSET);
if (content.isEmpty())
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_FAILED_TO_READ_CONTENT), null);
BufferedLogger logger = new BufferedLogger();
ASTNode root = JSONLDLoader.parseJSON(logger, content);
if (root == null)
return XSPReplyUtils.toHttpResponse(new XSPReplyApiError(ERROR_CONTENT_PARSING_FAILED, logger.getErrorsAsString()), null);
PlatformRoleBase role = new PlatformRoleBase(root);
return XSPReplyUtils.toHttpResponse(createRole(role.getIdentifier(), role.getName()), null);
switch (request.getMethod()) {
case HttpConstants.METHOD_DELETE:
return XSPReplyUtils.toHttpResponse(removeRole(roleId), null);
case HttpConstants.METHOD_PUT:
return XSPReplyUtils.toHttpResponse(addRole(roleId), null);
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
if (!HttpConstants.METHOD_POST.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected POST method");
return XSPReplyUtils.toHttpResponse(archive(), null);
} else if (request.getUri().equals(apiUri + "/delete")) {
if (!HttpConstants.METHOD_POST.equals(request.getMethod()))
return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected POST method");
return XSPReplyUtils.toHttpResponse(delete(), null);
} else if (request.getUri().startsWith(apiUri + "/manifest")) {
return handleManifest(request);
内容来源于网络,如有侵权,请联系作者删除!