本文整理了Java中org.xowl.infra.server.xsp.XSPReplyResult
类的一些代码示例,展示了XSPReplyResult
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSPReplyResult
类的具体详情如下:
包路径:org.xowl.infra.server.xsp.XSPReplyResult
类名称:XSPReplyResult
暂无
代码示例来源:origin: org.xowl.platform/xowl-service-domain
if (!reply.isSuccess())
return reply;
service = ((XSPReplyResult<DomainConnectorService>) reply).getData();
break;
registration.refAsServedService = context.registerService(HttpAPIService.class, service, null);
connectorsById.put(identifier, registration);
return new XSPReplyResult<>(registration.service);
代码示例来源:origin: org.xowl.platform/xowl-service-security-internal
/**
* Retrieves a stored procedure
*
* @param name The name of the procedure
*/
private void getProcedure(String name) {
XOWLStoredProcedure procedure = ((XSPReplyResult<XOWLStoredProcedure>) database.getStoreProcedure(name)).getData();
procedures.put(name, procedure);
}
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
/**
* Chooses the platform that will implementation the collaboration
*
* @param specification The specification for the collaboration
* @return The protocol reply
*/
private XSPReply provisionChooseProductFor(CollaborationSpecification specification) {
if (platforms.isEmpty())
return XSPReplyNotFound.instance();
return new XSPReplyResult<>(platforms.iterator().next());
}
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
@Override
public Collection<Artifact> getOutputsFor(String specificationId) {
ArtifactStorageService storageService = Register.getComponent(ArtifactStorageService.class);
if (storageService == null)
return Collections.emptyList();
Collection<Artifact> artifacts = new ArrayList<>();
for (String artifactId : manifest.getArtifactsForOutput(specificationId)) {
XSPReply reply = storageService.retrieve(artifactId);
if (reply.isSuccess())
artifacts.add(((XSPReplyResult<Artifact>) reply).getData());
}
return artifacts;
}
代码示例来源:origin: org.xowl.platform/xowl-service-connection
/**
* Realizes the action to pull an artifact
*
* @return The operation's result
*/
protected XSPReply doPullArtifact() {
Artifact artifact = input.poll();
if (artifact == null)
return new XSPReplyApiError(ConnectionService.ERROR_EMPTY_QUEUE);
return new XSPReplyResult<>(artifact);
}
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
@Override
public Collection<Artifact> getInputsFor(String specificationId) {
ArtifactStorageService storageService = Register.getComponent(ArtifactStorageService.class);
if (storageService == null)
return Collections.emptyList();
Collection<Artifact> artifacts = new ArrayList<>();
for (String artifactId : manifest.getArtifactsForInput(specificationId)) {
XSPReply reply = storageService.retrieve(artifactId);
if (reply.isSuccess())
artifacts.add(((XSPReplyResult<Artifact>) reply).getData());
}
return artifacts;
}
代码示例来源:origin: org.xowl.platform/xowl-kernel-impl
@Override
public XSPReply authenticate(String client, String token) {
if (isBanned(client))
return XSPReplyUnauthenticated.instance();
XSPReply reply = checkToken(token);
if (reply == XSPReplyUnauthenticated.instance()) {
// the token is invalid
onLoginFailure(client);
Logging.get().info("Authentication failure from " + client + " with invalid token");
return reply;
}
if (!reply.isSuccess()) {
Logging.get().info("Authentication failure from " + client + " with invalid token");
return reply;
}
PlatformUser user = getRealm().getUser(((XSPReplyResult<String>) reply).getData());
CONTEXT.set(user);
return new XSPReplyResult<>(user);
}
代码示例来源:origin: org.xowl.platform/xowl-service-domain
@Override
public XSPReply getNextInput(boolean block) {
Artifact artifact = null;
if (block) {
try {
artifact = input.take();
} catch (InterruptedException exception) {
// do nothing
}
} else {
artifact = input.poll();
}
if (artifact == null)
return new XSPReplyFailure("No queued artifact");
return new XSPReplyResult<>(artifact);
}
代码示例来源:origin: org.xowl.platform/xowl-service-security-internal
@Override
public boolean checkHasRole(String userId, String roleId) {
Map<String, Node> parameters = new HashMap<>();
parameters.put("user", nodes.getIRINode(USERS + userId));
parameters.put("role", nodes.getIRINode(ROLES + roleId));
XSPReply reply = database.executeStoredProcedure(procedures.get("procedure-check-role"),
new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
if (!reply.isSuccess())
return false;
Result result = ((XSPReplyResult<Result>) reply).getData();
return reply.isSuccess() && ((ResultYesNo) result).getValue();
}
代码示例来源:origin: org.xowl.platform/xowl-service-collaboration
@Override
public XSPReply createRole(String identifier, String name) {
SecurityService securityService = Register.getComponent(SecurityService.class);
if (securityService == null)
return XSPReplyServiceUnavailable.instance();
XSPReply reply = securityService.checkAction(ACTION_ADD_ROLE);
if (!reply.isSuccess())
return reply;
reply = securityService.getRealm().createRole(identifier, name);
if (!reply.isSuccess())
return reply;
PlatformRole role = ((XSPReplyResult<PlatformRole>) reply).getData();
manifest.addRole(role);
reply = serializeManifest();
if (!reply.isSuccess())
return reply;
return new XSPReplyResult<>(role);
}
代码示例来源:origin: org.xowl.platform/xowl-connector-semanticweb
@Override
public XSPReply doGetImportJob(String documentId, ImporterConfiguration configuration, Artifact metadata) {
return new XSPReplyResult<>(new SemanticWebImportJob(documentId, (SemanticWebImporterConfiguration) configuration, metadata));
}
代码示例来源:origin: org.xowl.platform/xowl-service-security-internal
@Override
public Collection<PlatformGroup> getGroups() {
Map<String, Node> parameters = new HashMap<>();
XSPReply reply = database.executeStoredProcedure(procedures.get("procedure-get-groups"),
new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
if (!reply.isSuccess())
return Collections.emptyList();
ResultSolutions result = ((XSPReplyResult<ResultSolutions>) reply).getData();
Collection<PlatformGroup> groups = new ArrayList<>(result.getSolutions().size());
for (RDFPatternSolution solution : result.getSolutions()) {
String id = ((IRINode) solution.get("group")).getIRIValue().substring(GROUPS.length());
String name = ((LiteralNode) solution.get("name")).getLexicalValue();
groups.add(getGroup(id, name));
}
return groups;
}
代码示例来源:origin: org.xowl.platform/xowl-service-connection
/**
* Pulls an artifact from the connector into the standard storage (usually the long-term store)
*
* @param connector The connector to pull from
* @return The result of the operation
*/
public static XSPReply pullArtifactFrom(ConnectorService connector) {
ArtifactStorageService storageService = Register.getComponent(ArtifactStorageService.class);
if (storageService == null)
return XSPReplyServiceUnavailable.instance();
XSPReply replyArtifact = connector.pullArtifact();
if (!replyArtifact.isSuccess())
return replyArtifact;
Artifact artifact = ((XSPReplyResult<Artifact>) replyArtifact).getData();
XSPReply reply = storageService.store(artifact);
if (!reply.isSuccess())
return reply;
EventService eventService = Register.getComponent(EventService.class);
if (eventService != null)
eventService.onEvent(new ArtifactPulledFromConnectorEvent(connector, artifact));
// reply with the artifact
return new XSPReplyResult<>(artifact.getIdentifier());
}
代码示例来源:origin: org.xowl.platform/xowl-service-domain
@Override
public XSPReply newConnector(DomainDescription description, String identifier, String name, String[] uris, Map<DomainDescriptionParam, Object> parameters) {
return new XSPReplyResult<>(new ParametricDomainConnector(identifier, name, uris));
}
}
代码示例来源:origin: org.xowl.platform/xowl-service-security-internal
@Override
public Collection<PlatformRole> getRoles() {
Map<String, Node> parameters = new HashMap<>();
XSPReply reply = database.executeStoredProcedure(procedures.get("procedure-get-roles"),
new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
if (!reply.isSuccess())
return Collections.emptyList();
ResultSolutions result = ((XSPReplyResult<ResultSolutions>) reply).getData();
Collection<PlatformRole> roles = new ArrayList<>(result.getSolutions().size());
for (RDFPatternSolution solution : result.getSolutions()) {
String id = ((IRINode) solution.get("role")).getIRIValue().substring(ROLES.length());
String name = ((LiteralNode) solution.get("name")).getLexicalValue();
roles.add(getRole(id, name));
}
return roles;
}
代码示例来源:origin: org.xowl.platform/xowl-service-consistency
if (!reply.isSuccess())
return reply;
XOWLRule original = ((XSPReplyResult<XOWLRule>) reply).getData();
reply = live.sparql("INSERT DATA { GRAPH <" + TextUtils.escapeAbsoluteURIW3C(IRI_RULE_METADATA) + "> {" +
"<" + TextUtils.escapeAbsoluteURIW3C(id) + "> <" + TextUtils.escapeAbsoluteURIW3C(Vocabulary.rdfType) + "> <" + TextUtils.escapeAbsoluteURIW3C(IRI_RULE) + "> ." +
if (!reply.isSuccess())
return reply;
Result sparqlResult = ((XSPReplyResult<Result>) reply).getData();
if (sparqlResult.isFailure())
return new XSPReplyApiError(ArtifactStorageService.ERROR_STORAGE_FAILED, ((ResultFailure) sparqlResult).getMessage());
if (eventService != null)
eventService.onEvent(new ConsistencyRuleCreatedEvent(rule, this));
return new XSPReplyResult<>(rule);
代码示例来源:origin: org.xowl.platform/xowl-service-lts
@Override
public XSPReply retrieve(String base, String version) {
StringWriter writer = new StringWriter();
writer.write("DESCRIBE ?a WHERE { GRAPH <");
writer.write(IOUtils.escapeAbsoluteURIW3C(KernelSchema.GRAPH_ARTIFACTS));
writer.write("> { ?a a <");
writer.write(IOUtils.escapeAbsoluteURIW3C(KernelSchema.ARTIFACT));
writer.write(">. ?a <");
writer.write(IOUtils.escapeAbsoluteURIW3C(KernelSchema.BASE));
writer.write("> <");
writer.write(IOUtils.escapeAbsoluteURIW3C(base));
writer.write(">. ?a <");
writer.write(IOUtils.escapeAbsoluteURIW3C(KernelSchema.VERSION));
writer.write("> \"");
writer.write(IOUtils.escapeStringW3C(version));
writer.write("\" } }");
Result result = storeLongTerm.sparql(writer.toString());
if (result.isFailure())
return new XSPReplyFailure(((ResultFailure) result).getMessage());
Collection<Quad> metadata = ((ResultQuads) result).getQuads();
if (metadata.isEmpty())
return XSPReplyNotFound.instance();
return new XSPReplyResult<>(storeLongTerm.buildArtifact(metadata));
}
代码示例来源:origin: org.xowl.platform/xowl-service-security-internal
@Override
public Collection<PlatformUser> getUsers() {
Map<String, Node> parameters = new HashMap<>();
XSPReply reply = database.executeStoredProcedure(procedures.get("procedure-get-users"),
new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
if (!reply.isSuccess())
return Collections.emptyList();
ResultSolutions result = ((XSPReplyResult<ResultSolutions>) reply).getData();
Collection<PlatformUser> users = new ArrayList<>(result.getSolutions().size());
for (RDFPatternSolution solution : result.getSolutions()) {
String id = ((IRINode) solution.get("user")).getIRIValue().substring(USERS.length());
String name = ((LiteralNode) solution.get("name")).getLexicalValue();
users.add(getUser(id, name));
}
return users;
}
代码示例来源:origin: org.xowl.platform/xowl-connector-semanticweb
if (!reply.isSuccess())
return reply;
try (InputStream stream = ((XSPReplyResult<InputStream>) reply).getData()) {
InputStreamReader reader = new InputStreamReader(stream, IOUtils.CHARSET);
SemanticWebLoader loader = new SemanticWebLoader();
return new XSPReplyResult<>(preview);
} catch (IOException exception) {
Logging.get().error(exception);
代码示例来源:origin: org.xowl.platform/xowl-kernel-impl
return new XSPReplyResult<>(new String(tokenBytes, 0, tokenBytes.length - 32 - 8, IOUtils.CHARSET));
内容来源于网络,如有侵权,请联系作者删除!