@Override protected String getId(PmSession session) throws CommandExecutionException { String filePath = (String) getValue(FILE_OPTION_NAME); if (filePath == null) { filePath = getOptionValue(FILE_OPTION_NAME); if (filePath == null) { return super.getId(session); } } Path path; try { path = Util.resolvePath(session.getAeshContext(), filePath); } catch (IOException ex) { throw new CommandExecutionException(ex.getMessage()); } if (!Files.exists(path)) { return null; } try { return FeaturePackDescriber.readSpec(path).getFPID().toString(); } catch (ProvisioningException ex) { throw new CommandExecutionException(session, CliErrors.retrieveFeaturePackID(), ex); } }
/** * Adds feature-pack archive to the local provisioning feature-pack cache. * Optionally, installs the feature-pack archive to the universe repository. * * @param featurePack feature-pack archive * @param installInUniverse whether to install the feature-pack into the universe repository * @return feature-pack location which was added to the local cache * @throws ProvisioningException in case of a failure */ public synchronized FeaturePackLocation addLocal(Path featurePack, boolean installInUniverse) throws ProvisioningException { final FPID fpid = FeaturePackDescriber.readSpec(featurePack).getFPID(); cacheManager.put(featurePack, fpid); if(!installInUniverse) { return fpid.getLocation(); } if(universeInstallers == null) { universeInstallers = UniverseFeaturePackInstaller.load(); } final Universe<?> universe = universeResolver.getUniverse(fpid.getUniverse()); final UniverseFeaturePackInstaller fpInstaller = universeInstallers.get(universe.getFactoryId()); if(fpInstaller == null) { throw new ProvisioningException(Errors.featurePackInstallerNotFound(universe.getFactoryId(), universeInstallers.keySet())); } fpInstaller.install(universe, fpid, featurePack); return fpid.getLocation(); }