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


Java ResponseBuilder类代码示例

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


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

示例1: insert

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的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: getAirConditioningById

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的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

示例3: getTranslations

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
/**
 * Returns Translations of a given {@link Locale}
 * @param locale to get the Translation of
 * @param request The HTTP-Request - is injected automatically
 * @return the translation
 */
@GET
public Response getTranslations(@PathParam("locale") final String locale,
		@Context final Request request) {

	final Translator translator = TranslatorManager.getTranslator(LocaleUtil.toLocale(locale));
	if(translator == null) {
		throw new NotFoundException();
	}

	final File file = translator.getFile();
	final Date lastModified = new Date(file.lastModified());

	ResponseBuilder respBuilder = request.evaluatePreconditions(lastModified);
	if(respBuilder == null) {
		respBuilder = Response.ok();
	}

	return respBuilder.lastModified(lastModified).entity(new StreamingOutput() {
		@Override
		public void write(final OutputStream output) throws IOException, WebApplicationException {
			IOUtils.copy(new FileInputStream(file), output);
		}
	}).build();
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:31,代码来源:TranslationService.java

示例4: getPostResponseBuilder

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
/**
 * POST用のレスポンスビルダーを作成する.
 * @param ent OEntity
 * @param outputFormat Content-Type
 * @param responseStr レスポンスボディ
 * @param resUriInfo レスポンスのUriInfo
 * @param key レスポンスのエンティティキー
 * @return レスポンスビルダー
 */
protected ResponseBuilder getPostResponseBuilder(
        OEntity ent,
        MediaType outputFormat,
        String responseStr,
        UriInfo resUriInfo,
        String key) {
    ResponseBuilder rb = Response.status(HttpStatus.SC_CREATED).entity(responseStr).type(outputFormat)
            .header(HttpHeaders.LOCATION, resUriInfo.getBaseUri().toASCIIString()
                    + getEntitySetName() + key)
            .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);

    // 応答にETAGを付与
    if (ent instanceof OEntityWrapper) {
        OEntityWrapper oew2 = (OEntityWrapper) ent;
        String etag = oew2.getEtag();
        if (etag != null) {
            rb = rb.header(HttpHeaders.ETAG, "W/\"" + etag + "\"");
        }
    }
    return rb;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:31,代码来源:AbstractODataResource.java

示例5: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    StorageClusterVersionModel model = new StorageClusterVersionModel();
    model.setVersion(servlet.getAdmin().getClusterStatus().getHBaseVersion());
    ResponseBuilder response = Response.ok(model);
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (IOException e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return Response.status(Response.Status.SERVICE_UNAVAILABLE)
      .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
      .build();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:StorageClusterVersionResource.java

示例6: insert

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的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: update

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

	try {
		AirConditioningDao.getInstance().update(air);
		builder.status(Response.Status.OK).entity(air);

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

}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:20,代码来源:AirConditioningController.java

示例8: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    ResponseBuilder response = Response.ok(getTableList());
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (Exception e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return processException(e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:RootResource.java

示例9: StringBuilder

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
/**
 * LocationヘッダのURLのフラグメントにerror_descriptionが存在しない場合チェックがtrueを返すこと.
 * @throws UnsupportedEncodingException URLのエラー
 */
@Test
public void LocationヘッダのURLのフラグメントにerror_descriptionが存在しない場合チェックがtrueを返すこと() throws UnsupportedEncodingException {
    ResponseBuilder rb = Response.status(Status.FOUND).type(MediaType.APPLICATION_JSON_TYPE);
    StringBuilder sbuf = new StringBuilder(UrlUtils.cellRoot("authz") + "#" + OAuth2Helper.Key.ERROR + "=");
    sbuf.append(URLEncoder.encode("Server Connection Error.", "utf-8"));
    sbuf.append("&" + OAuth2Helper.Key.STATE + "=");
    sbuf.append(URLEncoder.encode("0000000111", "utf-8"));
    sbuf.append("&" + OAuth2Helper.Key.CODE + "=");
    sbuf.append(URLEncoder.encode("PR503-SV-0002", "utf-8"));
    rb.header(HttpHeaders.LOCATION, sbuf.toString());

    Response res = rb.entity("").build();
    AuthzEndPointResourceMock authz = new AuthzEndPointResourceMock(null, null);
    assertTrue(authz.isSuccessAuthorization(res));
}
 
开发者ID:personium,项目名称:personium-core,代码行数:20,代码来源:AuthzTest.java

示例10: createFolderPost

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的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

示例11: headFile

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
@Override
public Response headFile(HttpHeaders headers, String uuid, int version, String path)
{
	ItemId itemId = new ItemId(uuid, version);
	checkViewItem(itemId);

	ItemFile itemFile = itemFileService.getItemFile(itemId, null);
	ResponseBuilder builder = makeBlobHeaders(itemFile, path);

	String contentType = mimeService.getMimeTypeForFilename(path);
	builder.type(contentType);

	if( !fileSystemService.fileExists(itemFile, path) )
	{
		return Response.status(Status.NOT_FOUND).build();
	}
	return builder.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:ItemResourceImpl.java

示例12: toResponse

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
@Override
public Response toResponse(DefaultOptionsMethodException arg0)
{
	final ResponseBuilder response = Response.ok();
	response.header("Access-Control-Allow-Origin", "*");
	response.header("Access-Control-Allow-Methods", ALL_METHODS);
	response.header("Allow", ALL_METHODS);
	response.header("Access-Control-Allow-Headers", "X-Authorization, Content-Type");
	response.header("Access-Control-Max-Age", TimeUnit.DAYS.toSeconds(1));
	response.header("Access-Control-Expose-Headers", "Location");
	return response.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:DefaultOptionsExceptionMapper.java

示例13: redirectToHome

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
/**
 * Redirect to main home page.
 */
protected ResponseBuilder redirectToHome() throws URISyntaxException {
	final String user = securityHelper.getLogin();
	if (isAnonymous(user)) {
		// We know nothing about the user
		return redirectToUrl(configuration.get("redirect.external.home"));
	}

	// Guess the company of this user
	if (companyResource.isUserInternalCommpany()) {
		// Internal user, redirect to the default URL of corporate user
		return redirectToUrl(configuration.get("redirect.internal.home"));
	}

	// Not internal user, redirect to the other home page
	return redirectToUrl(configuration.get("redirect.external.home"));

}
 
开发者ID:ligoj,项目名称:plugin-redirect,代码行数:21,代码来源:RedirectResource.java

示例14: createMessage

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
/**
 * 受信/送信メッセージEntityを作成する.
 * @param uriInfo URL情報
 * @param reader リクエストボディ
 * @return response情報
 */
protected Response createMessage(UriInfo uriInfo,
        Reader reader) {

    // response用URLに__ctlを追加する
    UriInfo resUriInfo = PersoniumCoreUtils.createUriInfo(uriInfo, 2, "__ctl");

    // Entityの作成を Producerに依頼
    OEntityWrapper oew = getOEntityWrapper(reader, odataResource, CtlSchema.getEdmDataServicesForMessage().build());
    EntityResponse res = getOdataProducer().createEntity(getEntitySetName(), oew);

    // レスポンスボディを生成する
    OEntity ent = res.getEntity();
    MediaType outputFormat = MediaType.APPLICATION_JSON_TYPE;
    List<MediaType> contentTypes = new ArrayList<MediaType>();
    contentTypes.add(MediaType.APPLICATION_JSON_TYPE);
    String key = AbstractODataResource.replaceDummyKeyToNull(ent.getEntityKey().toKeyString());
    String responseStr = renderEntityResponse(resUriInfo, res, "json", contentTypes);

    // 制御コードのエスケープ処理
    responseStr = escapeResponsebody(responseStr);

    ResponseBuilder rb = getPostResponseBuilder(ent, outputFormat, responseStr, resUriInfo, key);
    return rb.build();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:31,代码来源:MessageODataResource.java

示例15: putForUpdate

import javax.ws.rs.core.Response.ResponseBuilder; //导入依赖的package包/类
@Override
public ResponseBuilder putForUpdate(final String contentType, final InputStream inputStream, String etag) {
    // ロック
    Lock lock = this.lock();
    try {
        // 更新には、更新対象のDavNodeが存在するため、更新対象のDavNodeをリロードして存在確認する。
        // 更新対象のDavNodeが存在しない場合:
        // ・更新対象の親DavNodeが存在しない場合:親ごと消えているため404を返却
        // ・更新対象の親DavNodeが存在する場合:他のリクエストによって削除されたたため、作成処理を実行
        // 更新対象のDavNodeが存在する場合:更新処理を実行
        this.load();
        if (this.metaFile == null) {
            this.parent.load();
            if (this.parent.metaFile == null) {
                throw getNotFoundException().params(this.parent.getUrl());
            }
            return this.doPutForCreate(contentType, inputStream);
        }
        return this.doPutForUpdate(contentType, inputStream, etag);
    } finally {
        // ロックを開放する
        lock.release();
        log.debug("unlock2");
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:26,代码来源:DavCmpFsImpl.java


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