Examples of GuvnorMetadataProps


Examples of org.guvnor.tools.utils.GuvnorMetadataProps

        for (int i = 0; i < items.length; i++) {
            IFile sourceFile = PlatformUtils.getResourceFromFSPath(items[i]);
            if (sourceFile != null) {
                try {
                    GuvnorMetadataProps md = GuvnorMetadataUtils.getGuvnorMetadata(sourceFile);
                    if (md == null) {
                        // The file is not already associated with Guvnor, so just add it
                        boolean res = GuvnorMetadataUtils.
                                        addResourceToGuvnor(target.getGuvnorRepository().getLocation(),
                                                           target.getFullPath(), sourceFile);
                        if (!res) {
                            errors.add(MessageFormat.format(Messages.getString("add.failure.exist"), //$NON-NLS-1$
                                                            new Object[] {sourceFile.getName(), target.getFullPath()}));
                        }
                    } else {
                        // Need to check if the drop location is the same as the Guvnor
                        // associated location. If so, then perform commit.
                        // If not, disallow the drop.
                        String itemPath = target.getFullPath() + sourceFile.getName();
                        if (itemPath.equals(md.getFullpath())) {
                            // If there are pending changes
                            if (!GuvnorMetadataUtils.isGuvnorResourceCurrent(sourceFile)) {
                                GuvnorMetadataUtils.commitFileChanges(sourceFile);
                            }
                        } else {
                            errors.add(MessageFormat.format(Messages.getString("already.guvnor.as"), //$NON-NLS-1$
                                                           new Object[] { items[i],
                                                                          md.getFullpath() }));
                        }
                    }
                } catch (Exception e) {
                    Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
                }
View Full Code Here

Examples of org.guvnor.tools.utils.GuvnorMetadataProps

        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.GuvnorMetadataProps

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

Examples of org.guvnor.tools.utils.GuvnorMetadataProps

        PlatformUtils.refreshRepositoryView();
    }

    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.GuvnorMetadataProps

    }

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

Examples of org.guvnor.tools.utils.GuvnorMetadataProps

            }
            IStructuredSelection sel = (IStructuredSelection)selection;
            for (Iterator<Object> it = sel.iterator(); it.hasNext();) {
                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

Examples of org.guvnor.tools.utils.GuvnorMetadataProps

        for (int i = 0; i < items.length; i++) {
            IFile sourceFile = PlatformUtils.getResourceFromFSPath(items[i]);
            if (sourceFile != null) {
                try {
                    GuvnorMetadataProps md = GuvnorMetadataUtils.getGuvnorMetadata(sourceFile);
                    if (md == null) {
                        // The file is not already associated with Guvnor, so just add it
                        boolean res = GuvnorMetadataUtils.
                                        addResourceToGuvnor(target.getGuvnorRepository().getLocation(),
                                                           target.getFullPath(), sourceFile);
                        if (!res) {
                            errors.add(MessageFormat.format(Messages.getString("add.failure.exist"), //$NON-NLS-1$
                                                            new Object[] {sourceFile.getName(), target.getFullPath()}));
                        }
                    } else {
                        // Need to check if the drop location is the same as the Guvnor
                        // associated location. If so, then perform commit.
                        // If not, disallow the drop.
                        String itemPath = target.getFullPath() + sourceFile.getName();
                        if (itemPath.equals(md.getFullpath())) {
                            // If there are pending changes
                            if (!GuvnorMetadataUtils.isGuvnorResourceCurrent(sourceFile)) {
                                GuvnorMetadataUtils.commitFileChanges(sourceFile);
                            }
                        } else {
                            errors.add(MessageFormat.format(Messages.getString("already.guvnor.as"), //$NON-NLS-1$
                                                           new Object[] { items[i],
                                                                          md.getFullpath() }));
                        }
                    }
                } catch (Exception e) {
                    Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
                }
View Full Code Here

Examples of org.guvnor.tools.utils.GuvnorMetadataProps

        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.GuvnorMetadataProps

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

Examples of org.guvnor.tools.utils.GuvnorMetadataProps

    private void handleResourceMoved(final IResource resource, IPath fromPath) throws Exception {
        IFile mdFile = GuvnorMetadataUtils.findGuvnorMetadata(fromPath);
        if (mdFile == null) {
            return;
        }
        final GuvnorMetadataProps mdProps = GuvnorMetadataUtils.loadGuvnorMetadata(mdFile);
        Display display = PlatformUI.getWorkbench().getDisplay();
        display.asyncExec(new Runnable() {
            public void run() {
                try {
                    GuvnorMetadataUtils.setGuvnorMetadataProps(resource.getFullPath(), mdProps);
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.