• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ResponseBuilderImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getAlbumsByArtistId

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
@GET
@Path( "{authorId:\\d+}/albums" )
@Produces( { APPLICATION_XML, APPLICATION_JSON } )
public Collection<Album> getAlbumsByArtistId( @PathParam( "authorId" ) Long authorId )
{
    try
    {
        return getQueryRunner().query( getQuery( "album.selectAllByAuthor" ),
                                       albumListHandler, authorId );
    }
    catch ( SQLException e )
    {
        throw new WebApplicationException( new ResponseBuilderImpl()
                                          .entity( toErrorMessage( e ) )
                                          .status( Response.Status.INTERNAL_SERVER_ERROR )
                                          .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:19,代码来源:AuthorService.java


示例2: getAlbumByArtistIds

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
@GET
@Path( "{authorId:\\d+}/albums/{albumId:\\d+}" )
@Produces( { APPLICATION_XML, APPLICATION_JSON } )
public Album getAlbumByArtistIds( @PathParam( "authorId" ) Long authorId,
                                  @PathParam( "albumId" ) Long albumId )
{
    try
    {
        return getQueryRunner().query( getQuery( "album.selectByAuthor" ),
                                       albumListHandler.getEntityHandler(), authorId, albumId );
    }
    catch ( SQLException e )
    {
        throw new WebApplicationException( new ResponseBuilderImpl()
                                          .entity( toErrorMessage( e ) )
                                          .status( Response.Status.INTERNAL_SERVER_ERROR )
                                          .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:20,代码来源:AuthorService.java


示例3: getTracksByArtisAndAlbumIds

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
@GET
@Path( "{authorId:\\d+}/albums/{albumId:\\d+}/tracks" )
@Produces( { APPLICATION_XML, APPLICATION_JSON } )
public Collection<Track> getTracksByArtisAndAlbumIds( @PathParam( "authorId" ) Long authorId,
                                                      @PathParam( "albumId" ) Long albumId )
{
    try
    {
        return getQueryRunner().query( getQuery( "track.selectAllByAlbumAndAuthor" ),
                                       trackListHandler, authorId, albumId );
    }
    catch ( SQLException e )
    {
        throw new WebApplicationException( new ResponseBuilderImpl()
                                          .entity( toErrorMessage( e ) )
                                          .status( Response.Status.INTERNAL_SERVER_ERROR )
                                          .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:20,代码来源:AuthorService.java


示例4: getById

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
protected final E getById( String queryId, long id )
{
    try
    {
        E entity = queryRunner.query( getQuery( queryId ), entityListHandler.getEntityHandler(), id );

        if ( entity == null )
        {
            throw new WebApplicationException( new ResponseBuilderImpl()
                                              .status( Response.Status.NOT_FOUND )
                                              .build() );
        }

        return entity;
    }
    catch ( SQLException e )
    {
        throw new WebApplicationException( new ResponseBuilderImpl()
                                           .entity( toErrorMessage( e ) )
                                           .status( Response.Status.INTERNAL_SERVER_ERROR )
                                           .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:24,代码来源:AbstractService.java


示例5: delete

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
protected final Response delete( String queryId, Long id )
{
    try
    {
        int deleted = queryRunner.update( getQuery( queryId ), id );

        Status status;
        if ( deleted != 0 )
        {
            status = Status.OK;
        }
        else
        {
            status = Status.NOT_FOUND;
        }

        return Response.status( status ).build();
    }
    catch ( SQLException e )
    {
        throw new WebApplicationException( new ResponseBuilderImpl()
                                          .entity( toErrorMessage( e ) )
                                          .status( Response.Status.INTERNAL_SERVER_ERROR )
                                          .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:27,代码来源:AbstractService.java


示例6: generateAgreementFromTemplate

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
@GET
@Path("commands/fromtemplate")
@Produces(MediaType.APPLICATION_XML)
public Response generateAgreementFromTemplate(@QueryParam("templateId") String templateId) throws JAXBException {
    ITemplate template = templateDAO.getByUuid(templateId);

    Template wsagTemplate;
    try {
        wsagTemplate = templateParser.getWsagObject(template.getText());
    } catch (ParserException e) {
        throw new SlaGeneratorException(e.getMessage(), e);
    }
    Agreement wsagAgreement = new AgreementGenerator(wsagTemplate).generate();
    logger.debug(JaxbUtils.toString(wsagAgreement));
    
    ResponseBuilderImpl builder = new ResponseBuilderImpl();
    builder.status(HttpStatus.OK.value());
    builder.entity(wsagAgreement);
    return builder.build();
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:21,代码来源:SeacloudsRest.java


示例7: toResponse

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Response toResponse(Throwable thrownException) {
  ResponseBuilder builder = new ResponseBuilderImpl();
  builder.type(MediaType.APPLICATION_JSON);

  Status status = null;
  if (thrownException instanceof WebApplicationException) {
    WebApplicationException webAppException = (WebApplicationException) thrownException;
    status = Status.fromStatusCode(webAppException.getResponse().getStatus());
  }
  if (status == null) {
    status = Status.INTERNAL_SERVER_ERROR;
  }
  if (status == Status.INTERNAL_SERVER_ERROR) {
    LOGGER.error("ERROR", thrownException);
  }
  builder.status(status);
  builder.entity(new ExceptionWrapper(status, thrownException));

  return builder.build();
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:25,代码来源:GeneralExceptionMapper.java


示例8: buildResponsePOST

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
protected Response buildResponsePOST(HttpStatus status, MessageResponse message, String location) {
	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.header("location", location);
	builder.status(status.value());
	builder.entity(message);
	return builder.build();		
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:8,代码来源:AbstractSLARest.java


示例9: getAll

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
protected final Collection<E> getAll( String queryId )
{
    try
    {
        return queryRunner.query( getQuery( queryId ), entityListHandler );
    }
    catch ( SQLException e )
    {
        e.printStackTrace();
        throw new WebApplicationException( new ResponseBuilderImpl()
                                           .entity( toErrorMessage( e ) )
                                           .status( Response.Status.INTERNAL_SERVER_ERROR )
                                           .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:16,代码来源:AbstractService.java


示例10: insertOrUpdate

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
protected final Response insertOrUpdate( String queryId, Object...params )
{
    try
    {
        int updated = queryRunner.update( getQuery( queryId ), params );

        Status status;
        if ( updated != 0 )
        {
            status = Status.CREATED;
        }
        else
        {
            status = Status.NOT_FOUND;
        }

        return Response.status( status ).build();
    }
    catch ( SQLException e )
    {
        e.printStackTrace();

        throw new WebApplicationException( new ResponseBuilderImpl()
                                          .entity( toErrorMessage( e ) )
                                          .status( Response.Status.INTERNAL_SERVER_ERROR )
                                          .build() );
    }
}
 
开发者ID:davidefalessi,项目名称:falessi-tunes,代码行数:29,代码来源:AbstractService.java


示例11: authenticatedUser

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public AccountModel authenticatedUser(AccountModel oAccount)
{
 try
 {
	//create a new session and begin the transaction
    Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//create the query in HQL language
	String strQuery = String.format("FROM AccountModel WHERE (username = '%s' AND password = '%s')", oAccount.getUsername() , oAccount.getPassword());
	Query  hibernateQuery = hibernateSession.createQuery(strQuery);
	
	oAccount = null;
	
	//retrieve the unique result, if there is a result at all
	oAccount = (AccountModel) hibernateQuery.uniqueResult();
	
	if(oAccount == null)
	{
   		throw new WebApplicationException(Response.Status.UNAUTHORIZED);
	}
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	//return the <AuthenticationModel> of the authenticated user, or null if authentication failed
	return oAccount;
}
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:41,代码来源:SQLITEController.java


示例12: postAccount

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public AccountModel postAccount(AccountModel oAccount)
{
 try
 {
	//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//insert the new <ResourceName> to database 
	int accountId = (Integer) hibernateSession.save(oAccount);
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	//returh the <accountModelName> with updated <accountModelName>Id
	oAccount.setAccountId(accountId);
	return oAccount;
}
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:31,代码来源:SQLITEController.java


示例13: getAccount

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public AccountModel getAccount(AccountModel oAccount)
{
 try
 {
		//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//find the  <ResourceName> in the database 
	oAccount = (AccountModel) hibernateSession.get(AccountModel.class, oAccount.getAccountId());

	if(oAccount == null)
	{
   		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	return oAccount;
 }		
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:34,代码来源:SQLITEController.java


示例14: putAccount

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public AccountModel putAccount(AccountModel oAccount)
{
 try
 {
	//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//update the  <ResourceName> to database 
	hibernateSession.update(oAccount);
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	return oAccount;
 }		
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:29,代码来源:SQLITEController.java


示例15: deleteAccount

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public AccountModel deleteAccount(AccountModel oAccount)
{
 try
 {
 		//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();

	//find the  <ResourceName> in the database 
       oAccount = (AccountModel) hibernateSession.get(AccountModel.class, oAccount.getAccountId());
       
	if(oAccount == null)
	{
   		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
       
       oAccount.deleteAllCollections(hibernateSession);
	
	hibernateSession.delete(oAccount);
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	return oAccount;
 }		
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:37,代码来源:SQLITEController.java


示例16: postRESTService

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public RESTServiceModel postRESTService(RESTServiceModel oRESTService)
{
	try
	{
		//create a new session and begin the transaction
		Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
		Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
		//insert the new <ResourceName> to database
		int RESTServiceId = (Integer) hibernateSession.save(oRESTService);

		//commit and terminate the session
		hibernateTransaction.commit();
		hibernateSession.close();

	
		//return the <accountModelName> with updated <accountModelName>Id
		oRESTService.setRESTServiceId(RESTServiceId);
		return oRESTService;
	}
	catch (HibernateException exception)
	{
		System.out.println(exception.getCause());

		ResponseBuilderImpl builder = new ResponseBuilderImpl();
		builder.status(Response.Status.BAD_REQUEST);
		builder.entity(String.format("%s",exception.getCause()));
		Response response = builder.build();
		throw new WebApplicationException(response);
	}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:32,代码来源:SQLITEController.java


示例17: getRESTService

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public RESTServiceModel getRESTService(RESTServiceModel oRESTService)
{
 try
 {
		//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//find the  <ResourceName> in the database 
	oRESTService = (RESTServiceModel) hibernateSession.get(RESTServiceModel.class, oRESTService.getRESTServiceId());

	if(oRESTService == null)
	{
   		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	return oRESTService;
 }		
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:34,代码来源:SQLITEController.java


示例18: deleteRESTService

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public RESTServiceModel deleteRESTService(RESTServiceModel oRESTService)
{
 try
 {
 		//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();

	//find the  <ResourceName> in the database 
       oRESTService = (RESTServiceModel) hibernateSession.get(RESTServiceModel.class, oRESTService.getRESTServiceId());

	if(oRESTService == null)
	{
   		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
       
       oRESTService.deleteAllCollections(hibernateSession);
	hibernateSession.delete(oRESTService);
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	return oRESTService;
}
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:36,代码来源:SQLITEController.java


示例19: putRESTService

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public RESTServiceModel putRESTService(RESTServiceModel oRESTService)
{
 try
 {
	//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//update the  <ResourceName> to database 
	hibernateSession.update(oRESTService);
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	return oRESTService;
 }		
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:29,代码来源:SQLITEController.java


示例20: postResource

import com.sun.jersey.core.spi.factory.ResponseBuilderImpl; //导入依赖的package包/类
public ResourceModel postResource(ResourceModel oResource)
{
 try
 {
	//create a new session and begin the transaction
	Session hibernateSession = HibernateUtil.getSessionFactory().openSession();
	Transaction hibernateTransaction = hibernateSession.beginTransaction();
	
	//insert the new <ResourceName> to database 
	int resourceId = (Integer) hibernateSession.save(oResource);
	
	//commit and terminate the session
	hibernateTransaction.commit();
	hibernateSession.close();
	
	//return the <accountModelName> with updated <accountModelName>Id
	oResource.setResourceId(resourceId);
	return oResource;
 }
catch (HibernateException exception)
{
	System.out.println(exception.getCause());

	ResponseBuilderImpl builder = new ResponseBuilderImpl();
	builder.status(Response.Status.BAD_REQUEST);
	builder.entity(String.format("%s",exception.getCause()));
	Response response = builder.build();
	throw new WebApplicationException(response);
}
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:31,代码来源:SQLITEController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AMapNaviLocation类代码示例发布时间:2022-05-22
下一篇:
Java Base64类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap