Package com.puppetlabs.geppetto.forge.model

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


      // parse the "Modulefile/metadata.json" and get full name and version, use this as name of target entry
      // TODO: Improve this to report diagnostics
      try {
        Diagnostic diag = new Diagnostic();
        Metadata metadata = forge.createFromModuleDirectory(moduleDir, false, null, null, diag);
        if(metadata != null) {
          for(Dependency d : metadata.getDependencies()) {
            IProject best = getBestMatchingProject(d);
            if(best != null)
              result.add(best.getName());
            else {
              // TODO: need to inform the user about this somehow, but can't create markers here
View Full Code Here


    setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportdir_wiz.png"));//$NON-NLS-1$
    setNeedsProgressMonitor(true);
  }

  protected boolean isValidModule(File moduleDirectory, FileFilter filter) {
    Metadata md;
    try {
      md = forge.createFromModuleDirectory(moduleDirectory, false, filter, null, new Diagnostic());
      return md != null && md.getName() != null && md.getName().getOwner() != null &&
          md.getName().getName() != null && md.getVersion() != null;
    }
    catch(IOException e) {
    }
    return false;
  }
View Full Code Here

          if(!project.hasNature(XtextProjectHelper.NATURE_ID))
            continue;

          for(File moduleRoot : forge.findModuleRoots(project.getLocation().toFile(), null)) {
            Metadata metadata = forge.createFromModuleDirectory(moduleRoot, false, null, null, chain);
            addDependencyIfNotPresent(metadata, modules, always);
          }
        }
        catch(Exception e) {
          UIPlugin.getInstance().log(e);
View Full Code Here

      AllModuleReferences exportData) {

    // create node data for all existing modules and check if there are ambiguities
    Multimap<ModuleName, ModuleNodeData> processedModules = ArrayListMultimap.create();
    for(MetadataInfo mi : moduleData.values()) {
      Metadata m = mi.getMetadata();
      ModuleNodeData mnd = ModuleNodeData.existing(m.getName(), m.getVersion(), mi.isRole(), toHREF_URL(mi));
      moduleNodeData.put(mi, mnd);
      processedModules.put(m.getName(), mnd);
    }
    for(ModuleName key : processedModules.keySet()) {
      Collection<ModuleNodeData> modules = processedModules.get(key);
      if(modules.size() > 1) {
        int counter = 0;
        for(ModuleNodeData mnd : modules)
          mnd.setAmbiguous(++counter);
      }
    }
    // moduleData is keyed by "fullName" to lower case

    // Create pseudo module for non modular content
    nonModularNode = ModuleNodeData.root(root);
    pptpNode = new ModuleNodeData(ModuleName.create("root", "puppet", false), null, ModuleType.PPTP, ""); // will not be rendered

    // create module nodes for missing (unsatisfied dependencies)
    // unless dependency is to represented module name, but version is not matched (in which case
    // the unmatched but existing node is used.
    // if a dependency appears more than once, use the first (skip the rest with same name)
    for(MetadataInfo mi : moduleData.values()) {
      final ModuleNodeData a = moduleNodeData.get(mi);
      Set<ModuleName> processed = Sets.newHashSet();
      for(Dependency d : mi.getUnresolvedDependencies()) {
        final ModuleName name = d.getName();
        if(!processed.add(name))
          continue;
        Collection<MetadataInfo> existingVersions = moduleData.get(name);
        ModuleNodeData b = null;
        if(existingVersions == null || existingVersions.size() < 1) {
          b = moduleNodeData.get(name);
          if(b == null) {
            // need a node for the missing module
            b = ModuleNodeData.unresolved(name);
            // need to generate one that can not be found if name is null
            moduleNodeData.put(name == null
                ? ModuleName.create("no", "name", false)
                : name, b);
          }
        }
        else {
          // pick (one of) the existing versions (it is actually illegal to have more
          // than one, so just pick the first one).
          MetadataInfo first = Iterables.get(existingVersions, 0);
          b = moduleNodeData.get(first);
        }
        createUnresolvedEdge(a, b, d);
      }
      // Add edges for all resolved dependencies
      for(MetadataInfo.Resolution r : mi.getResolvedDependencies()) {
        createResolvedEdge(a, moduleNodeData.get(r.metadata), r.dependency);
      }
    }
    Map<File, ModuleNodeData> fileIndex = Maps.newHashMap();
    for(Map.Entry<Object, ModuleNodeData> m : moduleNodeData.entrySet()) {
      if(!(m.getKey() instanceof ModuleName)) {
        MetadataInfo mi = (MetadataInfo) m.getKey();
        fileIndex.put(mi.getFile(), m.getValue());
      }
    }
    Map<File, Multimap<File, Export>> ambiguities = exportData.getAmbiguityMap();
    for(Map.Entry<File, Multimap<File, AllModuleReferences.Export>> x : exportData.getImportMap().entrySet()) {
      // get the imported
      File fromFile = x.getKey();
      Multimap<File, Export> m = x.getValue();

      // get any ambiguities
      Multimap<File, Export> ambiguitiesForFile = ambiguities.get(fromFile);
      for(File toFile : m.keySet()) {
        createImportEdge(
          file2Module(fromFile, fileIndex), file2Module(toFile, fileIndex), m.get(toFile),
          ambiguitiesForFile != null
              ? ambiguitiesForFile.get(toFile)
              : null);
      }
    }
View Full Code Here

public class ForgeServiceTest extends AbstractForgeTest {

  @Test
  public void testLoadJSONMetadata__File() {
    try {
      Metadata md = getForgeUtil().loadJSONMetadata(getTestData("puppetlabs-apache/metadata.json"));
      assertEquals("Unexpected module name", ModuleName.fromString("puppetlabs-apache"), md.getName());
    }
    catch(IOException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

    // collect info in a structure
    Multimap<ModuleName, MetadataInfo> moduleData = ArrayListMultimap.create();
    for(File mdRoot : mdRoots) {
      // load and remember all that loaded ok
      File[] mdProvider = new File[1];
      Metadata m;
      try {
        m = forge.createFromModuleDirectory(mdRoot, true, null, mdProvider, diagnostics);
      }
      catch(IOException e) {
        addFileError(
          diagnostics, mdProvider[0], mdRoot, "Can not parse file: " + e.getMessage(),
          IValidationConstants.ISSUE__MODULEFILE_PARSE_ERROR);
        m = null;
      }
      if(m == null)
        worked(ticker, 1);
      else {
        File f = mdProvider[0];
        ModuleName moduleName = m.getName();
        if(options.isCheckModuleSemantics() && isOnPath(pathToFile(f.getAbsolutePath(), root), searchPath)) {
          // remember the metadata and where it came from
          // and if it represents a NODE as opposed to a regular MODULE
          moduleData.put(
            moduleName, new MetadataInfo(m, f, nodeRootPath.isPrefixOf(new Path(f.getAbsolutePath()))));
View Full Code Here

   */
  private void validateModulefile(Diagnostic diagnostics, File parentFile, ValidationOptions options,
      IProgressMonitor monitor) {
    SubMonitor ticker = SubMonitor.convert(monitor, 11);
    File[] mdProvider = new File[1];
    Metadata metadata = loadModuleMetadata(diagnostics, parentFile, mdProvider, ticker.newChild(1));
    if(metadata == null)
      return; // failed in some way and should have reported this

    validateModuleMetadata(metadata, diagnostics, mdProvider[0], parentFile, options, ticker.newChild(10));
  }
View Full Code Here

      File installFolder = getTestOutputFolder("apache-install-here", true);
      File resultFolder = getTestOutputFolder("apache-build-result", true);
      FileUtils.cpR(getTestData("puppetlabs-apache"), installFolder, ModuleUtils.DEFAULT_FILE_FILTER, false, true);
      Metadata[] mdHandle = new Metadata[1];
      fixture.build(installFolder, resultFolder, null, mdHandle, null, new Diagnostic());
      Metadata md = mdHandle[0];
      String archiveName = md.getName().toString() + '-' + md.getVersion();
      File builtArchive = new File(resultFolder, archiveName + ".tar.gz");
      assertTrue("Build did not build any archive", builtArchive.canRead());
      File unpackFolder = getTestOutputFolder("apache-unpack-result", true);
      InputStream input = new GZIPInputStream(new FileInputStream(builtArchive));
      try {
View Full Code Here

  }

  @Test
  public void generate() {
    try {
      Metadata metadata = new Metadata();
      metadata.setName(ModuleName.fromString("cloudsmith/testmodule"));
      File installFolder = getTestOutputFolder("testmodule-install", true);
      installFolder.delete();
      fixture.generate(installFolder, metadata);
    }
    catch(IOException e) {
View Full Code Here

public class ModuleUtilsTest extends AbstractForgeTest {

  @Test
  public void loadModule() {
    try {
      Metadata md = getForgeUtil().createFromModuleDirectory(
        getTestData("puppetlabs-apache"), false, null, null, new Diagnostic());
      assertEquals("Unexpected module name", ModuleName.fromString("puppetlabs-apache"), md.getName());
    }
    catch(IOException e) {
      fail(e.getMessage());
    }
  }
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.