javax.ws.rs.core.Response.Status#NOT_FOUND源码实例Demo

下面列出了javax.ws.rs.core.Response.Status#NOT_FOUND 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pulsar   文件: PersistentTopicsBase.java
private RestException topicNotFoundReason(TopicName topicName) {
    if (!topicName.isPartitioned()) {
        return new RestException(Status.NOT_FOUND, "Topic not found");
    }

    PartitionedTopicMetadata partitionedTopicMetadata = getPartitionedTopicMetadata(
            TopicName.get(topicName.getPartitionedTopicName()), false, false);
    if (partitionedTopicMetadata == null || partitionedTopicMetadata.partitions == 0) {
        final String topicErrorType = partitionedTopicMetadata == null ?
                "has no metadata" : "has zero partitions";
        return new RestException(Status.NOT_FOUND, String.format(
                "Partitioned Topic not found: %s %s", topicName.toString(), topicErrorType));
    } else if (!internalGetList().contains(topicName.toString())) {
        return new RestException(Status.NOT_FOUND, "Topic partitions were not yet created");
    }
    return new RestException(Status.NOT_FOUND, "Partitioned Topic not found");
}
 
源代码2 项目: cxf-fediz   文件: IdpServiceImpl.java
@Override
public Response removeClaimFromIdp(UriInfo ui, String realm, String claimType) {
    Idp idp = idpDAO.getIdp(realm, Arrays.asList("all"));

    Claim foundItem = null;
    for (Claim item : idp.getClaimTypesOffered()) {
        if (item.getClaimType().toString().equals(claimType)) {
            foundItem = item;
            break;
        }
    }
    if (foundItem == null) {
        LOG.warn("Claim '" + claimType + "' not found");
        throw new WebApplicationException(Status.NOT_FOUND);
    }
    idpDAO.removeClaimFromIdp(idp, foundItem);

    return Response.noContent().build();
}
 
源代码3 项目: Baragon   文件: AlbResource.java
@POST
@Path("/load-balancers/{elbName}/listeners")
public Listener createListeners(@PathParam("elbName") String elbName,
                                @Valid CreateListenerRequest createListenerRequest) {
  if (config.isPresent()) {
      Optional<LoadBalancer> maybeLoadBalancer = applicationLoadBalancer
          .getLoadBalancer(elbName);
      if (maybeLoadBalancer.isPresent()) {
        return applicationLoadBalancer
            .createListener(createListenerRequest
                .withLoadBalancerArn(maybeLoadBalancer.get().getLoadBalancerArn()));
      } else {
        throw new WebApplicationException(String.format("Could not find an elb with name %s", elbName), Status.NOT_FOUND);
      }
  } else {
    throw new BaragonWebException("ElbSync and related actions are not currently enabled");
  }
}
 
源代码4 项目: hermes   文件: MetaServerResource.java
@GET
@Path("servers")
public List<String> getServers(@QueryParam("clientTimeMillis") @DefaultValue("0") long clientTimeMillis, //
      @Context HttpServletResponse res) {
	Meta meta = m_metaHolder.getMeta();
	if (meta == null) {
		throw new RestException("Meta not found", Status.NOT_FOUND);
	}

	if (clientTimeMillis > 0) {
		long diff = clientTimeMillis - System.currentTimeMillis();
		if (Math.abs(diff) > m_coreConfig.getMaxClientTimeDiffMillis()) {
			res.addHeader(CoreConfig.TIME_UNSYNC_HEADER, Long.toString(diff));
		}
	}

	Collection<Server> servers = meta.getServers().values();
	List<String> result = new ArrayList<>();
	for (Server server : servers) {
		result.add(String.format("%s:%s", server.getHost(), server.getPort()));
	}

	return result;
}
 
源代码5 项目: neoscada   文件: ItemResourceImpl.java
@Override
public Response readAllCsv ( final String contextId )
{
    final DataContext context = this.provider.getContext ( contextId );

    if ( context == null )
    {
        logger.trace ( "Context '{}' not found", contextId ); //$NON-NLS-1$
        throw new WebApplicationException ( Status.NOT_FOUND );
    }

    final SortedMap<String, DataItemValue> values = context.getAllValues ();

    final StreamingOutput out = new StreamingOutput () {

        @Override
        public void write ( final OutputStream output ) throws IOException, WebApplicationException
        {
            streamAsCSV ( new PrintWriter ( new OutputStreamWriter ( output, StandardCharsets.UTF_8 ) ), values, ",", "\r\n" ); //$NON-NLS-1$  //$NON-NLS-2$
        }
    };
    return Response.ok ( out ).header ( "Content-Disposition", "attachment; filename=\"data.csv\"" ).build (); //$NON-NLS-1$
}
 
源代码6 项目: quarkus-deep-dive   文件: TodoResource.java
@DELETE
@Transactional
@Path("/{id}")
public Response deleteOne(@PathParam("id") Long id) {
    Todo entity = Todo.findById(id);
    if (entity == null) {
        throw new WebApplicationException("Todo with id of " + id + " does not exist.", Status.NOT_FOUND);
    }
    entity.delete();
    return Response.noContent().build();
}
 
源代码7 项目: nexus-public   文件: RoutingRulesResource.java
@PUT
@Path("/{name}")
@RequiresAuthentication
@RequiresPermissions("nexus:*")
public void updateRoutingRule(@PathParam("name") final String name, RoutingRuleXO routingRuleXO) {
  RoutingRule routingRule = routingRuleStore.getByName(name);
  if (null == routingRule) {
    throw new WebApplicationException(Status.NOT_FOUND);
  }
  routingRule.name(routingRuleXO.getName());
  routingRule.description(routingRuleXO.getDescription());
  routingRule.mode(routingRuleXO.getMode());
  routingRule.matchers(routingRuleXO.getMatchers());
  routingRuleStore.update(routingRule);
}
 
源代码8 项目: quarkus-deep-dive   文件: TodoResource.java
@DELETE
@Transactional
@Path("/{id}")
public Response deleteOne(@PathParam("id") Long id) {
    Todo entity = Todo.findById(id);
    if (entity == null) {
        throw new WebApplicationException("Todo with id of " + id + " does not exist.", Status.NOT_FOUND);
    }
    entity.delete();
    return Response.noContent().build();
}
 
源代码9 项目: imagej-server   文件: ObjectsResource.java
/**
 * Shows the information of an object.
 * 
 * @param id object ID
 * @return a JSON node containing the object information
 */
@GET
@Path("{id}")
public ObjectInfo getObjectInfo(@PathParam("id") final String id) {
	if (!objectService.contains(id)) {
		throw new WebApplicationException("ID does not exist", Status.NOT_FOUND);
	}
	return objectService.find(id);
}
 
@Override
public void unlock() {
  ExternalTaskService externalTaskService = engine.getExternalTaskService();

  try {
    externalTaskService.unlock(externalTaskId);
  } catch (NotFoundException e) {
    throw new RestException(Status.NOT_FOUND, e, "External task with id " + externalTaskId + " does not exist");
  }
}
 
public CaseInstanceDto getCaseInstance() {
  CaseService caseService = engine.getCaseService();

  CaseInstance instance = caseService
      .createCaseInstanceQuery()
      .caseInstanceId(caseInstanceId)
      .singleResult();

  if (instance == null) {
    throw new InvalidRequestException(Status.NOT_FOUND, "Case instance with id " + caseInstanceId + " does not exist.");
  }

  CaseInstanceDto result = CaseInstanceDto.fromCaseInstance(instance);
  return result;
}
 
public HistoricActivityInstanceDto getHistoricActivityInstance() {
  HistoryService historyService = engine.getHistoryService();
  HistoricActivityInstance instance = historyService.createHistoricActivityInstanceQuery()
    .activityInstanceId(activityInstanceId).singleResult();

  if (instance == null) {
    throw new InvalidRequestException(Status.NOT_FOUND, "Historic activity instance with id '" + activityInstanceId + "' does not exist");
  }

  final HistoricActivityInstanceDto historicActivityInstanceDto = new HistoricActivityInstanceDto();
  HistoricActivityInstanceDto.fromHistoricActivityInstance(historicActivityInstanceDto, instance);
  return historicActivityInstanceDto;
}
 
源代码13 项目: pulsar   文件: NamespacesBase.java
protected PublishRate internalGetPublishRate() {
    validateNamespacePolicyOperation(namespaceName, PolicyName.RATE, PolicyOperation.READ);

    Policies policies = getNamespacePolicies(namespaceName);
    PublishRate publishRate = policies.publishMaxMessageRate.get(pulsar().getConfiguration().getClusterName());
    if (publishRate != null) {
        return publishRate;
    } else {
        throw new RestException(Status.NOT_FOUND,
                "Publish-rate is not configured for cluster " + pulsar().getConfiguration().getClusterName());
    }
}
 
protected void findRestOperation(MicroserviceMeta microserviceMeta) {
  ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
  if (servicePathManager == null) {
    LOGGER.error("No schema defined for {}:{}.", microserviceMeta.getAppId(), microserviceMeta.getMicroserviceName());
    throw new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase());
  }

  OperationLocator locator = locateOperation(servicePathManager);
  requestEx.setAttribute(RestConst.PATH_PARAMETERS, locator.getPathVarMap());
  this.restOperationMeta = locator.getOperation();
}
 
protected Authorization getDbAuthorization() {
  Authorization dbAuthorization = authorizationService.createAuthorizationQuery()
    .authorizationId(resourceId)
    .singleResult();

  if (dbAuthorization == null) {
    throw new InvalidRequestException(Status.NOT_FOUND, "Authorization with id " + resourceId + " does not exist.");

  } else {
    return dbAuthorization;

  }
}
 
@Override
public Response validateUserExists(String username)
{
    User user = userManager.findByEmail(username);
    Status status = user != null ? Status.OK : Status.NOT_FOUND;
    return Response.status(status).entity("").build();
}
 
源代码17 项目: FHIR   文件: IssueTypeToHttpStatusMapper.java
private static Status issueTypeToResponseCode(IssueType.ValueSet value) {
    switch (value) {
    case INFORMATIONAL:
        return Status.OK;
    case FORBIDDEN:
    case SUPPRESSED:
    case SECURITY:
    case THROTTLED:     // Consider HTTP 429?
        return Status.FORBIDDEN;
    case PROCESSING:
    case BUSINESS_RULE: // Consider HTTP 422?
    case CODE_INVALID:  // Consider HTTP 422?
    case EXTENSION:     // Consider HTTP 422?
    case INVALID:       // Consider HTTP 422?
    case INVARIANT:     // Consider HTTP 422?
    case REQUIRED:      // Consider HTTP 422?
    case STRUCTURE:     // Consider HTTP 422?
    case VALUE:         // Consider HTTP 422?
    case TOO_COSTLY:    // Consider HTTP 403?
    case DUPLICATE:     // Consider HTTP 409?
        return Status.BAD_REQUEST;
    case DELETED:
        return Status.GONE;
    case CONFLICT:
        return Status.CONFLICT;
    case MULTIPLE_MATCHES:
        return Status.PRECONDITION_FAILED;
    case EXPIRED:
    case LOGIN:
    case UNKNOWN:
        return Status.UNAUTHORIZED;
    case NOT_FOUND:
    case NOT_SUPPORTED:
        return Status.NOT_FOUND;
    case TOO_LONG:
        return Status.REQUEST_ENTITY_TOO_LARGE;
    case EXCEPTION:
    case LOCK_ERROR:
    case NO_STORE:
    case TIMEOUT:
    case TRANSIENT:
    case INCOMPLETE:
    default:
        return Status.INTERNAL_SERVER_ERROR;
    }
}
 
源代码18 项目: pulsar   文件: ClustersBase.java
@GET
@Path("/{cluster}/namespaceIsolationPolicies/{policyName}")
@ApiOperation(
        value = "Get the single namespace isolation policy assigned to the cluster.",
        response = NamespaceIsolationData.class,
        notes = "This operation requires Pulsar superuser privileges."
)
@ApiResponses(value = {
        @ApiResponse(code = 403, message = "Don't have admin permission."),
        @ApiResponse(code = 404, message = "Policy doesn't exist."),
        @ApiResponse(code = 412, message = "Cluster doesn't exist."),
        @ApiResponse(code = 500, message = "Internal server error.")
})
public NamespaceIsolationData getNamespaceIsolationPolicy(
    @ApiParam(
        value = "The cluster name",
        required = true
    )
    @PathParam("cluster") String cluster,
    @ApiParam(
        value = "The name of the namespace isolation policy",
        required = true
    )
    @PathParam("policyName") String policyName
) throws Exception {
    validateSuperUserAccess();
    validateClusterExists(cluster);

    try {
        NamespaceIsolationPolicies nsIsolationPolicies = namespaceIsolationPoliciesCache()
                .get(path("clusters", cluster, NAMESPACE_ISOLATION_POLICIES))
                .orElseThrow(() -> new RestException(Status.NOT_FOUND,
                        "NamespaceIsolationPolicies for cluster " + cluster + " does not exist"));
        // construct the response to Namespace isolation data map
        if (!nsIsolationPolicies.getPolicies().containsKey(policyName)) {
            log.info("[{}] Cannot find NamespaceIsolationPolicy {} for cluster {}", clientAppId(), policyName, cluster);
            throw new RestException(Status.NOT_FOUND,
                    "Cannot find NamespaceIsolationPolicy " + policyName + " for cluster " + cluster);
        }
        return nsIsolationPolicies.getPolicies().get(policyName);
    } catch (RestException re) {
        throw re;
    } catch (Exception e) {
        log.error("[{}] Failed to get clusters/{}/namespaceIsolationPolicies/{}", clientAppId(), cluster, e);
        throw new RestException(e);
    }
}
 
源代码19 项目: hadoop   文件: NotFoundException.java
public NotFoundException(String msg) {
  super(new Exception(msg), Status.NOT_FOUND);
}
 
源代码20 项目: hadoop   文件: NotFoundException.java
public NotFoundException() {
  super(Status.NOT_FOUND);
}