Examples of IWebDavClient


Examples of org.guvnor.tools.utils.webdav.IWebDavClient

        return res;
    }

    private GuvnorMetadataProps getGuvnorMetadataProps(TreeObject node) throws Exception {
        GuvnorRepository rep = node.getGuvnorRepository();
        IWebDavClient webdav = WebDavServerCache.getWebDavClient(rep.getLocation());
        if (webdav == null) {
            webdav = WebDavClientFactory.createClient(new URL(rep.getLocation()));
            WebDavServerCache.cacheWebDavClient(rep.getLocation(), webdav);
        }
        ResourceProperties props  = webdav.queryProperties(node.getFullPath());
        return new GuvnorMetadataProps(node.getName(),
                                      node.getGuvnorRepository().getLocation(),
                                      node.getFullPath(),
                                      props.getLastModifiedDate(),
                                      props.getRevision());
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

        }
    }

    private String getResourceContents(TreeObject node) throws Exception {
        GuvnorRepository rep = node.getGuvnorRepository();
        IWebDavClient webdav = WebDavServerCache.getWebDavClient(rep.getLocation());
        if (webdav == null) {
            webdav = WebDavClientFactory.createClient(new URL(rep.getLocation()));
            WebDavServerCache.cacheWebDavClient(rep.getLocation(), webdav);
        }
        String res = webdav.getResourceContents(node.getFullPath());
        return res;
    }
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

            monitor.beginTask(Messages.getString("pending"), 1); //$NON-NLS-1$

            monitor.worked(1);
            GuvnorRepository rep = node.getGuvnorRepository();
            try {
                IWebDavClient webdav = WebDavServerCache.getWebDavClient(rep.getLocation());
                if (webdav == null) {
                    webdav = WebDavClientFactory.createClient(new URL(rep.getLocation()));
                    WebDavServerCache.cacheWebDavClient(rep.getLocation(), webdav);
                }
                Map<String, ResourceProperties> listing = null;
                try {
                    listing = webdav.listDirectory(node.getFullPath());
                } 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(
                                                node.getGuvnorRepository().getLocation(), webdav);
                    if (retry) {
                        listing = webdav.listDirectory(node.getFullPath());
                    }
                }
                if (listing != null) {
                    for (String s: listing.keySet()) {
                        ResourceProperties resProps = listing.get(s);
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

    }

    @Override
    public boolean performFinish() {
        try {
            IWebDavClient webdav = WebDavServerCache.getWebDavClient(model.getRepLocation());
            // During the course of the wizard, the user had to drill into a Guvnor repository
            // to choose resources. Therefore, we should have a cached repository connection
            // that is authenticated already. If not, something is really strange.
            assert(webdav != null);
            for (String oneResource:model.getResources()) {
                // Get the metadata properties
                ResourceProperties resprops = webdav.queryProperties(oneResource);
                if (resprops == null) {
                    throw new Exception("Null resource properties for " + oneResource); //$NON-NLS-1$
                }
                String contents = webdav.getResourceContents(oneResource);
                IPath targetLocation = new Path(model.getTargetLocation());
                IWorkspaceRoot root = Activator.getDefault().getWorkspace().getRoot();
                IFile targetFile = root.getFile(
                                        targetLocation.append(
                                            oneResource.substring(oneResource.lastIndexOf('/'))));
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

        info.put("username", model.getUsername()); //$NON-NLS-1$
        info.put("password", model.getPassword()); //$NON-NLS-1$
        if (model.shouldSaveAuthInfo()) {
            Platform.addAuthorizationInfo(serverUrl, "", "basic", info);     //$NON-NLS-1$ //$NON-NLS-2$
        } else {
            IWebDavClient client = WebDavClientFactory.createClient(serverUrl);
            WebDavServerCache.cacheWebDavClient(serverUrl.toString(), client);
            WebDavSessionAuthenticator authen = new WebDavSessionAuthenticator();
            authen.addAuthenticationInfo(serverUrl, "", "basic", info); //$NON-NLS-1$ //$NON-NLS-2$
            client.setSessionAuthenticator(authen);
        }
    }
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

    private void processDelete(IFile selectedFile) {
        try {
            GuvnorMetadataProps props = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile);
            assert(props != null);
            IWebDavClient client = WebDavServerCache.getWebDavClient(props.getRepository());
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(props.getRepository()));
                WebDavServerCache.cacheWebDavClient(props.getRepository(), client);
            }
            try {
                client.deleteResource(props.getFullpath());
            } 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) {
                    client.deleteResource(props.getFullpath());
                }
            }

        } catch (Exception e) {
            Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true);
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

    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);
            }
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

            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();
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

    }

    private ResourceProperties getRemoteResourceProps(IFile file, GuvnorMetadataProps localProps) {
        ResourceProperties remoteProps = null;
        try {
            IWebDavClient client = WebDavServerCache.getWebDavClient(localProps.getRepository());
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(localProps.getRepository()));
                WebDavServerCache.cacheWebDavClient(localProps.getRepository(), client);
            }
            try {
                remoteProps = client.queryProperties(localProps.getFullpath());
            } 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(localProps.getRepository(), client);
                if (retry) {
                    remoteProps = client.queryProperties(localProps.getFullpath());
                }
            }
        } catch (Exception e) {
            Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
        }
View Full Code Here

Examples of org.guvnor.tools.utils.webdav.IWebDavClient

        return res;
    }

    private GuvnorMetadataProps getGuvnorMetadataProps(TreeObject node) throws Exception {
        GuvnorRepository rep = node.getGuvnorRepository();
        IWebDavClient webdav = WebDavServerCache.getWebDavClient(rep.getLocation());
        if (webdav == null) {
            webdav = WebDavClientFactory.createClient(new URL(rep.getLocation()));
            WebDavServerCache.cacheWebDavClient(rep.getLocation(), webdav);
        }
        ResourceProperties props  = webdav.queryProperties(node.getFullPath());
        return new GuvnorMetadataProps(node.getName(),
                                      node.getGuvnorRepository().getLocation(),
                                      node.getFullPath(),
                                      props.getLastModifiedDate(),
                                      props.getRevision());
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.