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


Java EmptyRepresentation类代码示例

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


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

示例1: delete

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@Override
protected Representation delete( Variant variant )
    throws ResourceException
{
    Usecase usecase = UsecaseBuilder.newUsecase( "Remove entity" );
    EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( module, usecase, SystemTime.now() );
    try
    {
        EntityReference reference = EntityReference.create( identity );
        uow.entityStateOf( module, reference ).remove();
        uow.applyChanges().commit();
        getResponse().setStatus( Status.SUCCESS_NO_CONTENT );
    }
    catch( EntityNotFoundException e )
    {
        uow.discard();
        getResponse().setStatus( Status.CLIENT_ERROR_NOT_FOUND );
    }

    return new EmptyRepresentation();
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:22,代码来源:EntityResource.java

示例2: post

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@Override
protected Representation post( Representation entity, Variant variant )
    throws ResourceException
{
    try
    {
        /*
         * InputStream in = entity.getStream(); ObjectInputStream oin = new ObjectInputStream( in ); String reference
         * = oin.readUTF(); Usecase usecase = (Usecase) oin.readUnshared(); MetaInfo unitofwork = (MetaInfo)
         * oin.readUnshared(); Iterable<UnitOfWorkEvent> events = (Iterable<UnitOfWorkEvent>) oin.readUnshared();
         *
         * // Store state try { entityStore.apply( reference, events, usecase, unitofwork ).commit(); } catch(
         * ConcurrentEntityStateModificationException e ) { throw new ResourceException(
         * Status.CLIENT_ERROR_CONFLICT ); }
         */
    }
    catch( Exception e )
    {
        throw new ResourceException( e );
    }

    return new EmptyRepresentation();
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:EntitiesResource.java

示例3: writeRequest

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@Override
public boolean writeRequest(Object requestObject, Request request) throws ResourceException
{
   if (requestObject == null)
   {
      if (!Method.GET.equals(request.getMethod()))
         request.setEntity(new EmptyRepresentation());

      return true;
   }

   if (requestObject instanceof Representation)
   {
      request.setEntity((Representation) requestObject);
      return true;
   }

   for (RequestWriter requestWriter : requestWriters)
   {
      if (requestWriter.writeRequest(requestObject, request))
         return true;
   }

   return false;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:26,代码来源:RequestWriterDelegator.java

示例4: createRepresentationFromBody

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
protected Representation createRepresentationFromBody(Exchange exchange, MediaType mediaType) {
    Object body = exchange.getIn().getBody();
    if (body == null) {
        return new EmptyRepresentation();
    }

    // unwrap file
    if (body instanceof WrappedFile) {
        body = ((WrappedFile) body).getFile();
    }

    if (body instanceof InputStream) {
        return new InputRepresentation((InputStream) body, mediaType);
    } else if (body instanceof File) {
        return new FileRepresentation((File) body, mediaType);
    } else if (body instanceof byte[]) {
        return new ByteArrayRepresentation((byte[]) body, mediaType);
    } else if (body instanceof String) {
        return new StringRepresentation((CharSequence) body, mediaType);
    }

    // fallback as string
    body = exchange.getIn().getBody(String.class);
    if (body != null) {
        return new StringRepresentation((CharSequence) body, mediaType);
    } else {
        return new EmptyRepresentation();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:DefaultRestletBinding.java

示例5: login

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
public Representation login( String name, String password )
{
    context( Login.class ).login( name, password );

    EmptyRepresentation rep = new EmptyRepresentation();
    Response.getCurrent().getCookieSettings().add( "user", name );
    return rep;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:9,代码来源:LoginResource.java

示例6: showPage

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
/**
   * Entry point to the AuthPageResource. The AuthorizationResource dispatches
   * the call to this method. Should also be invoked by an eventual HTML page
   * FORM. In the from HTTP GET should be used and a result parameter: action
   * = Accept results in approving requested scope while action = Reject
   * results in a rejection error back to the requestor.
   * 
   * AuthPageResourceへのエントリポイント。 
* AuthorizationResourceは、このメソッドへの呼び出しをディスパッチします。 
* また、最終的なHTMLページ形式で起動する必要があります。 
* HTTPからのGETを使用して、結果パラメータれるべきである。 
* 
* :アクション 
* = 要求されたスコープのアクションしばらく承認に結果を受け入れる = 
* 戻って要求元に拒否通知エラーで結果を拒否します。
   * 
   * @return HTML page with the graphical policy page
   */
  public static Representation showPage() throws OAuthException {
  	
  	/*
	上記htmlを表示、またはsubmitされた タイミングで実行される
  	*/

      String action = getQuery().get("action").get(0);
      
      // Came back after user interacted with the page
      if (action != null) {										// submitされたときはここを通る
          Map<String, ArrayList<String>> query = getQuery();
          ArrayList<String> strscopes = query.get("scope");
          
          /* Scope.toString()で変換した文字列配列をScope[]に変換する */
          String[] strScopes = strscopes.toArray(new String[0]);
          Scope[] scopes = ScopeUtil.stringToScope(strScopes);
          
          /* アプリケーション名を取得 */
          String applicationName = null;
          ArrayList<String> strApplicationNames = query.get(APPLICATION_NAME);
          if (strApplicationNames != null && strApplicationNames.size() > 0) {
              applicationName = strApplicationNames.get(0);
          }

          RedirectRepresentation redirectRepresentation = handleAction(action, scopes, applicationName);	// この中でセッションを保存し認可コードを取得する
          return redirectRepresentation;
      }
      return new EmptyRepresentation(); // Will redirect
  }
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:48,代码来源:AuthPageServerResource.java

示例7: toObject

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T toObject(Representation source, Class<T> target, UniformResource resource) throws IOException {
    Object result = null;

    // The source for the XStream conversion
    XstreamRepresentation<?> xstreamSource = null;

    if (source instanceof EmptyRepresentation) {
        // nothing to do
    } else if (source instanceof XstreamRepresentation) {
        xstreamSource = ((XstreamRepresentation) source);
    } else if (VARIANT_JSON.isCompatible(source)) {
        xstreamSource = create(source);
    } else if (VARIANT_APPLICATION_ALL_XML.isCompatible(source) || VARIANT_APPLICATION_XML.isCompatible(source)
            || VARIANT_TEXT_XML.isCompatible(source)) {
        xstreamSource = create(source);
    }

    if (xstreamSource != null) {
        // Handle the conversion
        if ((target != null) && XstreamRepresentation.class.isAssignableFrom(target)) {
            result = xstreamSource;
        } else {
            if (target != null) {
                // XStream 1.3.1 does not process annotations when called
                // using fromXML(InputStream) despite autoProcessAnnotations
                // being set to "true". This call forces the processing.
                xstreamSource.getXstream().processAnnotations(target);
            }

            result = xstreamSource.getObject();
        }
    }

    return (T) result;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:38,代码来源:XstreamConverter.java

示例8: beforeHandle

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@Override
protected int beforeHandle(Request request, Response response) {
    if (Method.OPTIONS.equals(request.getMethod())) {
        final Map<String, Object> responseAttributes = response.getAttributes();
        @SuppressWarnings("unchecked")
        Series<Header> responseHeaders = (Series<Header>) responseAttributes.get("org.restlet.http.headers");
        
        // if(MyConfig.getAllow​edOrigins().contains​(origin)) {
        if (responseHeaders == null) {
            responseHeaders = new Series<Header>(Header.class);
            response.getAttributes().put("org.restlet.http.headers", responseHeaders);
        }
        responseHeaders.add("Access-Control-Allow-Origin", 
                master.configuration.getStringProperty("Access-Control-Allow-Origin","*"));
        responseHeaders.add("Access-Control-Allow-Methods",
                master.configuration.getStringProperty("Access-Control-Allow-Methods", "GET,POST,DELETE,OPTIONS"));
        responseHeaders.add("Access-Control-Allow-Headers", 
                  master.configuration.getStringProperty("Access-Control-Allow-Headers",
                          "Accept,Accept-Version,Authorization,Content-Length,Content-MD5,Content-Type,Date,"
                        + "Origin,X-Access-Token,X-Api-Version,X-CSRF-Token,X-File-Name,X-Requested-With"));
        responseHeaders.add("Access-Control-Allow-Credentials", "true");
        // responseHeaders.add("Access-Control-Max-Age", "60");
        response.setEntity(new EmptyRepresentation());
        return SKIP;
        //   }
    }

    return super.beforeHandle(request, response);
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:30,代码来源:OriginFilter.java

示例9: handle

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
public Representation handle() throws ResourceException {
    Request request = getRequest();
    Response response = getResponse();

    String redirectURL;
    if (redirectPath != null) {
        redirectURL = RequestUtil.constructAbsolutePath(request, redirectPath);
    } else {
        redirectURL = RequestUtil.constructAbsolutePath(request, defaultRedirectPath);
    }
    response.redirectSeeOther(redirectURL);

    setResponse(response);
    return new EmptyRepresentation();
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:16,代码来源:RootRedirectResource.java

示例10: score

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@Override
public <T> float score(Representation source, Class<T> target,
        Resource resource) {
    float result = -1.0F;

    if (target != null) {
        if (target.isAssignableFrom(source.getClass())) {
            result = 1.0F;
        } else if (String.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (StringRepresentation.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (EmptyRepresentation.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (File.class.isAssignableFrom(target)) {
            if (source instanceof FileRepresentation) {
                result = 1.0F;
            }
        } else if (Form.class.isAssignableFrom(target)) {
            if (MediaType.APPLICATION_WWW_FORM.isCompatible(source
                    .getMediaType())) {
                result = 1.0F;
            } else {
                result = 0.5F;
            }
        } else if (InputStream.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (InputRepresentation.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (Reader.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (ReaderRepresentation.class.isAssignableFrom(target)) {
            result = 1.0F;
        } else if (Serializable.class.isAssignableFrom(target)
                || target.isPrimitive()) {
            if (ObjectRepresentation.VARIANT_OBJECT_BINARY_SUPPORTED
                    && MediaType.APPLICATION_JAVA_OBJECT.equals(source
                            .getMediaType())) {
                result = 1.0F;
            } else if (ObjectRepresentation.VARIANT_OBJECT_BINARY_SUPPORTED
                    && MediaType.APPLICATION_JAVA_OBJECT
                            .isCompatible(source.getMediaType())) {
                result = 0.6F;
            } else if (ObjectRepresentation.VARIANT_OBJECT_XML_SUPPORTED
                    && MediaType.APPLICATION_JAVA_OBJECT_XML.equals(source
                            .getMediaType())) {
                result = 1.0F;
            } else if (ObjectRepresentation.VARIANT_OBJECT_XML_SUPPORTED
                    && MediaType.APPLICATION_JAVA_OBJECT_XML
                            .isCompatible(source.getMediaType())) {
                result = 0.6F;
            } else {
                result = 0.5F;
            }
        }
    } else if (source instanceof ObjectRepresentation<?>) {
        result = 1.0F;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:62,代码来源:DefaultConverter.java

示例11: beforeHandle

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
@Override
protected int beforeHandle(Request request, Response response) {
	
	@SuppressWarnings("unchecked")
	Series<Header> requestHeaders = request.getHeaders();
	// indication of the domain from where the request is made, if present
	String origin = requestHeaders.getFirstValue(ORIGIN, true);
	// get hold of responses headers
	@SuppressWarnings("unchecked")
	Series<Header> responseHeaders = (Series<Header>) response.getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);
	
	if (Method.OPTIONS.equals(request.getMethod())) {
		// the browser is sending a pre-flight resquest, asking whether it is allowed
		// to request the resource
		if (responseHeaders == null) {
			responseHeaders = new Series<Header>(Header.class);
			response.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,responseHeaders);
		}
		
		// tell we allow GET,POST,DELETE and OPTIONS from everywhere
		responseHeaders.add("Access-Control-Allow-Origin", "*");
		responseHeaders.add("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS");
		responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
		// tell to add cookies in cors request . not needed now
		//responseHeaders.add("Access-Control-Allow-Credentials", "true");
		// note: chrome ignore of max age is > 10 minutes (600 seconds)
		responseHeaders.add("Access-Control-Max-Age", "600");
		response.setEntity(new EmptyRepresentation());
		return SKIP;
	} else {
		// the request is not a CORS preflight, check if Origin header is present.
		if( origin != null && !origin.isEmpty()){
			// it is a simple CORS request or a request made after a successull preflight CORS request
			// we respond in the same way.
			if (responseHeaders == null) {
				responseHeaders = new Series<Header>(Header.class);
				response.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,responseHeaders);
			}
			
			responseHeaders.add("Access-Control-Allow-Origin", origin);
			responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
		}
	}

	return super.beforeHandle(request, response);
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:47,代码来源:CorsFilter.java

示例12: convert

import org.restlet.representation.EmptyRepresentation; //导入依赖的package包/类
public Representation convert(final LobHandler handler, final CcLob data) throws Exception {
    
    if (data.getValue() == null) {
        return new EmptyRepresentation();
    }
    
    switch (handler.getMdColumn().getType()) {
        case BLOB:
            
            return new OutputRepresentation(handler.getMediaType()) {
                
                @Override
                public void write(OutputStream out) throws IOException {
                    out.write(data.getValue());
                }
            };
            
        case CLOB:
            
            return new StringRepresentation(new String(data.getValue()), handler.getMediaType());
            
        default:
            
            throw new ClientErrorException(Status.CLIENT_ERROR_BAD_REQUEST);
            
    }
    
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:29,代码来源:LobConverter.java


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