Package com.salesforce.ide.core.services

Examples of com.salesforce.ide.core.services.ServiceLocator


    private ProjectService projectService = null;
    private ComponentFactory componentFactory = null;

    public ResourceTester() throws ForceProjectException {
        super();
        ServiceLocator serviceLocator = ContainerDelegate.getInstance().getServiceLocator();
        projectService = serviceLocator.getProjectService();
        componentFactory = ContainerDelegate.getInstance().getFactoryLocator().getComponentFactory();
    }
View Full Code Here


    private DeploymentResult deployWork(Connection connection, DeploymentPayload deploymentPayload, boolean checkOnly,
            IProgressMonitor monitor) throws InterruptedException, ForceProjectException, FactoryException,
            ForceConnectionException, ServiceException, ForceRemoteException, JAXBException {

        final ServiceLocator serviceLocator = ContainerDelegate.getInstance().getServiceLocator();
        ProjectPackageList projectPackageList = serviceLocator.getProjectService().getProjectPackageListInstance();
        projectPackageList.setProject(deploymentPayload.getProject());
        PackageManifestFactory factory = projectPackageList.getPackageManifestFactory();
        // See W-837427 - we handle custom objects differently upon deploy, and so
        // call this specialized manifest factory method.
        Package manifest = factory.createSpecialDefaultPackageManifest();
        manifest.setVersion(serviceLocator.getProjectService().getLastSupportedEndpointVersion());


        monitorCheckSubTask(monitor, "Loading deployment candidates...");
        DeploymentComponentSet deploymentComponents = deploymentPayload.getDeploySelectedComponents();

        IProject project = deploymentPayload.getProject();
        Package packageManifest = serviceLocator.getProjectService().getPackageManifestFactory().getPackageManifest(project);
       
        // Looping through each component that we want to deploy.
        //
        // Custom object components are handled differently.
        for (DeploymentComponent deploymentComponent : deploymentComponents) {
            if (deploymentComponent.getDestinationSummary().equals(DeploymentSummary.DELETED)) {
                projectPackageList.addDeleteComponent(deploymentComponent.getComponent());
            } else {
                projectPackageList.addComponent(deploymentComponent.getComponent());
              
                // If this is a custom object component, check to see if it's actually in the manifest -
                // maybe a field inside the object was retrieved from the source org into the project,
                // but the object itself wasn't.
                //
                // If so, we don't want to add the object to the deployment manifest.  Any fields
                // will be included by default because the manifest has a "*" for that component type.
                // (In fact it has a "*" for every component type except custom object, because of
                // this particular issue. See changelist 1452239.)
                //
                //Package packageManifest = serviceLocator.getProjectService().getPackageManifestFactory().getPackageManifest(project);
        String type = deploymentComponent.getComponent().getComponentType();
                boolean isObject = type.equals(Constants.CUSTOM_OBJECT);
                boolean isSharingRule = Constants.ABSTRACT_SHARING_RULE_TYPES.contains(type) || Constants.SHARING_RULE_TYPES.contains(type);
        if(isObject) {
          boolean isPresent = new PackageManifest(packageManifest).contains("CustomObject", deploymentComponent.getComponent().getName());
          if (isPresent) {
            factory.addComponentToManifest(manifest, deploymentComponent.getComponent());
          }
        }
        //If it's a sharing rule, we will add it from the project manifest
        else if (!isSharingRule) {// && !type.equals("Settings")) {
          factory.addComponentToManifest(manifest, deploymentComponent.getComponent());
        }

            }
        }
       
        //Add sharing rules from the package manifest file since the component and file structure is
        //different than what is required by the package manifest file.
        //W-1169372
        for (PackageTypeMembers member : packageManifest.getTypes()) {
          if (Constants.SHARING_RULE_TYPES.contains(member.getName())) {
            manifest.getTypes().add(member);
          }
        }
        monitorWork(monitor);

        try {
            Component comp = factory.getComponentFactory().getComponentById(Constants.PACKAGE_MANIFEST);
            comp.setMetadataFilePath(Constants.PACKAGE_MANIFEST_FILE_NAME);
            comp.setBody(manifest.getXMLString());
            comp.setName(manifest.getFullName());

            projectPackageList.get(0).removePackageManifestComponent();
            projectPackageList.get(0).setPackageManifest(comp);
            projectPackageList.get(0).addComponent(comp);
        } catch (Exception e) {
            logger.warn("Unable to change deploy manifest", e);
        }

        // prepare result and record datetime
        DeploymentResult result = new DeploymentResult();
        result.setDeployTime(new GregorianCalendar());
        result.setDeploymentPayload(deploymentPayload);
        result.setDestinationOrg(connection.getConnectionInfo());
        result.setSourceProjectName(deploymentPayload.getProject().getName());
        result.setSourceEndpoint(serviceLocator.getProjectService().getSoapEndPoint(deploymentPayload.getProject()));
        result.setSourceUsername(serviceLocator.getProjectService().getUsername(deploymentPayload.getProject()));

        DeployOptions deployOptions = makeDefaultDeployOptions(checkOnly, serviceLocator.getPackageDeployService());

        LogInfo[] runTestLogSettings =
                serviceLocator.getLoggingService().getAllLogInfo(getProject(), LoggingInfo.SupportedFeatureEnum.RunTest);

        DeployResultExt deployResultHandler = null;
        try {
            deployResultHandler =
                    serviceLocator.getPackageDeployService().deploy(connection, projectPackageList, deployOptions, runTestLogSettings,
                        false, new SubProgressMonitor(monitor, 6));
        } catch (ServiceTimeoutException ex) {
            deployResultHandler = serviceLocator.getPackageDeployService().handleDeployServiceTimeoutException(ex, "deploy", monitor);
        }

        result.setDeployResultHandler(deployResultHandler);

        if (deployResultHandler != null && !deployResultHandler.isSuccess()) {
View Full Code Here

TOP

Related Classes of com.salesforce.ide.core.services.ServiceLocator

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.