Package org.guvnor.tools.utils.webdav

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


        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


                monitor.beginTask(Messages.getString("pending"), reps.size()); //$NON-NLS-1$
                for (int i = 0; i < reps.size(); i++) {
                    TreeParent p = new TreeParent(reps.get(i).getLocation(), Type.REPOSITORY);
                    p.setParent(node);
                    p.setGuvnorRepository(reps.get(i));
                    ResourceProperties props = new ResourceProperties();
                    props.setBase(""); //$NON-NLS-1$
                    p.setResourceProps(props);
                    collector.add(p, monitor);
                    monitor.worked(1);
                }
                monitor.done();
View Full Code Here

                        listing = webdav.listDirectory(node.getFullPath());
                    }
                }
                if (listing != null) {
                    for (String s: listing.keySet()) {
                        ResourceProperties resProps = listing.get(s);
                        TreeObject o = null;
                        if (resProps.isDirectory()) {
                            Type childType;
                            switch (getNodeType()) {
                            case REPOSITORY:
                                if (s.startsWith("snapshot")) {
                                    childType = Type.SNAPSHOTS;
View Full Code Here

            // 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('/'))));
                if (targetFile.exists()) {
                    targetFile = resolveNameConflict(targetFile);
                }
                if (targetFile == null) {
                    continue;
                }
                ByteArrayInputStream bis =
                            new ByteArrayInputStream(contents.getBytes(targetFile.getCharset()));
                if (targetFile.exists()) {
                    targetFile.setContents(bis, true, true, null);
                } else {
                    targetFile.create(bis, true, null);
                }
                GuvnorMetadataProps mdProps = new GuvnorMetadataProps(targetFile.getName(),
                                                                     model.getRepLocation(),
                                                                     oneResource,
                                                                     resprops.getLastModifiedDate(),
                                                                     resprops.getRevision());
                GuvnorMetadataUtils.setGuvnorMetadataProps(targetFile.getFullPath(), mdProps);
                GuvnorMetadataUtils.markCurrentGuvnorResource(targetFile);
            }
        } catch (Exception e) {
            Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true);
View Full Code Here

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

            }
        }
    }

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

                Object oneSelection = it.next();
                if (oneSelection instanceof IFile) {
                    GuvnorMetadataProps localProps =
                        GuvnorMetadataUtils.getGuvnorMetadata((IFile)oneSelection);
                    if (localProps != null) {
                        ResourceProperties remoteProps =
                            getRemoteResourceProps((IFile)oneSelection, localProps);
                        if (remoteProps == null) {
                            res = false;
                            break;
                        }
                        if (remoteProps.getRevision().equals(localProps.getRevision())) {
                            res = false;
                            break;
                        }
                    } else {
                        res = false;
View Full Code Here

        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

                    }
                }
            }
            if (res) {
                GuvnorMetadataUtils.markCurrentGuvnorResource(selectedFile);
                ResourceProperties resProps = client.queryProperties(fullPath);
                GuvnorMetadataProps mdProps =
                        new GuvnorMetadataProps(selectedFile.getName(),
                                               repLoc,
                                               fullPath, resProps.getLastModifiedDate(),
                                               resProps.getRevision());
                GuvnorMetadataUtils.setGuvnorMetadataProps(selectedFile.getFullPath(), mdProps);
            }
        } catch (Exception e) {
            Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true);
        }
View Full Code Here

            IWebDavClient client = WebDavServerCache.getWebDavClient(props.getRepository());
            if (client == null) {
                client = WebDavClientFactory.createClient(new URL(props.getRepository()));
                WebDavServerCache.cacheWebDavClient(props.getRepository(), client);
            }
            ResourceProperties remoteProps = null;
            try {
                remoteProps = client.queryProperties(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) {
                    remoteProps = client.queryProperties(props.getFullpath());
                }
            }
            if (remoteProps == null) {
                throw new Exception("Could not retrieve server version of " + props.getFullpath()); //$NON-NLS-1$
            }
            // Check to make sure that the version in the repository is the same as the base
            // version for the local copy
            boolean proceed = true;
            if (!props.getRevision().equals(remoteProps.getRevision())) {
                String msg = MessageFormat.format(Messages.getString("overwrite.confirmation"), //$NON-NLS-1$
                                                 new Object[] { selectedFile.getName(),
                                                                remoteProps.getRevision(),
                                                                props.getRevision() });
                Display display = PlatformUI.getWorkbench().getDisplay();
                proceed = MessageDialog.openQuestion(display.getActiveShell(),
                                                    Messages.getString("overwrite.confirmation.caption"), msg); //$NON-NLS-1$

            }
            if (proceed) {
                client.putResource(props.getFullpath(), selectedFile.getContents());
                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);
        }
View Full Code Here

TOP

Related Classes of org.guvnor.tools.utils.webdav.ResourceProperties

Copyright © 2018 www.massapicom. 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.