Examples of IResponse


Examples of org.eclipse.webdav.IResponse

    /*
     * (non-Javadoc)
     * @see org.guvnor.tools.utils.webdav.IWebDavClient#putResource(java.lang.String, java.io.InputStream)
     */
    public void putResource(String resource, InputStream is) throws Exception {
        IResponse response = null;
        try {
            ILocator locator = WebDAVFactory.locatorFactory.newLocator(resource);
            response = client.put(locator, createContext(), is);
            if (response.getStatusCode() != IResponse.SC_OK
               && response.getStatusCode() != IResponse.SC_NO_CONTENT
               && response.getStatusCode() != IResponse.SC_CREATED) {
                throw new WebDavException(response);
            }
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

        }
    }

    private ResourceHistoryEntry[] getVersionEntries() {
        ResourceHistoryEntry[] entries = new ResourceHistoryEntry[0];
        IResponse response = null;
        try {
            client = WebDavServerCache.getWebDavClient(props.getRepository());
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(props.getRepository()));
                WebDavServerCache.cacheWebDavClient(props.getRepository(), client);
            }
            InputStream ins = null;
            try {
                response = client.getResourceVersions(props.getFullpath());
                ins = response.getInputStream();
            } catch (WebDavException wde) {
                if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) {
                    // If not an authentication failure, we don't know what to do with it
                    throw wde;
                }
                boolean retry = PlatformUtils.getInstance().
                                    authenticateForServer(props.getRepository(), client);
                if (retry) {
                    response = client.getResourceVersions(props.getFullpath());
                    ins = response.getInputStream();
                }
            }
            if (ins != null) {
                Properties verProps = new Properties();
                verProps.load(ins);
                entries = GuvnorMetadataUtils.parseHistoryProperties(verProps);
            }
        } catch (Exception e) {
            Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
        } finally {
            if (response != null) {
                try {
                    response.close();
                } catch (IOException ioe) {
                    Activator.getDefault().writeLog(IStatus.ERROR, ioe.getMessage(), ioe);
                }
            }
        }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

    /*
     * (non-Javadoc)
     * @see org.guvnor.tools.utils.webdav.IWebDavClient#deleteResource(java.lang.String)
     */
    public void deleteResource(String resource) throws Exception {
        IResponse response = null;
        try {
            ILocator locator = WebDAVFactory.locatorFactory.newLocator(resource);
            response = client.delete(locator, createContext());
            if (response.getStatusCode() != IResponse.SC_NO_CONTENT
               && response.getStatusCode() != IResponse.SC_OK) {
                throw new WebDavException(response);
            }
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

        }
        PlatformUtils.updateDecoration();
    }

    private void processUpdate(IFile selectedFile) {
        IResponse response = null;
        try {
            GuvnorMetadataProps props = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile);
            IWebDavClient client = WebDavServerCache.getWebDavClient(props.getRepository());
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(props.getRepository()));
                WebDavServerCache.cacheWebDavClient(props.getRepository(), client);
            }
            InputStream ins = null;
            try {
                response = client.getResourceInputStream(props.getFullpath());
                ins = response.getInputStream();
            } catch (WebDavException wde) {
                if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) {
                    // If not an authentication failure, we don't know what to do with it
                    throw wde;
                }
                boolean retry = PlatformUtils.getInstance().
                                    authenticateForServer(props.getRepository(), client);
                if (retry) {
                    response = client.getResourceInputStream(props.getFullpath());
                    ins = response.getInputStream();
                }
            }
            if (ins != null) {
                selectedFile.setContents(ins, true, true, null);
                GuvnorMetadataUtils.markCurrentGuvnorResource(selectedFile);
                ResourceProperties resProps = client.queryProperties(props.getFullpath());
                GuvnorMetadataProps mdProps = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile);
                mdProps.setVersion(resProps.getLastModifiedDate());
                mdProps.setRevision(resProps.getRevision());
                GuvnorMetadataUtils.setGuvnorMetadataProps(selectedFile.getFullPath(), mdProps);
            }
        } 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

Examples of org.eclipse.webdav.IResponse

            }
            repositoryLoc = props.getRepository();
            fullPath = props.getFullpath();
        }

        IResponse response = null;
        try {
            IWebDavClient client = WebDavServerCache.getWebDavClient(repositoryLoc);
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(repositoryLoc));
                WebDavServerCache.cacheWebDavClient(repositoryLoc, client);
            }
            InputStream ins = null;
            try {
                response = client.getResourceVersions(fullPath);
                ins = response.getInputStream();
            } catch (WebDavException wde) {
                if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) {
                    // If not an authentication failure, we don't know what to do with it
                    throw wde;
                }
                boolean retry = PlatformUtils.getInstance().
                                    authenticateForServer(repositoryLoc, client);
                if (retry) {
                    response = client.getResourceVersions(fullPath);
                    ins = response.getInputStream();
                }
            }
            if (ins != null) {
                Properties verProps = new Properties();
                verProps.load(ins);
                ResourceHistoryView view = PlatformUtils.getResourceHistoryView();
                if (view != null) {
                    view.setEntries(repositoryLoc, fullPath, verProps);
                }
            }
        } 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

Examples of org.eclipse.webdav.IResponse

            PlatformUtils.updateDecoration();
        }
     }

    private void updateSelectedFile(ResourceHistoryEntry verInfo) {
        IResponse response = null;
        try {
            response = client.getResourceVersionInputStream(props.getFullpath(), verInfo.getRevision());
            InputStream ins = response.getInputStream();
            if (ins != null) {
                selectedFile.setContents(ins, true, true, null);
                GuvnorMetadataUtils.markCurrentGuvnorResource(selectedFile);
                GuvnorMetadataProps mdProps = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile);
                mdProps.setVersion(verInfo.getDate());
                mdProps.setRevision(verInfo.getRevision());
                GuvnorMetadataUtils.setGuvnorMetadataProps(selectedFile.getFullPath(), mdProps);
            }
        } 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

Examples of org.eclipse.webdav.IResponse

            }
        }
    }
    private ResourceHistoryEntry[] getVersionEntries() {
        ResourceHistoryEntry[] entries = new ResourceHistoryEntry[0];
        IResponse response = null;
        try {
            client = WebDavServerCache.getWebDavClient(props.getRepository());
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(props.getRepository()));
                WebDavServerCache.cacheWebDavClient(props.getRepository(), client);
            }
            InputStream ins = null;
            try {
                response = client.getResourceVersions(props.getFullpath());
                ins = response.getInputStream();
            } catch (WebDavException wde) {
                if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) {
                    // If not an authentication failure, we don't know what to do with it
                    throw wde;
                }
                boolean retry = PlatformUtils.getInstance().
                                    authenticateForServer(props.getRepository(), client);
                if (retry) {
                    response = client.getResourceVersions(props.getFullpath());
                    ins = response.getInputStream();
                }
            }
            if (ins != null) {
                Properties verProps = new Properties();
                verProps.load(ins);
                entries = GuvnorMetadataUtils.parseHistoryProperties(verProps);
            }
        } catch (Exception e) {
            Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
        } finally {
            if (response != null) {
                try {
                    response.close();
                } catch (IOException ioe) {
                    Activator.getDefault().writeLog(IStatus.ERROR, ioe.getMessage(), ioe);
                }
            }
        }
View Full Code Here

Examples of org.eclipse.webdav.IResponse

     * on the WebDAV server.
     */
    public void create() throws DAVException {
        Document document = newDocument();
        Mkworkspace.create(document);
        IResponse response = null;
        try {
            response = davClient.mkworkspace(locator, newContext(), document);
            examineResponse(response);
        } catch (IOException e) {
            throw new SystemException(e);
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.