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


Java Response.status方法代码示例

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


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

示例1: insert

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * Cadastra litersminute
 * 
 * @param User
 * @return Response
 */
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(LitersMinute litersminute) {
	ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
	builder.expires(new Date());

	Timestamp date = new Timestamp(System.currentTimeMillis());
	litersminute.setDate(date);

	try {
		AirConditioning air = AirConditioningDao.getInstance().getById(litersminute.getAirconditioning().getId());

		if (air.getId().equals(null)) {
			AirConditioningDao.getInstance().insertU(litersminute.getAirconditioning());
		} else {
			litersminute.setAirconditioning(air);
		}

		Long id = LitersMinuteDao.getInstance().insertU(litersminute);
		litersminute.setId(id);

		System.out.println(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(date.getTime()));
		System.out.println(date.getTime());
		builder.status(Response.Status.OK).entity(litersminute);

	} catch (SQLException e) {
		builder.status(Response.Status.INTERNAL_SERVER_ERROR);
	}

	return builder.build();
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:41,代码来源:LitersMinuteController.java

示例2: insert

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * Cadastra usuario
 * 
 * @param User
 * @return Response
 */
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(User user) {

	ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
	builder.expires(new Date());

	try {

		Long idUser = (long) UserDao.getInstance().insertU(user);
		user.setId(idUser);
		builder.status(Response.Status.OK).entity(user);

	} catch (SQLException e) {

		builder.status(Response.Status.INTERNAL_SERVER_ERROR);
	}

	return builder.build();
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:30,代码来源:UserController.java

示例3: getAirConditioningById

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * Return all lmin by air
 * 
 * @return Response
 */
@PermitAll
@GET
@Path("/byair/{id}")
@Produces("application/json")
public Response getAirConditioningById(@PathParam("id") Long idAir) {
	ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
	builder.expires(new Date());

	try {
		List<LitersMinute> lmin = LitersMinuteDao.getInstance().getByAirId(idAir);

		if (lmin != null) {
			builder.status(Response.Status.OK);
			builder.entity(lmin);

		} else {
			builder.status(Response.Status.NOT_FOUND);
		}

	} catch (SQLException exception) {
		builder.status(Response.Status.INTERNAL_SERVER_ERROR);
	}

	return builder.build();
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:31,代码来源:LitersMinuteController.java

示例4: createFolderPost

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * @param stagingUuid
 * @param parentFolder May or may not be present. This folder must already
 *            exist.
 * @param folder Mandatory
 * @return
 */
@Override
public Response createFolderPost(String stagingUuid, String parentFolder, GenericFileBean folder)
{
	final StagingFile stagingFile = getStagingFile(stagingUuid);
	ensureFileExists(stagingFile, parentFolder);

	final String filename = folder.getFilename();
	final String newPath = PathUtils.filePath(parentFolder, filename);

	boolean exists = fileSystemService.fileExists(stagingFile, newPath);
	fileSystemService.mkdir(stagingFile, newPath);

	// was: .entity(convertFile(stagingFile, newPath, false))
	ResponseBuilder resp = Response.status(exists ? Status.OK : Status.CREATED);
	if( !exists )
	{
		resp = resp.location(itemLinkService.getFileDirURI(stagingFile, URLUtils.urlEncode(newPath, false)));
	}
	return resp.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:FileResourceImpl.java

示例5: getJobTasks

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@ApiOperation(value = "Retrieves Job's tasks",
        notes = "Retrieves a Job's Tasks for Job specified by the Job Id",
        response = TaskRecordDto.class,
        responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@GET
@Path("/{jobId}/tasks")
public List<TaskRecordDto> getJobTasks(@PathParam("jobId") Long jobId) {

    logger.info("Listing task records for job id " + jobId);

    try {
        ListTaskRequest listRequest = new ListTaskRequest();
        listRequest.setJobId(jobId);
        ListResponse<TaskRecordDto> res = this.listTaskService.dispatch(listRequest);

        return res.getList();
    } catch (Exception e) {
        throw new VmidcRestServerException(Response.status(Status.INTERNAL_SERVER_ERROR), e.getMessage());
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:23,代码来源:JobApis.java

示例6: insert

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * Cadastrar air
 * 
 * @param AirConditioning
 * @return Response
 */
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(AirConditioning air) {
	ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
	builder.expires(new Date());

	try {
		Long idAir = (long) AirConditioningDao.getInstance().insertU(air);
		air.setId(idAir);
		builder.status(Response.Status.OK).entity(air);

	} catch (SQLException e) {
		builder.status(Response.Status.INTERNAL_SERVER_ERROR);
	}

	return builder.build();
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:27,代码来源:AirConditioningController.java

示例7: post

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * POST method.
 * @param reader Request body
 * @return JAX-RS Response
 */
@WriteAPI
@POST
public Response post(final Reader reader) {
    // Check the authority required for execution.
    cellRsCmp.checkAccessContext(cellRsCmp.getAccessContext(), CellPrivilege.ROOT);

    // Reading body.
    JSONObject body;
    body = ResourceUtils.parseBodyAsJSON(reader);
    String name = (String) body.get(BODY_JSON_KEY_NAME);
    // Validate body.
    if (name == null) {
        throw PersoniumCoreException.Common.REQUEST_BODY_REQUIRED_KEY_MISSING.params(BODY_JSON_KEY_NAME);
    }
    if (!ODataUtils.validateRegEx(name, Common.PATTERN_SNAPSHOT_NAME)) {
        throw PersoniumCoreException.Common.REQUEST_BODY_FIELD_FORMAT_ERROR.params(
                BODY_JSON_KEY_NAME, Common.PATTERN_SNAPSHOT_NAME);
    }

    SnapshotFileManager snapshotFileManager = new SnapshotFileManager(cellRsCmp.getCell(), name);
    snapshotFileManager.importSnapshot();

    ResponseBuilder res = Response.status(HttpStatus.SC_ACCEPTED);
    res.header(HttpHeaders.LOCATION, cellRsCmp.getCell().getUrl() + "__import");
    return res.build();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:32,代码来源:CellImportResource.java

示例8: buildAuthenticationErrorResponse

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * Build an authentication error response
 * @param schemes Optional allowed authentication schemes
 * @param errorCode Optional error code
 * @param errorDescription Optional error description
 * @param statusCode HTTP status code
 * @param realmName Optional realm name
 * @return Authentication error response
 */
public static Response buildAuthenticationErrorResponse(String[] schemes, String errorCode, String errorDescription,
		int statusCode, String realmName) {

	// status
	Status status = Status.UNAUTHORIZED;
	if (statusCode > 0) {
		Status errorStatus = Status.fromStatusCode(statusCode);
		if (errorStatus != null) {
			status = errorStatus;
		}
	}

	// response
	ResponseBuilder responseBuilder = Response.status(status);

	if (schemes != null && schemes.length > 0) {
		for (String scheme : schemes) {
			responseBuilder.header(HttpHeaders.WWW_AUTHENTICATE,
					buildAuthenticationErrorHeader(scheme, errorCode, errorDescription, realmName));
		}
	}

	// response
	return responseBuilder.header(HttpHeaders.CACHE_CONTROL, "no-store").header(HttpHeaders.PRAGMA, "no-cache")
			.build();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:36,代码来源:ResponseUtils.java

示例9: testSetStatusCode

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@Test
public void testSetStatusCode() {
    final ResponseBuilder builder = Response.status(404);
    final Response response = builder.build();
    assertEquals(404, response.getStatus());
    assertEquals("Not Found", response.getStatusInfo().getReasonPhrase());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:ResponseBuilderTest.java

示例10: toResponse

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@Override
public Response toResponse(Exception exception) {
    final UUID errorId = UUID.randomUUID();
    Response.ResponseBuilder response = Response.status(Response.Status.BAD_REQUEST);

    // when creating a new exception here we want to create an unaudited application exception - this is to ensure
    // that the exception is audited by the calling application, as saml-engine no longer talks directly to
    // event sink

    if(exception instanceof ApplicationException) {
        ApplicationException applicationException = (ApplicationException)exception;
        response.entity(logAndGetErrorStatusDto(applicationException.getExceptionType().getLevel(), applicationException.getExceptionType(), applicationException, applicationException.getErrorId(), applicationException.isAudited()));
    } else if(exception instanceof SamlContextException) {
        SamlContextException contextException = (SamlContextException) exception;
        response.entity(logAndGetErrorStatusDto(contextException.getLogLevel(), contextException.getExceptionType(), exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else if(exception instanceof SamlFailedToDecryptException) {
        response.entity(logAndGetErrorStatusDto(((SamlFailedToDecryptException) exception).getLogLevel(), ExceptionType.INVALID_SAML_FAILED_TO_DECRYPT, exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else if(exception instanceof SamlDuplicateRequestIdException) {
        response.entity(logAndGetErrorStatusDto(((SamlDuplicateRequestIdException) exception).getLogLevel(), ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID, exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else if(exception instanceof SamlRequestTooOldException) {
        response.entity(logAndGetErrorStatusDto(((SamlTransformationErrorException) exception).getLogLevel(), ExceptionType.INVALID_SAML_REQUEST_TOO_OLD, exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else if(exception instanceof SamlTransformationErrorException) {
        response.entity(logAndGetErrorStatusDto(((SamlTransformationErrorException) exception).getLogLevel(), ExceptionType.INVALID_SAML, exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else if(exception instanceof UnableToGenerateSamlException) {
        response.entity(logAndGetErrorStatusDto(((UnableToGenerateSamlException) exception).getLogLevel(), ExceptionType.INVALID_INPUT, exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else if (exception instanceof NoKeyConfiguredForEntityException) {
        response.entity(logAndGetErrorStatusDto(ERROR, ExceptionType.NO_KEY_CONFIGURED_FOR_ENTITY, exception, errorId, HAS_NOT_BEEN_AUDITED_YET));
    } else {
        levelLogger.log(WARN, exception, errorId);
    }

    return response.build();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:34,代码来源:SamlEngineExceptionMapper.java

示例11: toResponse

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@Override
public Response toResponse(OryxServingException exception) {
  Response.ResponseBuilder response = Response.status(exception.getStatusCode());
  if (exception.getMessage() != null) {
    response = response.entity(exception.getMessage());
  }
  return response.build();
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:9,代码来源:OryxExceptionMapper.java

示例12: toResponse

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
public Response toResponse() {
	Response.ResponseBuilder builder = Response.status(status);
	if (bodySet && body != null) {
		builder.entity(ScriptObjectMirrors.convert(body));
	}
	setResponseBuilderHeaders(builder);
	return builder.build();
}
 
开发者ID:marrow16,项目名称:Nasapi,代码行数:9,代码来源:EndpointResponse.java

示例13: toResponse

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@Override
public Response toResponse(UnauthorizedException exception) {

    logger.info("{}. Returning {} response.", exception, Response.Status.UNAUTHORIZED);
    logger.debug(StringUtils.EMPTY, exception);

    final Response.ResponseBuilder response = Response.status(Response.Status.UNAUTHORIZED);
    if (exception.getWwwAuthenticateChallenge() != null) {
        response.header(AUTHENTICATION_CHALLENGE_HEADER_NAME, exception.getWwwAuthenticateChallenge());
    }
    response.entity(exception.getMessage()).type("text/plain");
    return response.build();

}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:15,代码来源:UnauthorizedExceptionMapper.java

示例14: getEmptyResponse

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * イベントログが存在しない場合に返却する空レスポンスを取得する.
 * @return 空レスポンス
 */
private Response getEmptyResponse() {
    // レスポンスの返却
    ResponseBuilder res = Response.status(HttpStatus.SC_OK);
    res.header(HttpHeaders.CONTENT_TYPE, EventUtils.TEXT_CSV);

    res.entity("");
    log.debug("main thread end.");
    return res.build();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:14,代码来源:LogResource.java

示例15: getGardensByGardenId

import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
 * Get garden status by garden's id
 * 
 * @param gardenId
 * @return
 */
@PermitAll
@GET
@Path("/garden/{gardenId}")
@Produces("application/json")
public Response getGardensByGardenId(@PathParam("gardenId") Long gardenId) {

	ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
	builder.expires(new Date());

	try {

		List<GardenStatus> gardenStatus = GardenStatusDao.getInstance().getByGardenId(gardenId);

		if (gardenStatus != null) {

			builder.status(Response.Status.OK);
			builder.entity(gardenStatus);
		} else {

			builder.status(Response.Status.NOT_FOUND);
		}

	} catch (SQLException exception) {

		builder.status(Response.Status.INTERNAL_SERVER_ERROR);
	}

	return builder.build();
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:36,代码来源:GardenStatusController.java


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