Package com.puppetlabs.geppetto.forge.model

Examples of com.puppetlabs.geppetto.forge.model.Metadata


        UIPlugin plugin = UIPlugin.getInstance();
        String owner = null;
        Diagnostic diag = new Diagnostic();
        for(ExportSpec spec : getExportSpecs(whiteCheckedResources)) {
          try {
            Metadata md = getForge().createFromModuleDirectory(
              spec.getModuleRoot(), false, spec.getFileFilter(), null, diag);
            if(md != null) {
              ModuleName name = md.getName();
              if(owner == null)
                owner = name.getOwner();
              else if(!owner.equals(name.getOwner())) {
                setErrorMessage(plugin.getString("_UI_MultipleModuleOwners"));
                return false;
View Full Code Here


    if(candidates == null)
      candidates = refreshCache(dependency.getName());

    int idx = candidates.length;
    while(--idx >= 0) {
      Metadata release = candidates[idx];
      if(vReq == null || vReq.isIncluded(release.getVersion()))
        return release;
    }
    return null;
  }
View Full Code Here

    if(candidates == null)
      candidates = refreshCache(dependency.getName());
    int idx = candidates.length;
    ArrayList<Metadata> matchingReleases = null;
    while(--idx >= 0) {
      Metadata release = candidates[idx];
      if(vReq == null || vReq.isIncluded(release.getVersion())) {
        if(matchingReleases == null)
          matchingReleases = new ArrayList<Metadata>();
        matchingReleases.add(release);
      }
    }
View Full Code Here

          return true;
      return false;
    }

    Metadata getBestMatch() {
      Metadata bestMatch = null;
      for(Metadata release : releases)
        if(bestMatch == null || release.getVersion().compareTo(bestMatch.getVersion()) > 0)
          bestMatch = release;
      return bestMatch;
    }
View Full Code Here

    setWindowTitle(UIPlugin.getLocalString("_UI_NewPuppetModuleProject_title")); //$NON-NLS-1$
  }

  protected void initializeProjectContents(IProgressMonitor monitor) throws Exception {
    SubMonitor submon = SubMonitor.convert(monitor, 100);
    Metadata metadata = new Metadata();
    metadata.setName(ModuleName.create(getModuleOwner(), project.getName().toLowerCase(), true));
    metadata.setVersion(Version.fromString("0.1.0"));

    if(ResourceUtil.getFile(project.getFullPath().append("manifests/init.pp")).exists()) { //$NON-NLS-1$
      File modulefile = project.getLocation().append(MODULEFILE_NAME).toFile(); //$NON-NLS-1$
      submon.worked(20);
View Full Code Here

      boolean moduleFileExists = moduleFile.exists();
      if(moduleFileExists) {
        // Check if this file is viable.
        boolean renameModuleFile = false;
        Diagnostic chain = new Diagnostic();
        Metadata receiver = new Metadata();
        try {
          ModuleUtils.parseModulefile(moduleFile, receiver, chain);
          for(Diagnostic problem : chain)
            if(problem.getSeverity() >= Diagnostic.ERROR) {
              // Trust the metadata.json as the source and recreate the Modulefile
View Full Code Here

    return "pom.xml";
  }

  @Override
  public Metadata performMetadataExtraction(File existingFile, Diagnostic result) throws IOException {
    Metadata metadata = new Metadata();
    String gid = mavenProject.getGroupId();
    String owner = gid.substring(gid.lastIndexOf('.') + 1);
    metadata.setName(ModuleName.create(owner, mavenProject.getArtifactId(), true));
    metadata.setVersion(Version.create(mavenProject.getVersion()));
    metadata.setSummary(mavenProject.getName());

    Scm scm = mavenProject.getScm();
    if(scm != null)
      metadata.setSource(scm.getUrl());

    metadata.setProjectPage(mavenProject.getUrl());

    List<Dependency> forgeDeps = null;
    for(org.apache.maven.model.Dependency dep : mavenProject.getDependencies()) {
      if("test".equals(dep.getScope()))
        continue;

      try {
        org.apache.maven.artifact.versioning.VersionRange vr = org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec(dep.getVersion());
        List<Restriction> restrictions = vr.getRestrictions();
        if(restrictions.size() == 1) {
          Restriction r = restrictions.get(0);
          Version lower = r.getLowerBound() == null
              ? Version.MIN
              : Version.create(r.getLowerBound().toString());
          Version upper = r.getUpperBound() == null
              ? Version.MAX
              : Version.create(r.getUpperBound().toString());

          Dependency forgeDep = new Dependency();
          String dgid = mavenProject.getGroupId();
          String downer = dgid.substring(dgid.lastIndexOf('.') + 1);
          forgeDep.setName(ModuleName.create(downer, dep.getArtifactId(), true));
          forgeDep.setVersionRequirement(VersionRange.create(
            lower, r.isLowerBoundInclusive(), upper, r.isUpperBoundInclusive()));

          if(forgeDeps == null)
            forgeDeps = new ArrayList<Dependency>();
          forgeDeps.add(forgeDep);
        }
      }
      catch(InvalidVersionSpecificationException e) {
        result.addChild(new FileDiagnostic(
          Diagnostic.WARNING, ValidationService.GEPPETTO, e.getMessage(), mavenProject.getFile()));
      }
    }
    metadata.setDependencies(forgeDeps);
    return metadata;
  }
View Full Code Here

    }

    public void toString(StringBuilder bld) {
      dependencyToString(dependency, bld);
      bld.append("->");
      Metadata md = metadata.getMetadata();
      md.getName().toString(bld);
      bld.append('/');
      md.getVersion().toString(bld);
    }
View Full Code Here

    if(fileFilter == null)
      fileFilter = moduleFileFilter;

    File[] extractedFrom = new File[1];

    Metadata md = createFromModuleDirectory(moduleSource, true, fileFilter, extractedFrom, result);
    if(result.getSeverity() >= ERROR)
      return null;

    if(resultingMetadata != null)
      resultingMetadata[0] = md;

    if(md == null)
      // Metadata could not be read. Errors are in result
      return null;

    for(File tst = destination; tst != null; tst = tst.getParentFile()) {
      if(fileFilter.accept(tst))
        // Destination folder might reside inside of the module when it
        // has been excluded.
        break;

      if(tst.equals(moduleSource))
        throw new IllegalArgumentException("Destination cannot reside within the module itself");
    }

    ModuleName fullName = md.getName();
    Version ver = md.getVersion();
    if(fullName == null || ver == null)
      // Reason has been added to the Diagnostic result
      return null;

    /**
 
View Full Code Here

  @Override
  public List<File> changes(File path, FileFilter fileFilter) throws IOException {
    if(fileFilter == null)
      fileFilter = moduleFileFilter;
    Metadata md = loadJSONMetadata(new File(path, METADATA_JSON_NAME));
    List<File> result = new ArrayList<File>();
    Checksums.appendChangedFiles(md.getChecksums(), path, result, fileFilter);
    return result;
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.forge.model.Metadata

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.