Examples of IResponse


Examples of org.apache.james.jspf.executor.IResponse

                private IResponseQueue responsePool;
                private Integer id;
                private LookupAsynch lookup;

                public void run() {
                    responsePool.insertResponse(new IResponse() {

                        public Exception getException() {
                            if (lookup.getResult() == LookupAsynch.TRY_AGAIN) {
                                return new TimeoutException(lookup.getErrorString());
                            } else {
View Full Code Here

Examples of org.apache.james.jspf.executor.IResponse

                private IResponseQueue responsePool;
                private Integer id;
                private LookupAsynch lookup;

                public void run() {
                    responsePool.insertResponse(new IResponse() {

                        public Exception getException() {
                            if (lookup.getResult() == LookupAsynch.TRY_AGAIN) {
                                return new TimeoutException(lookup.getErrorString());
                            } else {
View Full Code Here

Examples of org.eclipse.webdav.IResponse

    /*
     * (non-Javadoc)
     * @see org.guvnor.tools.utils.webdav.IWebDavClient#listDirectory(java.lang.String)
     */
    public Map<String, ResourceProperties> listDirectory(String path) throws Exception {
        IResponse response = null;
        try {
            IContext context = createContext();
            context.put("Depth", "1"); //$NON-NLS-1$ //$NON-NLS-2$
            ILocator locator = WebDAVFactory.locatorFactory.newLocator(path);
            response = client.propfind(locator, context, null);
            if (response.getStatusCode() != IResponse.SC_MULTI_STATUS) {
                throw new WebDavException(response);
            }
            Map<String, ResourceProperties> res =
                StreamProcessingUtils.parseListing(path, response.getInputStream());
            addGuvnorResourceProperties(res, path);
            return res;
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

    }

    private void addGuvnorResourceProperties(Map<String,
                                            ResourceProperties> props,
                                            String path) throws Exception {
        IResponse response = null;
        try {
            String apiVer = changeToAPICall(path);
            Properties guvProps = new Properties();
            response = getResourceInputStream(apiVer);
            guvProps.load(response.getInputStream());
            response.getInputStream();
            for (Iterator<String> it = props.keySet().iterator(); it.hasNext();) {
                String oneKey = it.next();
                String val = guvProps.getProperty(oneKey);
                if (val != null) {
                    ResourceProperties resProps = props.get(oneKey);
                    StringTokenizer tokens = new StringTokenizer(val, ","); //$NON-NLS-1$
//                    String dateStamp = tokens.nextToken();
//                    String revision = tokens.nextToken();
                    if(tokens.hasMoreElements()){
                        resProps.setLastModifiedDate(tokens.nextToken());
                    }
                    if(tokens.hasMoreElements()){
                        resProps.setRevision(tokens.nextToken());
                    }
                }
            }
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

    /*
     * (non-Javadoc)
     * @see org.guvnor.tools.utils.webdav.IWebDavClient#queryProperties(java.lang.String)
     */
    public ResourceProperties queryProperties(String resource) throws Exception {
        IResponse response = null;
        try {
            IContext context = createContext();
            context.put("Depth", "1"); //$NON-NLS-1$ //$NON-NLS-2$
            ILocator locator = WebDAVFactory.locatorFactory.newLocator(resource);
            response = client.propfind(locator, context, null);
            if (response.getStatusCode() != IResponse.SC_MULTI_STATUS
               && response.getStatusCode() != IResponse.SC_OK) {
                throw new WebDavException(response);
            }
            Map<String, ResourceProperties> props =
                StreamProcessingUtils.parseListing("", response.getInputStream()); //$NON-NLS-1$
            if (props.keySet().size() != 1) {
                throw new Exception(props.keySet().size() + " entries found for " + resource); //$NON-NLS-1$
            }
            String fullpath = props.keySet().iterator().next();
            ResourceProperties res = props.get(fullpath);
            String filename = new Path(fullpath).lastSegment();
            addGuvnorResourceProperties(res, filename, resource);
            return res;
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

    private void addGuvnorResourceProperties(ResourceProperties props,
                                            String filename, String resource) throws Exception {
        if (props == null) {
            return;
        }
        IResponse response = null;
        try {
            String path = resource.substring(0, resource.lastIndexOf('/'));
            String apiVer = changeToAPICall(path);
            Properties guvProps = new Properties();
            response = getResourceInputStream(apiVer);
            guvProps.load(response.getInputStream());
            String val = guvProps.getProperty(filename);
            if (val != null) {
                StringTokenizer tokens = new StringTokenizer(val, ","); //$NON-NLS-1$
//                String dateStamp = tokens.nextToken();
//                String revision = tokens.nextToken();
                if(tokens.hasMoreElements()){
                    props.setLastModifiedDate(tokens.nextToken());
                }
                if(tokens.hasMoreElements()){
                    props.setRevision(tokens.nextToken());
                }
            } else {
                Exception nfe = new Exception("Failed to get Guvnor properties for " + filename); //$NON-NLS-1$
                Activator.getDefault().writeLog(IStatus.WARNING, nfe.getMessage(), nfe);
            }
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

    /*
     * (non-Javadoc)
     * @see org.guvnor.tools.utils.webdav.IWebDavClient#getResourceContents(java.lang.String)
     */
    public String getResourceContents(String resource) throws Exception {
        IResponse response = null;
        try {
            response = getResourceInputStream(resource);
            return StreamProcessingUtils.getStreamContents(response.getInputStream());
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

     * (non-Javadoc)
     * @see org.guvnor.tools.utils.webdav.IWebDavClient#getInputStream(java.lang.String)
     */
    public IResponse getResourceInputStream(String resource) throws Exception {
        ILocator locator = WebDAVFactory.locatorFactory.newLocator(resource);
        IResponse response = client.get(locator, createContext());
        if (response.getStatusCode() != IResponse.SC_OK) {
            throw new WebDavException(response);
        }
        return response;
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

                if (e.getErrorCode() != IResponse.SC_NOT_FOUND) {
                    throw e;
                }
            }
        }
        IResponse response = null;
        try {
            if (res) {
                ILocator locator = WebDAVFactory.locatorFactory.newLocator(resource);
                response = client.put(locator, createContext(), is);
                if (response.getStatusCode() != IResponse.SC_OK
                   && response.getStatusCode() != IResponse.SC_CREATED) {
                    throw new WebDavException(response);
                }
            }
        } finally {
            if (response != null) {
                response.close();
            }
        }
        return res;
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

            compareWithSelectedVersion(dialog.getSelectedEntry());
        }
    }

    private void compareWithSelectedVersion(ResourceHistoryEntry revision) {
        IResponse response = null;
        try {
            IWorkbenchPage page = targetPart.getSite().getPage();
            String leftContents = StreamProcessingUtils.getStreamContents(selectedFile.getContents());
            GuvnorResourceEdition left =
                new GuvnorResourceEdition(selectedFile.getName(),
                                         ITypedElement.TEXT_TYPE,
                                         leftContents, selectedFile.getCharset());
            response = client.getResourceVersionInputStream(props.getFullpath(), revision.getRevision());
            String rightContents = StreamProcessingUtils.getStreamContents(response.getInputStream());
            //Assuming UTF-8 for Guvnor resources...
            GuvnorResourceEdition right =
                new GuvnorResourceEdition(selectedFile.getName() + ", " + revision.getRevision(), //$NON-NLS-1$
                                         ITypedElement.TEXT_TYPE,
                                         rightContents, "UTF-8"); //$NON-NLS-1$
            CompareUI.openCompareEditorOnPage(new GuvnorCompareEditorInput(left, right), page);
        } catch (Exception e) {
            Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true);
        } finally {
            if (response != null) {
                try {
                    response.close();
                } catch (IOException ioe) {
                    Activator.getDefault().writeLog(IStatus.ERROR, ioe.getMessage(), ioe);
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.