예제 #1
0
 public long getSize(
     IProvisioningPlan provisioningPlan,
     IProfile profile,
     IEngine engine,
     ProvisioningContext context,
     IProgressMonitor monitor) {
   // If there is nothing to size, return 0
   if (provisioningPlan == null) {
     return SIZE_NOTAPPLICABLE;
   }
   if (((ProvisioningPlan) provisioningPlan).getOperands().length == 0) {
     return 0;
   }
   long installPlanSize = 0;
   if (provisioningPlan.getInstallerPlan() != null) {
     SizingPhaseSet set = new SizingPhaseSet(new Sizing(100));
     IStatus status = engine.perform(provisioningPlan, set, null);
     if (status.isOK()) {
       installPlanSize = set.getSizing().getDiskSize();
     }
   }
   SizingPhaseSet set = new SizingPhaseSet(new Sizing(100));
   IStatus status = engine.perform(provisioningPlan, set, null);
   if (status.isOK()) {
     return installPlanSize + set.getSizing().getDiskSize();
   }
   return SIZE_UNAVAILABLE;
 }
  /**
   * Tests a JDT feature bundle container contains the appropriate bundles for a specific OS.
   *
   * @throws Exception
   */
  public void testMacOSFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    definition.setOS(Platform.OS_MACOSX);
    ITargetLocation container =
        getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt");
    expected.add("org.eclipse.jdt.launching");
    // 2 versions of JUnit
    expected.add("org.junit");
    expected.add("org.junit");
    expected.add("org.junit4");
    expected.add("org.eclipse.jdt.launching.macosx");

    assertEquals("Wrong number of bundles in JDT feature", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      String symbolicName = bundles[i].getBundleInfo().getSymbolicName();
      expected.remove(symbolicName);
      if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) {
        // the bundle should be missing unless on Mac
        IStatus status = bundles[i].getStatus();
        if (Platform.getOS().equals(Platform.OS_MACOSX)) {
          assertTrue("Mac bundle should be present", status.isOK());
        } else {
          assertFalse("Mac bundle should be missing", status.isOK());
          assertEquals(
              "Mac bundle should be mssing",
              TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST,
              status.getCode());
        }
      }
    }
    Iterator iterator = expected.iterator();
    while (iterator.hasNext()) {
      String name = (String) iterator.next();
      System.err.println("Missing: " + name);
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());

    // should be no source bundles
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle bundle = bundles[i];
      assertFalse("Should be no source bundles", bundle.isSourceBundle());
    }
  }
 @Override
 public void run() {
   if (status != null && !status.isOK()) {
     ErrorDialog.openError(
         Utils.getShell(null), null, TeamUIMessages.RefreshSubscriberJob_3, status);
   } else if (gotoAction != null) {
     gotoAction.run();
   }
 }
 @Override
 public String getToolTipText() {
   if (status != null && !status.isOK()) {
     return status.getMessage();
   }
   if (gotoAction != null) {
     return gotoAction.getToolTipText();
   }
   return Utils.shortenText(
       SynchronizeView.MAX_NAME_LENGTH, RefreshParticipantJob.this.getName());
 }
예제 #5
0
  public void testGetAction() {
    final ArrayList actionsList1 = new ArrayList();
    InstallableUnitPhase phase1 =
        new InstallableUnitPhase("test", 1) {
          protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
            List<ProvisioningAction> actions = getActions(operand.second(), "test1");
            actionsList1.addAll(actions);
            return actions;
          }
        };
    final ArrayList actionsList2 = new ArrayList();
    InstallableUnitPhase phase2 =
        new InstallableUnitPhase("test", 1) {
          protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
            List<ProvisioningAction> actions = getActions(operand.second(), "test2");
            actionsList2.addAll(actions);
            return actions;
          }
        };

    PhaseSet phaseSet = new TestPhaseSet(new Phase[] {phase1, phase2});
    IProfile profile = createProfile("PhaseTest");

    Map instructions = new HashMap();
    instructions.put("test1", MetadataFactory.createTouchpointInstruction("test1.test()", null));
    instructions.put("test2", MetadataFactory.createTouchpointInstruction("test2.test()", null));
    ITouchpointData touchpointData = MetadataFactory.createTouchpointData(instructions);
    IInstallableUnit unit =
        createIU(
            "test",
            Version.create("1.0.0"),
            null,
            NO_REQUIRES,
            new IProvidedCapability[0],
            NO_PROPERTIES,
            ITouchpointType.NONE,
            touchpointData,
            false);
    IProvisioningPlan plan = engine.createPlan(profile, null);
    plan.addInstallableUnit(unit);
    IStatus status = engine.perform(plan, phaseSet, new NullProgressMonitor());
    if (!status.isOK()) {
      fail(status.toString());
    }

    assertEquals(
        TestAction.class,
        ((ParameterizedProvisioningAction) actionsList1.get(0)).getAction().getClass());
    assertEquals(
        TestAction.class,
        ((ParameterizedProvisioningAction) actionsList2.get(0)).getAction().getClass());
  }
예제 #6
0
  private static int collectErrorStatus(OutputStream stream, ArrayList<IStatus> list) {
    IStatus status = getStatus(stream);
    if (!status.isOK()) list.add(status);
    if (status.matches(IStatus.ERROR))
      // Errors past this should be bogus as they rely on output from this step
      return status.getSeverity();

    OutputStream destination = getDestination(stream);
    if (destination == null || !(destination instanceof IStateful)) return status.getSeverity();
    int result = collectErrorStatus(destination, list);
    // TODO greater than test here is a little brittle but it is very unlikely that we will add
    // a new status severity.
    return status.getSeverity() > result ? status.getSeverity() : result;
  }
예제 #7
0
 @Override
 protected IStatus performJob() {
   IStatus result = doClone();
   if (result.isOK()) {
     return result;
   } else {
     try {
       if (project != null) GitCloneHandlerV1.removeProject(user, project);
       else FileUtils.delete(URIUtil.toFile(clone.getContentLocation()), FileUtils.RECURSIVE);
     } catch (IOException e) {
       String msg = "An error occured when cleaning up after a clone failure";
       result =
           new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
     }
     return result;
   }
 }
예제 #8
0
 /** Merges a given IStatus into a MultiStatus */
 protected static void mergeStatus(MultiStatus multi, IStatus status) {
   if (status != null && !status.isOK()) multi.merge(status);
 }
예제 #9
0
    public void update(Observable o, Object arg) {
      final IWorkspace workspace = DLTKUIPlugin.getWorkspace();
      final String name = fNameGroup.getName();
      // check whether the project name field is empty
      if (name.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterProjectName);
        setPageComplete(false);
        return;
      }
      // check whether the project name is valid
      final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT);
      if (!nameStatus.isOK()) {
        setErrorMessage(nameStatus.getMessage());
        setPageComplete(false);
        return;
      }
      // check whether project already exists
      final IProject handle = getProjectHandle();

      if (!isInLocalServer()) {
        if (handle.exists()) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
      String newProjectNameLowerCase = name.toLowerCase();
      for (IProject currentProject : projects) {
        String existingProjectName = currentProject.getName();
        if (existingProjectName.toLowerCase().equals(newProjectNameLowerCase)) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      final String location = fPHPLocationGroup.getLocation().toOSString();
      // check whether location is empty
      if (location.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterLocation);
        setPageComplete(false);
        return;
      }
      // check whether the location is a syntactically correct path
      if (!Path.EMPTY.isValidPath(location)) {
        setErrorMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
        setPageComplete(false);
        return;
      }
      // check whether the location has the workspace as prefix
      IPath projectPath = Path.fromOSString(location);
      if (!fPHPLocationGroup.isInWorkspace() && Platform.getLocation().isPrefixOf(projectPath)) {
        setErrorMessage(
            NewWizardMessages.ScriptProjectWizardFirstPage_Message_cannotCreateInWorkspace);
        setPageComplete(false);
        return;
      }
      // If we do not place the contents in the workspace validate the
      // location.
      if (!fPHPLocationGroup.isInWorkspace()) {
        IEnvironment environment = getEnvironment();
        if (EnvironmentManager.isLocal(environment)) {
          final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
          File file = projectPath.toFile();
          if (!locationStatus.isOK()) {
            setErrorMessage(locationStatus.getMessage());
            setPageComplete(false);
            return;
          }

          if (!canCreate(projectPath.toFile())) {
            setErrorMessage(
                NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
            setPageComplete(false);
            return;
          }
        }
      }

      if (fragment != null) {
        fragment.getWizardModel().putObject("ProjectName", fNameGroup.getName());
        if (!fragment.isComplete()) {
          setErrorMessage((String) fragment.getWizardModel().getObject(ERROR_MESSAGE));
          setPageComplete(false);
          return;
        }
      }

      setPageComplete(true);
      setErrorMessage(null);
      setMessage(null);
    }