Download the payload from the given path

@param path the relative path of the payload in the {@link ExternalPayloadStorage}
@return the payload object
@throws ApplicationException in case of JSON parsing errors or download errors
974704
@SuppressWarnings("unchecked")
    public Map<String, Object> downloadPayload(String path) {
        try (InputStream inputStream = externalPayloadStorage.download(path)) {
            return objectMapper.readValue(IOUtils.toString(inputStream), Map.class);
        } catch (IOException e) {
            logger.error("Unable to download payload from external storage path: {}", path, e);
            throw new ApplicationException(ApplicationException.Code.INTERNAL_ERROR, e);
        }
    }
55063
protected HttpPost generatePostRequest(final String path, final Map<String, Object> paramMap) {
        final HttpPost post = new HttpPost(buildUri(path));
        post.setEntity(new StringEntity(JSONObject.toJSONString(paramMap), ContentType.APPLICATION_JSON));
        return post;
    }
1089057
public T extractFromPayload(String path, String variable) {
        if (JsonPathMessageValidationContext.isJsonPathExpression(path)) {
            getJsonPathVariableExtractor().getJsonPathExpressions().put(path, variable);
        } else {
            getXpathVariableExtractor().getXpathExpressions().put(path, variable);
        }
        return self;
    }
57882
private static URL getUrlForResourceAsStream(final ExternalContext externalContext, String path)
            throws MalformedURLException
    {
        URLStreamHandler handler = new URLStreamHandler()
        {
            protected URLConnection openConnection(URL u) throws IOException
            {
                final String file = u.getFile();
                return new URLConnection(u)
                {
                    public void connect() throws IOException
                    {
                    }

                    public InputStream getInputStream() throws IOException
                    {
                        if (log.isLoggable(Level.FINE))
                        {
                            log.fine("Opening internal url to " + file);
                        }
                        Object ctx = externalContext.getContext();
                        // Or maybe fetch the external context afresh ?
                        // Object ctx =
                        // FacesContext.getCurrentInstance().getExternalContext().getContext();

                        if (ctx instanceof ServletContext)
                        {
                            ServletContext servletContext = (ServletContext) ctx;
                            InputStream stream = servletContext.getResourceAsStream(file);
                            if (stream == null)
                            {
                                throw new FileNotFoundException("Cannot open resource " + file);
                            }
                            return stream;
                        }
                        else
                        {
                            throw new IOException("Cannot open resource for an context of "
                                    + (ctx != null ? ctx.getClass() : null));
                        }
                    }
                };
            }
        };
        return new URL("internal", null, 0, path, handler);
    }
949540
@Override
    public MIMETypedStream getExternalContent(ContentManagerParams params)
            throws GeneralException, HttpServiceNotFoundException, RangeNotSatisfiableException {
        logger.debug("in getExternalContent(), url={}", params.getUrl());
        try {
            if(params.getProtocol().equals("file")){
                return getFromFilesystem(params);
            }
            if (params.getProtocol().equals("http") || params.getProtocol().equals("https")){
                return getFromWeb(params);
            }
            throw new GeneralException("protocol for retrieval of external content not supported. URL: " + params.getUrl());
        }
        catch (RangeNotSatisfiableException re) {
        	throw re;
        } catch (Exception ex) {
            // catch anything but generalexception
            ex.printStackTrace();
            throw new HttpServiceNotFoundException("[" + this.getClass().getSimpleName() + "] "
                    + "returned an error.  The underlying error was a "
                    + ex.getClass().getName()
                    + "  The message "
                    + "was  \""
                    + ex.getMessage() + "\"  .  ",ex);
        }
    }
839213
private String getRealPath( String path )
            throws IOException
    {

        URL fileURL = _servletContext.getResource( path );

        File tempDir = (File) _servletContext.getAttribute( "javax.servlet.context.tempdir" );

        // download file into temp dir
        if ( fileURL != null )
        {
            File newFile = File.createTempFile( "temp", ".jar", tempDir );
            if ( download( fileURL, newFile ) )
            {
                String filePath = newFile.getPath();
                return filePath;
            }
        }
        return null;
    }
885208
@Override
    @Path("/{documentId}")
    public JSONObject get(String path, Map<String,String> headers)
    throws ServiceException, JSONException {
        WorkflowServices workflowServices = ServiceLocator.getWorkflowServices();
        String docId = getSegment(path, 1);
        if (docId == null) {
            throw new ServiceException(ServiceException.BAD_REQUEST, "Invalid path: " + path);
        }
        try {
            JSONObject json = new JSONObject();
            json.put("value", workflowServices.getDocumentStringValue(Long.valueOf(docId)));
            return json;
        }
        catch (NumberFormatException e) {
            throw new ServiceException(ServiceException.BAD_REQUEST, "Invalid path: " + path, e);
        }
    }
1344246
public static byte[] readBytes(String path)
    {
        try
        {
            if (IOAdapter == null) return readBytesFromFileInputStream(new FileInputStream(path));

            InputStream is = IOAdapter.open(path);
            if (is instanceof FileInputStream)
                return readBytesFromFileInputStream((FileInputStream) is);
            else
                return readBytesFromOtherInputStream(is);
        }
        catch (Exception e)
        {
            logger.warning("读取" + path + "时发生异常" + e);
        }

        return null;
    }
1047169
@GET
    public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
        throw new ServiceException(ServiceException.NOT_ALLOWED, "GET not implemented");
    }
1150279
public static String getUrl(String path) {
        if (path == null) {
            return path;
        }

        ServletContext sc = ExecutionContext.getSession().getServletContext();

        if (path.startsWith("jar:")) {
            int i = path.indexOf("!");
            path = i < 0 ? path : path.substring(++i);
        }

        path = sc.getContextPath() + path;
        return path;
    }
1304747
@Override
    public InputStream get(String path) throws IOException {
        InputStream stream = _cl.getResourceAsStream(rewritePath(path));
        if (stream == null) {
            throw new FileNotFoundException("Not found in classpath: " + path);
        } else {
            return stream;
        }
    }
1093136
public InputStream getResourceAsStream( String path ) {
        Object in = null;
        if ( externalClassLoader != null )
            // classloader wants no leading slash
            in = externalClassLoader.getResourceAsStream( path.substring(1) );
        if ( in == null )
            return Interpreter.class.getResourceAsStream( path );

        return (InputStream) in;
    }
1167713
public InputStream getURLStream(String path) throws NoSuchPathException, IOException {
		URL url = null;
		try {
			url = new URL(path);
		} catch (MalformedURLException e) {
			throw new NoSuchPathException(e);
		}

		return url.openStream();
		
	}
599117
public Response put(String path, Object payload) throws IOException, RESTException {
        return put(path, payload, null);
    }
476162
public void getLink(String path, final I_CmsStringCallback callback) {

        m_apiRoot.getRpcHelper().executeRpc(CmsXmlContentUgcApi.SERVICE.getLink(path, new AsyncCallback<String>() {

            @SuppressWarnings("synthetic-access")
            public void onFailure(Throwable caught) {

                m_apiRoot.handleError(caught, null);
            }

            public void onSuccess(String result) {

                callback.call(result);
            }
        }));
    }
350283
@GET
	@Path("getReport")
	public ReportMetaData getReport(@QueryParam("path") String path) {
		String absolutePath = StorageConstants.NEXT_SERVER_ROOT + path;
		if (!storageService.entityExists(absolutePath)) {
			throw new WebApplicationException(new Exception("No report at '"+  path + "'"), 
					ErrorCodes.NOT_FOUND);			
		}
		Report report;
		try {
			report = (Report) storageService.getEntity(absolutePath);
		} catch (NotFoundException e) {
			throw new WebApplicationException(new Exception("No report at '"+  path + "'"), 
					ErrorCodes.NOT_FOUND);
		}
		if (!ReportConstants.NEXT.equals(report.getType())) {
			throw new WebApplicationException(new Exception("No report at '"+  path + "'"), 
					ErrorCodes.NOT_FOUND);
		}
		
		return createReportMetaData(report);
	}
590226
private JsonObject load(Path path) throws IOException {
    try (InputStream stream = Resources.getResource(path.toString()).openStream()) {
      return (JsonObject) JSON_PARSER.parse(new InputStreamReader(stream));
    }
  }