Package com.salesforce.ide.core.model

Examples of com.salesforce.ide.core.model.ProjectPackageList


    private ProjectPackageList getRemoteProjectPackageList(ProjectPackageList localProjectPackageList,
            IProgressMonitor monitor) throws ForceConnectionException, ForceRemoteException, FactoryException,
            ServiceException, InterruptedException, IOException {

        // declare return list
        ProjectPackageList remoteProjectPackageList = null;

        // update package manifest version to current ide version
        Package packageManifest = ContainerDelegate.getInstance().getServiceLocator().getProjectService().getPackageManifestFactory().getPackageManifest(model.getProject());
        packageManifest.setVersion(installedIdeVersion);

        // remove existing, stored connection, change endpoint version, and get new connection
        ForceProject forceProject = ContainerDelegate.getInstance().getServiceLocator().getProjectService().getForceProject(model.getProject());
        ContainerDelegate.getInstance().getFactoryLocator().getConnectionFactory().removeConnection(forceProject);
        ContainerDelegate.getInstance().getFactoryLocator().getMetadataFactory().removeMetadataStubExt(forceProject);
        ContainerDelegate.getInstance().getFactoryLocator().getToolingFactory().removeToolingStubExt(forceProject);
        forceProject.setEndpointApiVersion(installedIdeVersion);
        Connection connection = ContainerDelegate.getInstance().getFactoryLocator().getConnectionFactory().getConnection(forceProject);

        // perform retrieve
        RetrieveResultExt retrieveResultHandler = null;
        try {
            retrieveResultHandler = ContainerDelegate.getInstance().getServiceLocator().getPackageRetrieveService().retrieveSelective(connection,
                    localProjectPackageList, true, packageManifest, monitor);
        } catch (ServiceTimeoutException ex) {
            //FIXME: Best way to handle?
        }

        if (retrieveResultHandler == null) {
            logger.warn("Unable to get remote content - retrieve result is null");
            return remoteProjectPackageList;
        }

        monitorWork(monitor);

        remoteProjectPackageList = ContainerDelegate.getInstance().getServiceLocator().getProjectService().getProjectPackageFactory().getProjectPackageListInstance();
        remoteProjectPackageList.setProject(model.getProject());
        remoteProjectPackageList.generateComponents(retrieveResultHandler.getZipFile(), retrieveResultHandler
                .getFileMetadataHandler(), monitor);

        return remoteProjectPackageList;
    }
View Full Code Here


        } catch (ServiceTimeoutException ex) {
            retrieveResultHandler = ContainerDelegate.getInstance().getServiceLocator().getPackageRetrieveService().handleRetrieveServiceTimeoutException(
                    ex, "upgrade resource(s)", monitor);
            if (retrieveResultHandler != null) {
                Connection connection = ContainerDelegate.getInstance().getFactoryLocator().getConnectionFactory().getConnection(project);
                ProjectPackageList projectPackageList = ContainerDelegate.getInstance().getServiceLocator().getProjectService().getProjectPackageFactory().getManagedInstalledProjectPackages(
                        connection);
                if (projectPackageList != null) {
                    projectPackageList.setProject(project);
                }
                retrieveResultHandler.setProjectPackageList(projectPackageList);
            }
        }
View Full Code Here

            IProgressMonitor monitor) throws CoreException, InterruptedException, FactoryException {
        if (Utils.isEmpty(resources)) {
            throw new IllegalArgumentException("Resources cannot be null");
        }

        ProjectPackageList projectPackageList = getProjectPackageListInstance();
        projectPackageList.setProject(resources.get(0).getProject());
        for (IResource resource : resources) {
            if (resource.getType() == IResource.PROJECT) {
                projectPackageList = getProjectContents(resource.getProject(), monitor);
            } else if (isSourceFolder(resource)) {
                projectPackageList = getProjectContents(resource.getProject(), monitor);
            } else if (isComponentFolder(resource)) {
                ComponentList componentList = getComponentsForComponentFolder((IFolder) resource, true, true);
                projectPackageList.addComponents(componentList, false);
            } else if (isSubComponentFolder(resource)) {
                ComponentList componentList = getComponentsForSubComponentFolder((IFolder) resource, true);
                projectPackageList.addComponents(componentList, false);
            } else if (isManagedFile(resource)) { //if we're in a force.com project. "isManaged" is misleading.
                Component component = getComponentFactory().getComponentFromFile((IFile) resource);
                projectPackageList.addComponent(component, true);

                // add dependent or associated components such as folder metadata component if component is sub-folder component
                if (includeAssociated) {
                    ComponentList componentList = getComponentFactory().getAssociatedComponents(component);
                    if (Utils.isNotEmpty(componentList)) {
                        projectPackageList.addComponents(componentList, false);
                    }
                }
            }
        }
        //filter out any built in folder stuff.
        // if component subfolder is built-in subfolder, then this subfolder will be available in dest org (also this subfolder is not retrievable/deployable)
        // so no need to add subfolder component to deploy list. W-623512
        ComponentList allComponentsList = getComponentFactory().getComponentListInstance();
        allComponentsList.addAll(projectPackageList.getAllComponents());
        for (Component component : allComponentsList) {
            if (Utils.isNotEmpty(component.getBuiltInSubFolders())) {
                for (String builtInSubFolder : component.getBuiltInSubFolders()) {
                    if (builtInSubFolder.equals(component.getName())) {
                        projectPackageList.removeComponent(component);
                    }
                }
            }
        }
View Full Code Here

        }

        monitorCheck(monitor);

        // initialize container to holder contents
        ProjectPackageList projectPackageList = getProjectPackageListInstance();
        projectPackageList.setProject(project);

        // ensure project is not empty
        if (isProjectEmpty(project)) {
            return projectPackageList;
        }

        // get src folder; discontinue if not found or empty
        IResource sourceResource = project.findMember(Constants.SOURCE_FOLDER_NAME);
        if (sourceResource == null || !sourceResource.exists() || sourceResource.getType() != IResource.FOLDER
                || Utils.isEmpty(((IFolder) sourceResource).members())) {
            if (logger.isInfoEnabled()) {
                logger.info(Constants.SOURCE_FOLDER_NAME
                        + " not found, does not exist, or does not contain package folders in project '"
                        + project.getName() + "'");
            }
            return projectPackageList;
        }

        List<IFolder> componentFolders = getComponentFolders((IFolder) sourceResource);
        for (IFolder componentFolder : componentFolders) {
            monitorCheck(monitor);

            if (Utils.isEmpty(componentFolder.members())) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Skipping folder " + project.getName() + "' - no components found");
                }
                continue;
            }

            // find components in componet folder
            ComponentList componentList = getComponentsForComponentFolder(componentFolder, true, true);
            if (componentList.isEmpty()) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Component folder '" + componentFolder.getName()
                            + "' is does not contain components for enabled object types");
                }
                continue;
            }

            // add components to project package list instance including reference to package manifest
            projectPackageList.addComponents(componentList, false);
            if (logger.isDebugEnabled()) {
                logger.debug("Added '" + componentFolder.getName() + "' folder containing [" + componentList.size()
                        + "] components to project package list");
            }
        }
View Full Code Here

        return componentFolder;
    }

    public ProjectPackageList getComponentsForComponentTypes(IProject project, String[] componentTypes)
            throws CoreException, FactoryException {
        ProjectPackageList projectPackageList = getProjectPackageFactory().getProjectPackageListInstance(project);
        if (Utils.isNotEmpty(componentTypes)) {
            for (String componentType : componentTypes) {
                IFolder componentFolder = getComponentFolderByComponentType(project, componentType);
                if (componentFolder != null && componentFolder.exists()) {
                    ComponentList componentList = getComponentFactory().getComponentListInstance();
                    componentList.addAll(getComponentsForFolder(componentFolder, true));
                    projectPackageList.addComponents(componentList, true);
                }
            }
        }
        return projectPackageList;
    }
View Full Code Here

            InterruptedException {
        if (project == null) {
            throw new IllegalArgumentException("Project cannot be null");
        }
        // get local and remote components
        ProjectPackageList localProjectPackageList = getProjectService().getProjectContents(project, monitor);

        if (localProjectPackageList == null) {
            logger.warn("Unable to check in sync for project '" + project.getName()
                    + "' - local local project package list is null");
            return true;
View Full Code Here

        }

        // get local components
        monitorCheck(monitor);
        monitor.subTask("Retrieving local project contents...");
        ProjectPackageList localProjectPackageList = null;
        if (getProjectService().isPackageFolder(folder) || getProjectService().isSourceFolder(folder)) {
            localProjectPackageList = getProjectPackageFactory().loadProjectPackageList(folder, monitor);
        } else if (getProjectService().isComponentFolder(folder) || getProjectService().isSubComponentFolder(folder)) {
            localProjectPackageList = getProjectPackageFactory().loadProjectPackageList(folder, monitor);
        } else if (getProjectService().isReferencedPackageResource(folder)) {
            logger.warn("Folder '" + folder.getName() + "' is not support by in sync check");
            return true;
        }

        monitor.worked(1);

        if (localProjectPackageList == null) {
            logger.warn("Unable to check in sync for folder '" + folder.getName()
                    + "' - local local project package list is null");
            return true;
        }

        localProjectPackageList.setProject(folder.getProject());

        monitorCheck(monitor);
        monitor.subTask("Retrieving remote contents...");
        RetrieveResultExt retrieveResultExt =
                getPackageRetrieveService().retrieveSelective(localProjectPackageList, true, monitor);
View Full Code Here

        }

        // get local components
        monitorWorkCheck(monitor, "Retrieving local project contents...");
        monitorCheck(monitor);
        ProjectPackageList localProjectPackageList = null;

        Component component = null;
        try {
            component = getComponentFactory().getComponentFromFile(file, true);
        } catch (FactoryException e) {
            logger.warn("Unable to check in sync for file '" + file.getName()
                    + "' - unable to create component from file");
            return true;
        }

        if (component.isPackageManifest()) {
            logger.warn("Component is a package manifest - skipping as sync file resource");
            // REVIEWME: what if the user wants to sync a package manifest?
            return true;
        }

        localProjectPackageList = getProjectPackageListInstance();
        localProjectPackageList.setProject(file.getProject());
        localProjectPackageList.addComponent(component, true);

        monitorWorkCheck(monitor, "Retrieving remote contents...");
        RetrieveResultExt retrieveResultExt =
                getPackageRetrieveService().retrieveSelective(localProjectPackageList, true, monitor);
View Full Code Here

    private boolean evaluateLocalAndRemote(ProjectPackageList localProjectPackageList,
            RetrieveResultExt retrieveResultExt, IProgressMonitor monitor) throws InterruptedException, IOException {

        // get remote package list to evaluate
        ProjectPackageList remoteProjectPackageList = retrieveResultExt.getProjectPackageList();

        monitorCheckSubTask(monitor, Messages.getString("Components.Generating"));
        remoteProjectPackageList.generateComponents(retrieveResultExt.getZipFile(),
            retrieveResultExt.getFileMetadataHandler(), monitor);
        monitorWork(monitor);

        monitorCheck(monitor);
        // if either local or remote are empty, assume project is out-of-sync
        if ((localProjectPackageList.isEmpty() && remoteProjectPackageList.isNotEmpty())
                || (localProjectPackageList.isNotEmpty() && remoteProjectPackageList.isEmpty())) {
            return false;
        }

        monitorSubTask(monitor, Messages.getString("Components.Evaluating"));
        // test either project package
        for (ProjectPackage localProjectPackage : localProjectPackageList) {
            monitorCheck(monitor);
            // local package does not exist remotely, assume project is out-of-sync
            if (!remoteProjectPackageList.hasPackage(localProjectPackage.getName())) {
                logger.warn("Project package '" + localProjectPackage.getName()
                        + "' does not exist remotely - assuming project is out of sync");
                return false;
            }

            // deep equal check on same-named project package
            ProjectPackage remoteProjectPackage =
                    remoteProjectPackageList.getProjectPackage(localProjectPackage.getName());
            if (!localProjectPackage.hasChanged(remoteProjectPackage)) {
                logger.warn("Project package '" + localProjectPackage.getName()
                        + "' does not jive with remote package - assuming project is out of sync");
                return false;
            }
View Full Code Here

        }

        if (logger.isDebugEnabled()) {
            logger.debug("Retrieve all components for:\n" + connection.getLogDisplay());
        }
        ProjectPackageList projectPackageList =
                getProjectPackageFactory().getDevelopmentAndUnmanagedInstalledProjectPackages(connection);

        if (logger.isDebugEnabled()) {
            logger.debug("Packages for " + connection.getLogDisplay() + " " + projectPackageList.toString());
        }

        RetrieveRequest retrieveRequest = getRetrieveRequest();
        retrieveRequest.setPackageNames(projectPackageList.getNamedPackageNames());
        if (defaultMainfest == null) {
            getPackageManifestFactory().setDefaultPackageManifest(connection, retrieveRequest);
        } else {
            retrieveRequest.setUnpackaged(getPackageManifestFactory().convert(defaultMainfest));
        }
View Full Code Here

TOP

Related Classes of com.salesforce.ide.core.model.ProjectPackageList

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.