当前位置: 首页>>代码示例>>Java>>正文


Java NotFoundException类代码示例

本文整理汇总了Java中javax.ws.rs.NotFoundException的典型用法代码示例。如果您正苦于以下问题:Java NotFoundException类的具体用法?Java NotFoundException怎么用?Java NotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NotFoundException类属于javax.ws.rs包,在下文中一共展示了NotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteQueue

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
public Response deleteQueue(String queueName, Boolean ifUnused, Boolean ifEmpty) {
    if (Objects.isNull(ifUnused)) {
        ifUnused = true;
    }

    if (Objects.isNull(ifEmpty)) {
        ifEmpty = true;
    }

    try {
        if (broker.deleteQueue(queueName, ifUnused, ifEmpty)) {
            return Response.ok().build();
        } else {
            throw new NotFoundException("Queue " + queueName + " doesn't exist.");
        }
    } catch (BrokerException e) {
        throw new BadRequestException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:20,代码来源:QueuesApiDelegate.java

示例2: uploadPart

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
/**
 *  Add a segment of a binary.
 *
 *  <p>Note: the response will be a json structure, such as:</p>
 *  <pre>{
 *    "digest": "a-hash"
 *  }</pre>
 *
 *  @param id the upload session identifier
 *  @param partNumber the part number
 *  @param part the input stream
 *  @return a response
 */
@PUT
@Timed
@Path("{partNumber}")
@Produces("application/json")
public String uploadPart(@PathParam("id") final String id,
        @PathParam("partNumber") final Integer partNumber,
        final InputStream part) {

    final JsonObjectBuilder builder = Json.createObjectBuilder();

    if (!binaryService.uploadSessionExists(id)) {
        throw new NotFoundException();
    }

    final String digest = binaryService.uploadPart(id, partNumber, part);

    return builder.add("digest", digest).build().toString();
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:32,代码来源:MultipartUploader.java

示例3: toResponse

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
@Override
public Response toResponse(NotFoundException ex) {
  if (ex.getCause() instanceof IllegalArgumentException) {
    // If a URL parameter cannot be decoded (e.g. an invalid UUID) an IllegalArgumentException will be wrapped inside
    // a NotFoundException. But a 412 should be returned in this case.
    return ResultStash.builder()
            .setStatus(Response.Status.PRECONDITION_FAILED)
            .addActionError("Invalid URL parameter detected.", "invalid.url.parameter")
            .buildResponse();
  }

  return ResultStash.builder()
          .setStatus(Response.Status.NOT_FOUND)
          .addActionError("Requested URL does not exist.", "url.not.exist")
          .buildResponse();
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:17,代码来源:NotFoundMapper.java

示例4: getLRAStatus

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
@GET
@Path("{LraId}")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Obtain the status of an LRA as a string",
        response = String.class)
@ApiResponses( {
        @ApiResponse( code = 404, message =
                "The coordinator has no knowledge of this LRA" ),
        @ApiResponse( code = 204, message =
                "The LRA exists and has not yet been asked to close or cancel "
                       + " - compare this response with a 200 response.s"),
        @ApiResponse( code = 200, message =
                "The LRA exists. The status is reported in the content body.")
} )
public Response getLRAStatus(
        @ApiParam( value = "The unique identifier of the LRA", required = true )
        @PathParam("LraId")String lraId) throws NotFoundException {
    CompensatorStatus status = lraService.getTransaction(toURL(lraId)).getLRAStatus();

    if (status == null)
        return Response.noContent().build(); // 204 means the LRA is still active

    return Response.ok(status.name()).build();
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:25,代码来源:Coordinator.java

示例5: active

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
@PUT
@Path("{LraId}/renew")
@ApiOperation(value = "Update the TimeLimit for an existing LRA",
        notes = "LRAs can be automatically cancelled if they aren't closed or cancelled before the TimeLimit\n"
                + "specified at creation time is reached.\n"
                + "The time limit can be updated.\n")
@ApiResponses({
        @ApiResponse( code = 200, message = "If the LRA timelimit has been updated" ),
        @ApiResponse( code = 404, message = "The coordinator has no knowledge of this LRA" ),
        @ApiResponse( code = 412, message = "The LRA is not longer active (ie in the complete or compensate messages have been sent" )
} )
public Response renewTimeLimit(
        @ApiParam( value = "The new time limit for the LRA", required = true )
        @QueryParam(TIMELIMIT_PARAM_NAME) @DefaultValue("0") Long timelimit,
        @PathParam("LraId")String lraId) throws NotFoundException {

    return Response.status(lraService.renewTimeLimit(toURL(lraId), timelimit)).build();
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:19,代码来源:Coordinator.java

示例6: closeLRA

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
@PUT
@Path("{LraId}/close")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Attempt to close an LRA",
        notes = "Trigger the successful completion of the LRA. All"
                +" compensators will be dropped by the coordinator."
                +" The complete message will be sent to the compensators."
                +" Upon termination, the URL is implicitly deleted."
                +" The invoker cannot know for sure whether the lra completed or compensated without enlisting a participant.",
        response = Boolean.class)
@ApiResponses( {
        @ApiResponse( code = 404, message = "The coordinator has no knowledge of this LRA" ),
        @ApiResponse( code = 200, message = "The complete message was sent to all coordinators" )
} )
public Response closeLRA(
        @ApiParam( value = "The unique identifier of the LRA", required = true )
        @PathParam("LraId")String txId) throws NotFoundException {
    return endLRA(toURL(txId), false, false);
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:20,代码来源:Coordinator.java

示例7: coordinator

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
@PUT
@Path("{LraId}/cancel")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Attempt to cancel an LRA",
        notes =   " Trigger the compensation of the LRA. All"
                + " compensators will be triggered by the coordinator (ie the compensate message will be sent to each compensators)."
                + " Upon termination, the URL is implicitly deleted."
                + " The invoker cannot know for sure whether the lra completed or compensated without enlisting a participant.",
        response = Boolean.class)
@ApiResponses( {
        @ApiResponse( code = 404, message = "The coordinator has no knowledge of this LRA" ),
        @ApiResponse( code = 200, message = "The compensate message was sent to all coordinators" )
} )
public Response cancelLRA(
        @ApiParam( value = "The unique identifier of the LRA", required = true )
        @PathParam("LraId")String lraId) throws NotFoundException {
    return endLRA(toURL(lraId), true, false);
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:19,代码来源:Coordinator.java

示例8: _getNestedCollectionRoutesTry

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
private <T> Try<NestedCollectionRoutes<T>> _getNestedCollectionRoutesTry(
	String name, String nestedName) {

	Try<Optional<NestedCollectionRoutes<T>>> optionalTry = Try.success(
		_nestedCollectionRouterManager.getNestedCollectionRoutesOptional(
			name, nestedName));

	return optionalTry.map(
		Optional::get
	).recoverWith(
		__ -> _getReusableNestedCollectionRoutesTry(nestedName)
	).mapFailMatching(
		NoSuchElementException.class,
		() -> new NotFoundException("No resource found for path " + name)
	);
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:17,代码来源:RootEndpointImpl.java

示例9: joinLRA

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
private Response joinLRA(URL lraId, long timeLimit, String compensatorUrl, String linkHeader, String userData)
        throws NotFoundException {
    final String recoveryUrlBase = String.format("http://%s/%s/",
            context.getRequestUri().getAuthority(), NarayanaLRAClient.RECOVERY_COORDINATOR_PATH_NAME);

    StringBuilder recoveryUrl = new StringBuilder();

    int status = lraService.joinLRA(recoveryUrl, lraId, timeLimit, compensatorUrl, linkHeader, recoveryUrlBase, userData);

    try {
        return Response.status(status)
                .entity(recoveryUrl)
                .location(new URI(recoveryUrl.toString()))
                .header(LRA_HTTP_RECOVERY_HEADER, recoveryUrl)
                .build();
    } catch (URISyntaxException e) {
        LRALogger.i18NLogger.error_invalidRecoveryUrlToJoinLRA(recoveryUrl.toString(), lraId);
        throw new GenericLRAException(lraId, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Invalid recovery URL", e);
    }
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:21,代码来源:Coordinator.java

示例10: handle

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
public Response handle(final MinijaxRequestContext context) {
    final MinijaxResourceMethod rm = findRoute(context.getMethod(), (MinijaxUriInfo) context.getUriInfo());
    if (rm == null) {
        return toResponse(context, new NotFoundException());
    }

    context.setResourceMethod(rm);

    try {
        if (securityContextClass != null) {
            context.setSecurityContext(get(securityContextClass));
        }

        runRequestFilters(context);
        checkSecurity(context);
        final Response response = toResponse(rm, rm.invoke(context));
        runResponseFilters(context, response);
        return response;
    } catch (final Exception ex) {
        LOG.debug(ex.getMessage(), ex);
        return toResponse(context, ex);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:24,代码来源:MinijaxApplication.java

示例11: testBadGet

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
/**
 * Tests that a fetch of a non-existent port chain object throws an exception.
 */
@Test
public void testBadGet() {
    expect(portChainService.getPortChain(anyObject()))
    .andReturn(null).anyTimes();
    replay(portChainService);
    WebTarget wt = target();
    try {
        wt.path("port_chains/78dcd363-fc23-aeb6-f44b-56dc5aafb3ae")
                .request().get(String.class);
        fail("Fetch of non-existent port chain did not throw an exception");
    } catch (NotFoundException ex) {
        assertThat(ex.getMessage(),
                   containsString("HTTP 404 Not Found"));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:PortChainResourceTest.java

示例12: toResponse

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
@Override
public Response toResponse(Exception exception) {
    if (exception instanceof NotFoundException) {
        return Response.status(Response.Status.NOT_FOUND).build();
    }
    UUID eventId = UUID.randomUUID();
    LOG.error(MessageFormat.format("{0} - Exception while processing request.", eventId), exception);
    StringBuilder sb = new StringBuilder();
    sb.append(exception.getClass().getName());

    if (configuration.getReturnStackTraceInResponse()) {
        sb.append(" : ");
        sb.append(exception.getMessage());
        sb.append("\n");
        for (StackTraceElement element : exception.getStackTrace()) {
            sb.append("! ");
            sb.append(element.toString());
            sb.append("\n");
        }
    }
    return Response.serverError().entity(sb.toString()).build();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:23,代码来源:ExceptionExceptionMapper.java

示例13: testBadGet

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
/**
 * Tests that a fetch of a non-existent intent object throws an exception.
 */
@Test
public void testBadGet() {

    expect(mockIntentService.getIntent(Key.of(0, APP_ID)))
            .andReturn(null)
            .anyTimes();
    replay(mockIntentService);

    WebTarget wt = target();
    try {
        wt.path("intents/0").request().get(String.class);
        fail("Fetch of non-existent intent did not throw an exception");
    } catch (NotFoundException ex) {
        assertThat(ex.getMessage(),
                containsString("HTTP 404 Not Found"));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:IntentsResourceTest.java

示例14: testBadGet

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
/**
 * Tests that a fetch of a non-existent device object throws an exception.
 */
@Test
public void testBadGet() {
    expect(mockFlowService.getFlowEntries(anyObject()))
            .andReturn(null).anyTimes();
    replay(mockFlowService);
    replay(mockDeviceService);

    WebTarget wt = target();
    try {
        wt.path("flows/0").request().get(String.class);
        fail("Fetch of non-existent device did not throw an exception");
    } catch (NotFoundException ex) {
        assertThat(ex.getMessage(),
                containsString("HTTP 404 Not Found"));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:FlowsResourceTest.java

示例15: testBadGet

import javax.ws.rs.NotFoundException; //导入依赖的package包/类
/**
 * Tests that a fetch of a non-existent port pair group object throws an exception.
 */
@Test
public void testBadGet() {
    expect(portPairGroupService.getPortPairGroup(anyObject()))
    .andReturn(null).anyTimes();
    replay(portPairGroupService);
    WebTarget wt = target();
    try {
        wt.path("port_pair_groups/78dcd363-fc23-aeb6-f44b-56dc5aafb3ae")
                .request().get(String.class);
        fail("Fetch of non-existent port pair group did not throw an exception");
    } catch (NotFoundException ex) {
        assertThat(ex.getMessage(),
                   containsString("HTTP 404 Not Found"));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:PortPairGroupResourceTest.java


注:本文中的javax.ws.rs.NotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。