org.xowl.infra.server.xsp.XSPReplyResult.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(14.4k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中org.xowl.infra.server.xsp.XSPReplyResult.<init>()方法的一些代码示例,展示了XSPReplyResult.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSPReplyResult.<init>()方法的具体详情如下:
包路径:org.xowl.infra.server.xsp.XSPReplyResult
类名称:XSPReplyResult
方法名:<init>

XSPReplyResult.<init>介绍

暂无

代码示例

代码示例来源: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-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-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-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-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-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-lts

@Override
public XSPReply retrieve(String identifier) {
  Result result = sparql("DESCRIBE <" + IOUtils.escapeAbsoluteURIW3C(identifier) + ">");
  if (result.isFailure())
    return new XSPReplyFailure(((ResultFailure) result).getMessage());
  Collection<Quad> metadata = ((ResultQuads) result).getQuads();
  if (metadata.isEmpty())
    return XSPReplyNotFound.instance();
  return new XSPReplyResult<>(buildArtifact(metadata));
}

代码示例来源:origin: org.xowl.platform/xowl-kernel-impl

@Override
public XSPReply getConfiguration() {
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.checkAction(SecurityService.ACTION_GET_POLICY);
  if (!reply.isSuccess())
    return reply;
  KernelSecurityPolicyConfiguration configuration = resolveConfig();
  return new XSPReplyResult<>(configuration.synchronize());
}

代码示例来源:origin: org.xowl.platform/xowl-service-security-internal

@Override
public XSPReply createRole(String identifier, String name) {
  // check authorization
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_CREATE_ROLE);
  if (!reply.isSuccess())
    return reply;
  // check identifier format
  if (!identifier.matches("[_a-zA-Z0-9]+"))
    return new XSPReplyApiError(ERROR_INVALID_IDENTIFIER, "[_a-zA-Z0-9]+");
  // create the group data
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("role", nodes.getIRINode(ROLES + identifier));
  parameters.put("name", nodes.getLiteralNode(name, Vocabulary.xsdString, null));
  reply = database.executeStoredProcedure(procedures.get("procedure-create-role"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  PlatformRoleBase role = getRole(identifier, name);
  EventService eventService = Register.getComponent(EventService.class);
  if (eventService != null)
    eventService.onEvent(new PlatformRoleCreatedEvent(role, securityService));
  return new XSPReplyResult<>(role);
}

代码示例来源:origin: org.xowl.platform/xowl-service-security-internal

@Override
public XSPReply createUser(String identifier, String name, String key) {
  // check authorization
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_CREATE_USER);
  if (!reply.isSuccess())
    return reply;
  // check identifier format
  if (!identifier.matches("[_a-zA-Z0-9]+"))
    return new XSPReplyApiError(ERROR_INVALID_IDENTIFIER, "[_a-zA-Z0-9]+");
  // create the user as an embedded server user
  reply = server.createUser(identifier, key);
  if (!reply.isSuccess())
    return reply;
  // create the user data
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("user", nodes.getIRINode(USERS + identifier));
  parameters.put("name", nodes.getLiteralNode(name, Vocabulary.xsdString, null));
  reply = database.executeStoredProcedure(procedures.get("procedure-create-user"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  XOWLInternalUser user = getUser(identifier, name);
  EventService eventService = Register.getComponent(EventService.class);
  if (eventService != null)
    eventService.onEvent(new PlatformUserCreatedEvent(user, securityService));
  return new XSPReplyResult<>(user);
}

代码示例来源:origin: org.xowl.platform/xowl-service-collaboration

@Override
public XSPReply addInputSpecification(ArtifactSpecification specification) {
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.checkAction(ACTION_ADD_INPUT_SPEC);
  if (!reply.isSuccess())
    return reply;
  manifest.addInputSpecification(specification);
  reply = serializeManifest();
  if (!reply.isSuccess())
    return reply;
  return new XSPReplyResult<>(specification);
}

代码示例来源:origin: org.xowl.platform/xowl-kernel-impl

@Override
public XSPReply login(String client, String login, String password) {
  if (isBanned(client))
    return XSPReplyUnauthenticated.instance();
  if (login == null || login.isEmpty() || password == null || password.length() == 0) {
    onLoginFailure(client);
    Logging.get().info("Authentication failure from " + client + " on initial login with " + login);
    return XSPReplyUnauthenticated.instance();
  }
  PlatformUser user = getRealm().authenticate(login, password);
  if (user != null) {
    CONTEXT.set(user);
    return new XSPReplyResult<>(buildTokenFor(login));
  }
  onLoginFailure(client);
  Logging.get().info("Authentication failure from " + client + " on initial login with " + login);
  return XSPReplyUnauthenticated.instance();
}

代码示例来源:origin: org.xowl.platform/xowl-service-collaboration

@Override
public XSPReply addOutputSpecification(ArtifactSpecification specification) {
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.checkAction(ACTION_ADD_OUTPUT_SPEC);
  if (!reply.isSuccess())
    return reply;
  manifest.addOutputSpecification(specification);
  reply = serializeManifest();
  if (!reply.isSuccess())
    return reply;
  return new XSPReplyResult<>(specification);
}

代码示例来源:origin: org.xowl.platform/xowl-service-impact

@Override
  public XSPReply perform(ImpactAnalysisSetup setup) {
    SecurityService securityService = Register.getComponent(SecurityService.class);
    if (securityService == null)
      return XSPReplyServiceUnavailable.instance();
    XSPReply reply = securityService.checkAction(ImpactAnalysisService.ACTION_PERFORM);
    if (!reply.isSuccess())
      return reply;
    JobExecutionService executionService = Register.getComponent(JobExecutionService.class);
    if (executionService == null)
      return XSPReplyServiceUnavailable.instance();
    XOWLImpactAnalysisJob job = new XOWLImpactAnalysisJob(setup);
    executionService.schedule(job);
    return new XSPReplyResult<>(job);
  }
}

代码示例来源:origin: org.xowl.platform/xowl-service-impact

@Override
public void doRun() {
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null) {
    result = XSPReplyServiceUnavailable.instance();
    return;
  }
  XSPReply reply = securityService.checkAction(ImpactAnalysisService.ACTION_PERFORM);
  if (!reply.isSuccess()) {
    result = reply;
    return;
  }
  StorageService storageService = Register.getComponent(StorageService.class);
  if (storageService == null) {
    result = XSPReplyServiceUnavailable.instance();
    return;
  }
  TripleStore live = storageService.getLiveStore();
  List<XOWLImpactAnalysisResultPart> finalParts = new ArrayList<>();
  result = new XSPReplyResult<>(new XOWLImpactAnalysisResult(finalParts));
  browseGraph(live, finalParts);
}

代码示例来源: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-collaboration

@Override
public XSPReply addRole(String roleId) {
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.checkAction(ACTION_ADD_ROLE);
  if (!reply.isSuccess())
    return reply;
  PlatformRole role = securityService.getRealm().getRole(roleId);
  if (role == null)
    return XSPReplyNotFound.instance();
  manifest.addRole(role);
  reply = serializeManifest();
  if (!reply.isSuccess())
    return reply;
  return new XSPReplyResult<>(role);
}

代码示例来源: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-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-consistency

@Override
public XSPReply addRule(ConsistencyRule rule) {
  StorageService storageService = Register.getComponent(StorageService.class);
  if (storageService == null)
    return XSPReplyServiceUnavailable.instance();
  TripleStore live = storageService.getLiveStore();
  XSPReply reply = live.addRule(rule.getDefinition(), rule.isActive());
  if (!reply.isSuccess())
    return reply;
  reply = live.sparql("INSERT DATA { GRAPH <" + TextUtils.escapeAbsoluteURIW3C(IRI_RULE_METADATA) + "> {" +
      "<" + TextUtils.escapeAbsoluteURIW3C(rule.getIdentifier()) + "> <" + TextUtils.escapeAbsoluteURIW3C(Vocabulary.rdfType) + "> <" + TextUtils.escapeAbsoluteURIW3C(IRI_RULE) + "> ." +
      "<" + TextUtils.escapeAbsoluteURIW3C(rule.getIdentifier()) + "> <" + TextUtils.escapeAbsoluteURIW3C(KernelSchema.NAME) + "> \"" + TextUtils.escapeStringW3C(rule.getName()) + "\" ." +
      "<" + TextUtils.escapeAbsoluteURIW3C(rule.getIdentifier()) + "> <" + TextUtils.escapeAbsoluteURIW3C(IRI_DEFINITION) + "> \"" + TextUtils.escapeStringW3C(rule.getDefinition()) + "\" ." +
      "} }", null, null);
  if (!reply.isSuccess())
    return reply;
  Result sparqlResult = ((XSPReplyResult<Result>) reply).getData();
  if (sparqlResult.isFailure())
    return new XSPReplyApiError(ArtifactStorageService.ERROR_STORAGE_FAILED, ((ResultFailure) sparqlResult).getMessage());
  EventService eventService = Register.getComponent(EventService.class);
  if (eventService != null)
    eventService.onEvent(new ConsistencyRuleCreatedEvent(rule, this));
  return new XSPReplyResult<>(rule);
}

相关文章