Java Code Examples for org.restlet.representation.Representation#getStream()
The following examples show how to use
org.restlet.representation.Representation#getStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentResource.java From FoxBPM with Apache License 2.0 | 6 votes |
@Put public String update(Representation entity){ String deploymentId = getAttribute("deploymentId"); InputStream input = null; try { input = entity.getStream(); if(input == null){ throw new FoxbpmPluginException("请求中必须包含文件流", "Rest服务"); } ModelService modelService = FoxBpmUtil.getProcessEngine().getModelService(); DeploymentBuilder deploymentBuilder = modelService.createDeployment(); ZipInputStream zip = new ZipInputStream(input); deploymentBuilder.updateDeploymentId(deploymentId); deploymentBuilder.addZipInputStream(zip); deploymentBuilder.deploy(); setStatus(Status.SUCCESS_OK); } catch (Exception e) { if (e instanceof FoxBPMException) { throw (FoxBPMException) e; } throw new FoxBPMException(e.getMessage(), e); } return "SUCCESS"; }
Example 2
Source File: DeploymentCollectionResource.java From FoxBPM with Apache License 2.0 | 6 votes |
@Post public String deploy(Representation entity){ InputStream input = null; String processDefinitionKey = null; try { input = entity.getStream(); if(input == null){ throw new FoxbpmPluginException("请求中必须包含文件流", "Rest服务"); } ModelService modelService = FoxBpmUtil.getProcessEngine().getModelService(); ZipInputStream zip = new ZipInputStream(input); DeploymentBuilder deploymentBuilder = modelService.createDeployment(); deploymentBuilder.addZipInputStream(zip); Deployment deployment = deploymentBuilder.deploy(); setStatus(Status.SUCCESS_CREATED); ProcessDefinitionQuery processDefinitionQuery = modelService.createProcessDefinitionQuery(); processDefinitionKey = processDefinitionQuery.deploymentId(deployment.getId()).singleResult().getId(); } catch (Exception e) { if (e instanceof FoxBPMException) { throw (FoxBPMException) e; } throw new FoxBPMException(e.getMessage(), e); } return processDefinitionKey; }
Example 3
Source File: GetDisambiguation.java From AGDISTIS with GNU Affero General Public License v3.0 | 4 votes |
@Post public String postText(Representation entity) throws IOException, Exception { NEDAlgo_HITS agdistis = null; try { agdistis = new NEDAlgo_HITS(); } catch (IOException e) { log.error( "Can not load index due to either wrong properties in agdistis.properties or missing index at location", e); System.exit(0); } log.info("Start working on Request for AGDISTIS"); String result = ""; String text = ""; String type = ""; InputStream input = entity.getStream(); // here the inputStream is duplicated due to it can be read only once. // Therefore, we do it for checking if the input is from gerbil or not. byte[] byteArray = IOUtils.toByteArray(input); InputStream input1 = new ByteArrayInputStream(byteArray); InputStream input2 = new ByteArrayInputStream(byteArray); String string = IOUtils.toString(input1); // Parse the given representation and retrieve data Form form = new Form(string); text = form.getFirstValue("text"); type = form.getFirstValue("type"); log.info("text: " + text); log.info("type: " + type); if (text == null) { result = NIFGerbil(input2, agdistis); // This part is created to // work // along with GERBIL, because // GERBIL only sends the NIF // files without taking care of // more than one parameter. So, // GERBIL is not capable to send // the nif in the text parameter // making // AGDISTIS?type=nif&text= not // work. return result; } if (type == null) { type = "agdistis"; } if (type.equals("agdistis")) { return standardAG(text, agdistis); // This type is the standard // and in case the user // doesn't send the type // parameter, it is // considered as the main // one(e.g // AGDISTIS?type=agdistis&text=<entity>Barack // Obama</entity>). } else if (type.equals("nif")) { return NIFType(text, agdistis); // This type is for AGDISTIS // works beyond the GERBIL, this // part is in case of user wants // to check just a certain NIF // file(e.g // AGDISTIS?type=nif&text=@prefix....) } else if (type.equals("candidates")) { return candidateType(text, agdistis); // Here is to let us know // about all candidates // for each mention and // its respective // HITS/PageRank score. } else { return "ERROR"; } }
Example 4
Source File: CustomPageBarResourceFactory.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected InputStream get(final String exportURL) throws IOException { ClientResource clientResource = new ClientResource(exportURL); clientResource.getLogger().setLevel(Level.OFF); final Representation representation = clientResource.get(); return representation != null && representation.isAvailable() ? representation.getStream() : null; }
Example 5
Source File: FormReader.java From DeviceConnect-Android with MIT License | 3 votes |
/** * Constructor.<br> * In case the representation does not define a character set, the UTF-8 * character set is used. * * @param representation * The web form content. * @param decode * Indicates if the parameters should be decoded using the given * character set. * @throws IOException * if the stream of the representation could not be opened. */ public FormReader(Representation representation, boolean decode) throws IOException { this.decode = decode; this.stream = representation.getStream(); this.separator = '&'; if (representation.getCharacterSet() != null) { this.characterSet = representation.getCharacterSet(); } else { this.characterSet = CharacterSet.UTF_8; } }