gpt4 book ai didi

org.xowl.infra.server.xsp.XSPReplyApiError类的使用及代码示例

转载 作者:知者 更新时间:2024-03-24 04:39:05 29 4
gpt4 key购买 nike

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

XSPReplyApiError介绍

暂无

代码示例

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

@Override
  public XSPReply setPolicy(String actionId, String policyDefinition) {
    ASTNode definition = JSONLDLoader.parseJSON(Logging.get(), policyDefinition);
    if (definition == null)
      return new XSPReplyApiError(HttpApiService.ERROR_CONTENT_PARSING_FAILED);
    SecuredActionPolicy policy = SecuredActionPolicyBase.load(definition);
    if (policy == null)
      return new XSPReplyApiError(HttpApiService.ERROR_CONTENT_PARSING_FAILED, "Invalid policy definition");
    return setPolicy(actionId, policy);
  }
}

代码示例来源:origin: org.xowl.platform/xowl-connector-semanticweb

/**
 * @param reader      The reader to read from
 * @param resourceIRI The IRI for the resource to load
 * @param syntax      The expected syntax
 * @return The reply
 */
public XSPReply load(Reader reader, String resourceIRI, String syntax) {
  BufferedLogger bufferedLogger = new BufferedLogger();
  try {
    Collection<Quad> quads = load(bufferedLogger, reader, resourceIRI, syntax);
    if (quads == null || !bufferedLogger.getErrorMessages().isEmpty())
      return new XSPReplyApiError(HttpApiService.ERROR_CONTENT_PARSING_FAILED, bufferedLogger.getErrorsAsString());
    return new XSPReplyResultCollection<>(quads);
  } catch (TranslationException exception) {
    bufferedLogger.error(exception);
    return new XSPReplyApiError(HttpApiService.ERROR_CONTENT_PARSING_FAILED, bufferedLogger.getErrorsAsString());
  }
}

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

for (Addon addon : addons) {
  if (Objects.equals(addon.getIdentifier(), identifier))
    return new XSPReplyApiError(ERROR_ADDON_ALREADY_INSTALLED);
if (!directory.mkdirs()) {
  Logging.get().error("Failed to create directory " + directory.getAbsolutePath());
  return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "Failed to unpack the addon.");
} catch (IOException exception) {
  Logging.get().error(exception);
  return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "Failed to unpack the addon.");
  return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "No descriptor found.");
  if (definition == null) {
    IOUtils.deleteFolder(directory);
    return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "Failed to read the descriptor.");
  Logging.get().error(exception);
  IOUtils.deleteFolder(directory);
  return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "Failed to read the descriptor.");
  return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "Descriptor does not match the provided identifier.");
  if (!fileBundle.exists()) {
    IOUtils.deleteFolder(directory);
    return new XSPReplyApiError(ERROR_INVALID_ADDON_PACKAGE, "Addon package does not contain bundle " + fileBundle.getName());

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

@Override
public XSPReply unassignRoleToGroup(String group, String role) {
  // check input data
  PlatformGroup groupObj = getGroup(group);
  if (groupObj == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, group);
  PlatformRole roleObj = getRole(role);
  if (roleObj == null)
    return new XSPReplyApiError(ERROR_INVALID_ROLE, role);
  // check for current user with admin role
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_UNASSIGN_ROLE_TO_GROUP);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("entity", nodes.getIRINode(GROUPS + group));
  parameters.put("role", nodes.getIRINode(ROLES + role));
  reply = database.executeStoredProcedure(procedures.get("procedure-unassign-role"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

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

@Override
public XSPReply addAdminToGroup(String user, String group) {
  // check input data
  PlatformGroup groupObject = getGroup(group);
  if (groupObject == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, group);
  PlatformUser newUser = getUser(user);
  if (newUser == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, user);
  // check the current user is either the platform admin or the group admin
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_ADD_ADMIN_TO_GROUP, groupObject);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("group", nodes.getIRINode(GROUPS + group));
  parameters.put("admin", nodes.getIRINode(USERS + user));
  reply = database.executeStoredProcedure(procedures.get("procedure-add-admin"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

@Override
public XSPReply assignRoleToUser(String user, String role) {
  // check input data
  PlatformUser userObj = getUser(user);
  if (userObj == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, user);
  PlatformRole roleObj = getRole(role);
  if (roleObj == null)
    return new XSPReplyApiError(ERROR_INVALID_ROLE, role);
  // check for current user with admin role
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_ASSIGN_ROLE_TO_USER);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("entity", nodes.getIRINode(USERS + user));
  parameters.put("role", nodes.getIRINode(ROLES + role));
  reply = database.executeStoredProcedure(procedures.get("procedure-assign-role"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

@Override
public XSPReply removeAdminFromGroup(String user, String group) {
  // check input data
  PlatformGroup groupObject = getGroup(group);
  if (groupObject == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, group);
  PlatformUser newUser = getUser(user);
  if (newUser == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, user);
  // check the current user is either the platform admin or the group admin
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_REMOVE_ADMIN_FROM_GROUP, groupObject);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("group", nodes.getIRINode(GROUPS + group));
  parameters.put("admin", nodes.getIRINode(USERS + user));
  reply = database.executeStoredProcedure(procedures.get("procedure-remove-admin"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

@Override
public XSPReply unassignRoleToUser(String user, String role) {
  // check input data
  PlatformUser userObj = getUser(user);
  if (userObj == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, user);
  PlatformRole roleObj = getRole(role);
  if (roleObj == null)
    return new XSPReplyApiError(ERROR_INVALID_ROLE, role);
  // check for current user with admin role
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_UNASSIGN_ROLE_TO_USER);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("entity", nodes.getIRINode(USERS + user));
  parameters.put("role", nodes.getIRINode(ROLES + role));
  reply = database.executeStoredProcedure(procedures.get("procedure-unassign-role"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

@Override
public XSPReply addUserToGroup(String user, String group) {
  // check input data
  PlatformGroup groupObject = getGroup(group);
  if (groupObject == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, group);
  PlatformUser newUser = getUser(user);
  if (newUser == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, user);
  // check the current user is either the platform admin or the group admin
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_ADD_USER_TO_GROUP, groupObject);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("group", nodes.getIRINode(GROUPS + group));
  parameters.put("user", nodes.getIRINode(USERS + user));
  reply = database.executeStoredProcedure(procedures.get("procedure-add-member"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

@Override
public XSPReply removeUserFromGroup(String user, String group) {
  // check input data
  PlatformGroup groupObject = getGroup(group);
  if (groupObject == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, group);
  PlatformUser newUser = getUser(user);
  if (newUser == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, user);
  // check the current user is either the platform admin or the group admin
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_REMOVE_USER_FROM_GROUP, groupObject);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("group", nodes.getIRINode(GROUPS + group));
  parameters.put("user", nodes.getIRINode(USERS + user));
  reply = database.executeStoredProcedure(procedures.get("procedure-remove-member"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

@Override
public XSPReply assignRoleToGroup(String group, String role) {
  // check input data
  PlatformGroup groupObj = getGroup(group);
  if (groupObj == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, group);
  PlatformRole roleObj = getRole(role);
  if (roleObj == null)
    return new XSPReplyApiError(ERROR_INVALID_ROLE, role);
  // check for current user with admin role
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_ASSIGN_ROLE_TO_GROUP);
  if (!reply.isSuccess())
    return reply;
  // execute
  Map<String, Node> parameters = new HashMap<>();
  parameters.put("entity", nodes.getIRINode(GROUPS + group));
  parameters.put("role", nodes.getIRINode(ROLES + role));
  reply = database.executeStoredProcedure(procedures.get("procedure-assign-role"),
      new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
  if (!reply.isSuccess())
    return reply;
  return XSPReplySuccess.instance();
}

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

if (service != null)
  return new XSPReplyApiError(ERROR_CONNECTOR_SAME_ID);
  return new XSPReplyApiError(ERROR_NO_FACTORY);

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

@Override
public XSPReply renameUser(String identifier, String name) {
  // check authorization
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  PlatformUser userObject = getUser(identifier);
  if (userObject == null)
    return new XSPReplyApiError(ERROR_INVALID_USER, identifier);
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_RENAME_USER, userObject);
  if (!reply.isSuccess())
    return reply;
  synchronized (cacheUsers) {
    Map<String, Node> parameters = new HashMap<>();
    parameters.put("entity", nodes.getIRINode(USERS + identifier));
    parameters.put("newName", nodes.getLiteralNode(name, Vocabulary.xsdString, null));
    reply = database.executeStoredProcedure(procedures.get("procedure-rename-entity"),
        new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
    if (!reply.isSuccess())
      return reply;
    cacheUsers.remove(identifier);
    return XSPReplySuccess.instance();
  }
}

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

@Override
public XSPReply renameGroup(String identifier, String name) {
  // check authorization
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  PlatformGroup groupObject = getGroup(identifier);
  if (groupObject == null)
    return new XSPReplyApiError(ERROR_INVALID_GROUP, identifier);
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_RENAME_GROUP, groupObject);
  if (!reply.isSuccess())
    return reply;
  synchronized (cacheGroups) {
    // rename the entity
    Map<String, Node> parameters = new HashMap<>();
    parameters.put("entity", nodes.getIRINode(GROUPS + identifier));
    parameters.put("newName", nodes.getLiteralNode(name, Vocabulary.xsdString, null));
    reply = database.executeStoredProcedure(procedures.get("procedure-rename-entity"),
        new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
    if (!reply.isSuccess())
      return reply;
    cacheGroups.remove(identifier);
    return XSPReplySuccess.instance();
  }
}

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

@Override
public XSPReply renameRole(String identifier, String name) {
  // check authorization
  SecurityService securityService = Register.getComponent(SecurityService.class);
  if (securityService == null)
    return XSPReplyServiceUnavailable.instance();
  PlatformRole roleObject = getRole(identifier);
  if (roleObject == null)
    return new XSPReplyApiError(ERROR_INVALID_ROLE, identifier);
  XSPReply reply = securityService.getPolicy().checkAction(securityService, SecurityService.ACTION_RENAME_ROLE, roleObject);
  if (!reply.isSuccess())
    return reply;
  synchronized (cacheRoles) {
    // rename the entity
    Map<String, Node> parameters = new HashMap<>();
    parameters.put("entity", nodes.getIRINode(ROLES + identifier));
    parameters.put("newName", nodes.getLiteralNode(name, Vocabulary.xsdString, null));
    reply = database.executeStoredProcedure(procedures.get("procedure-rename-entity"),
        new BaseStoredProcedureContext(Collections.<String>emptyList(), Collections.<String>emptyList(), parameters));
    if (!reply.isSuccess())
      return reply;
    cacheRoles.remove(identifier);
    return XSPReplySuccess.instance();
  }
}

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

return new XSPReplyApiError(ERROR_ADDON_NOT_INSTALLED);

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

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com