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


Java InputRepresentation类代码示例

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


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

示例1: getProcessDefinitions

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Get
public InputRepresentation getProcessDefinitions() {
  if(authenticate() == false) return null;
  
  String processDefinitionId = (String) getRequest().getAttributes().get("processDefinitionId");
  Object form = ActivitiUtil.getFormService().getRenderedStartForm(processDefinitionId);
  InputStream is = null;
  if (form != null && form instanceof String) {
    is = new ByteArrayInputStream(((String) form).getBytes());
  }
  else if (form != null && form instanceof InputStream) {
    is = (InputStream) form;
  }
  if (is != null) {
    InputRepresentation output = new InputRepresentation(is);
    return output;
  
  } else if (form != null){
    throw new ActivitiException("The form for process definition '" + processDefinitionId + "' failed to render.");
  
  } else {
    throw new ActivitiException("The form for process definition '" + processDefinitionId + "' cannot be rendered using the rest api.");
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:25,代码来源:ProcessDefinitionFormResource.java

示例2: execute

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Get
public InputRepresentation execute() {
  String path = getRequest().getResourceRef().getPath();
  if(path.contains("/deployment") && path.contains("/resource")) {
    String deploymentId = path.substring(path.indexOf("/deployment/") + 12, path.indexOf("/", path.indexOf("/deployment/") + 12));
    String resourceName = path.substring(path.indexOf("/resource/") + 10);
    InputStream resource = ActivitiUtil.getRepositoryService().getResourceAsStream(deploymentId, resourceName);
    if (resource != null) {
      InputRepresentation output = new InputRepresentation(resource);
      return output;
    } else {
      throw new ActivitiException("There is no resource with name '" + resourceName + "' for deployment with id '" + deploymentId + "'.");
    }
  } else {
    throw new ActivitiException("No router defined");
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:18,代码来源:DefaultResource.java

示例3: getTaskForm

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Get
public InputRepresentation getTaskForm() {
  if(authenticate() == false) return null;
  
  String taskId = (String) getRequest().getAttributes().get("taskId");
  Object form = ActivitiUtil.getFormService().getRenderedTaskForm(taskId);
  InputStream is = null;
  if (form != null && form instanceof String) {
    is = new ByteArrayInputStream(((String) form).getBytes());
  }
  else if (form != null && form instanceof InputStream) {
    is = (InputStream) form;
  }
  if (is != null) {
    InputRepresentation output = new InputRepresentation(is);
    return output;
  
  } else if (form != null){
    throw new ActivitiException("The form for task '" + taskId + "' cannot be rendered using the rest api.");
  
  } else {
    throw new ActivitiException("There is no form for task '" + taskId + "'.");
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:25,代码来源:TaskFormResource.java

示例4: processUpload

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
private void processUpload(Exchange exchange) throws Exception {
	logger.debug("Begin import:"+ exchange.getIn().getHeaders());
	if(exchange.getIn().getBody()!=null){
		logger.debug("Body class:"+ exchange.getIn().getBody().getClass());
	}else{
		logger.debug("Body class is null");
	}
	//logger.debug("Begin import:"+ exchange.getIn().getBody());
	MediaType mediaType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, MediaType.class);
	InputRepresentation representation = new InputRepresentation((InputStream) exchange.getIn().getBody(), mediaType);
	logger.debug("Found MIME:"+ mediaType+", length:"+exchange.getIn().getHeader(Exchange.CONTENT_LENGTH, Integer.class));
	//make a reply
	Json reply = Json.read("{\"files\": []}");
	Json files = reply.at("files");
	
	try {
		List<FileItem> items = new RestletFileUpload(new DiskFileItemFactory()).parseRepresentation(representation);
		logger.debug("Begin import files:"+items);
		for (FileItem item : items) {
			if (!item.isFormField()) {
				InputStream inputStream = item.getInputStream();
				
				Path destination = Paths.get(Util.getConfigProperty(STATIC_DIR)+Util.getConfigProperty(MAP_DIR)+item.getName());
				logger.debug("Save import file:"+destination);
				long len = Files.copy(inputStream, destination, StandardCopyOption.REPLACE_EXISTING);
				Json f = Json.object();
				f.set("name",item.getName());
				f.set("size",len);
				files.add(f);
				install(destination);
			}
		}
	} catch (FileUploadException | IOException e) {
		logger.error(e.getMessage(),e);
	}
	exchange.getIn().setBody(reply);
}
 
开发者ID:SignalK,项目名称:signalk-server-java,代码行数:38,代码来源:UploadProcessor.java

示例5: getDefinitionDiagram

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Get
public InputRepresentation getDefinitionDiagram() {
  if(authenticate() == false) return null;
  
  String deploymentId = (String) getRequest().getAttributes().get("deploymentId");
  String resourceName = (String) getRequest().getAttributes().get("resourceName");
  
  if(deploymentId == null) {
    throw new ActivitiException("No deployment id provided");
  }

  final InputStream resourceStream = ActivitiUtil.getRepositoryService().getResourceAsStream(
      deploymentId, resourceName);

  if (resourceStream == null) {
    throw new ActivitiException("No resource with name " + resourceName + " could be found");
  }

  InputRepresentation output = new InputRepresentation(resourceStream);
  return output;
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:22,代码来源:DeploymentArtifactResource.java

示例6: getPicture

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Get
public InputRepresentation getPicture() {
  if(authenticate() == false) return null;
  
  String userId = (String) getRequest().getAttributes().get("userId");
  if(userId == null) {
    throw new ActivitiException("No userId provided");
  }
  Picture picture = ActivitiUtil.getIdentityService().getUserPicture(userId);
  
  String contentType = picture.getMimeType();
  MediaType mediatType = MediaType.IMAGE_PNG;
  if(contentType != null) {
    if(contentType.contains(";")) {
      contentType = contentType.substring(0, contentType.indexOf(";"));
    }
    mediatType = MediaType.valueOf(contentType);
  }
  InputRepresentation output = new InputRepresentation(picture.getInputStream(), mediatType);
  getResponse().getCacheDirectives().add(CacheDirective.maxAge(28800));
  
  return output;
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:24,代码来源:UserPictureResource.java

示例7: doPut

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Override
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException{
    Representation rep = cr.toXml();
    
    //Empty Community with new CommunityResource
    Community origComm = mock(Community.class);
    when(origComm.getID()).thenReturn(2);
    when(origComm.getName()).thenReturn("");
    when(origComm.getType()).thenReturn(0);
    when(origComm.getMetadata("short_description")).thenReturn("");
    when(origComm.getMetadata("introductory_text")).thenReturn("");
    when(origComm.getMetadata("copyright_text")).thenReturn("");
    when(origComm.getMetadata("side_bar_text")).thenReturn("");
    when(origComm.getLogo()).thenReturn(null);
    CommunityResource originalCr = new CommunityResource(origComm, 2);
    
    InputRepresentation ir = new InputRepresentation(rep.getStream());
    
    //Edit the originalCr Community by passing the mockedCommunity cr representation to it.
    PrintWriter out = resp.getWriter();
    if(req.getPathInfo().equals("/edit")){
        out.write(originalCr.edit(ir).getText());
        out.write(originalCr.toXml().getText());
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:26,代码来源:CommunityServlet.java

示例8: getVariants

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Override
public List<VariantInfo> getVariants(Class<?> source) {
    List<VariantInfo> result = null;

    if (source != null) {
        if (String.class.isAssignableFrom(source)
                || StringRepresentation.class.isAssignableFrom(source)) {
            result = addVariant(result, VARIANT_ALL);
        } else if (File.class.isAssignableFrom(source)
                || FileRepresentation.class.isAssignableFrom(source)) {
            result = addVariant(result, VARIANT_ALL);
        } else if (InputStream.class.isAssignableFrom(source)
                || InputRepresentation.class.isAssignableFrom(source)) {
            result = addVariant(result, VARIANT_ALL);
        } else if (Reader.class.isAssignableFrom(source)
                || ReaderRepresentation.class.isAssignableFrom(source)) {
            result = addVariant(result, VARIANT_ALL);
        } else if (Representation.class.isAssignableFrom(source)) {
            result = addVariant(result, VARIANT_ALL);
        } else if (Form.class.isAssignableFrom(source)) {
            result = addVariant(result, VARIANT_FORM);
        } else if (Serializable.class.isAssignableFrom(source)) {
            if (ObjectRepresentation.VARIANT_OBJECT_BINARY_SUPPORTED) {
                result = addVariant(result, VARIANT_OBJECT);
            }
            if (ObjectRepresentation.VARIANT_OBJECT_XML_SUPPORTED) {
                result = addVariant(result, VARIANT_OBJECT_XML);
            }
        }
    }

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

示例9: createRepresentationFromBody

import org.restlet.representation.InputRepresentation; //导入依赖的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

示例10: createRouteBuilder

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("restlet:http://localhost:" + portNum + "/stock/{symbol}?restletMethods=get")
                .to("http://localhost:" + portNum2 + "/test?bridgeEndpoint=true")
                //.removeHeader("Transfer-Encoding")
                .setBody().constant("110");

            from("jetty:http://localhost:" + portNum2 + "/test").setBody().constant("response is back");

            // create ByteArrayRepresentation for response
            from("restlet:http://localhost:" + portNum + "/images/{symbol}?restletMethods=get")
                .setBody().constant(new InputRepresentation(
                    new ByteArrayInputStream(getAllBytes()), MediaType.IMAGE_PNG, 256));

            from("restlet:http://localhost:" + portNum + "/music/{symbol}?restletMethods=get")
                .setHeader(Exchange.CONTENT_TYPE).constant("audio/mpeg")
                .setBody().constant(getAllBytes());

            from("restlet:http://localhost:" + portNum + "/video/{symbol}?restletMethods=get")
                .setHeader(Exchange.CONTENT_TYPE).constant("video/mp4")
                .setBody().constant(new ByteArrayInputStream(getAllBytes()));

            from("restlet:http://localhost:" + portNum + "/gzip/data?restletMethods=get")
                .setBody().constant(new EncodeRepresentation(Encoding.GZIP, new StringRepresentation("Hello World!", MediaType.TEXT_XML)));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:RestletSetBodyTest.java

示例11: getInstanceDiagram

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
@Get
public InputRepresentation getInstanceDiagram() {
  if(authenticate() == false) return null;
  
  String processInstanceId = (String) getRequest().getAttributes().get("processInstanceId");
  
  if(processInstanceId == null) {
    throw new ActivitiException("No process instance id provided");
  }

  ExecutionEntity pi =
      (ExecutionEntity) ActivitiUtil.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();

  if (pi == null) {
    throw new ActivitiException("Process instance with id" + processInstanceId + " could not be found");
  }

  ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) ActivitiUtil.getRepositoryService())
      .getDeployedProcessDefinition(pi.getProcessDefinitionId());

  if (pde != null && pde.isGraphicalNotationDefined()) {
    InputStream resource = ProcessDiagramGenerator.generateDiagram(pde, "png", ActivitiUtil.getRuntimeService().getActiveActivityIds(processInstanceId));

    InputRepresentation output = new InputRepresentation(resource);
    return output;
    
  } else {
    throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:31,代码来源:ProcessInstanceDiagramResource.java

示例12: main

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
public static void main(String[] args) {
	ClientResource client = new ClientResource("http://127.0.0.1:8082/model/deployments");
	client.setChallengeResponse(ChallengeScheme.HTTP_BASIC,"111", "111");
	
	InputStream input = TestDeploy.class.getClassLoader().getResourceAsStream("FirstFoxbpm.zip");
	Representation deployInput = new InputRepresentation(input);
	Representation result = client.post(deployInput);
	try {
		result.write(System.out);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:FoxBPM,项目名称:FoxBPM,代码行数:14,代码来源:TestDeploy.java

示例13: S3Media

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
S3Media(S3Object object,String name) {
   this.object = object;
   this.name = name;
   entity = new InputRepresentation(object.getObjectContent(),MediaType.valueOf(object.getObjectMetadata().getContentType()));
   String lastModifiedValue = object.getObjectMetadata().getUserMetadata().get("last-modified");
   Date lastModified = lastModifiedValue==null ? object.getObjectMetadata().getLastModified() : DateUtils.parse(lastModifiedValue,DateUtils.FORMAT_RFC_3339);
   entity.setModificationDate(lastModified);
   entity.setSize(object.getObjectMetadata().getContentLength());
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:10,代码来源:S3MediaStorage.java

示例14: get

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
public Representation get()
{
   if (getLogger().isLoggable(Level.FINE)) {
      getLogger().info("Class resource: "+path);
   }
   InputStream is = classLoader.getResourceAsStream(path);
   if (is==null) {
      getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
      return null;
   } else {
      return new InputRepresentation(is,type);
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:14,代码来源:ClassResource.java

示例15: get

import org.restlet.representation.InputRepresentation; //导入依赖的package包/类
public Representation get()
{
   if (getLogger().isLoggable(Level.FINE)) {
      getLogger().info("Class resource: "+path);
   }
   InputStream is = baseClass.getResourceAsStream(path);
   if (is==null) {
      return null;
   } else {
      return new InputRepresentation(is,type);
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:13,代码来源:LoginApplication.java


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