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


Java ResponseBuilderImpl类代码示例

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


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


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