public FeaturePackDescription build() throws ProvisioningDescriptionException { return new FeaturePackDescription(this); } }
@SuppressWarnings("unchecked") public T addLocalFeaturePack(Path path) throws ProvisioningException { if (path == null) { return (T) this; } try { FeaturePackDescription featurePackLayout = FeaturePackDescriber.describeFeaturePackZip(path); getLocalFeaturePacks().put(featurePackLayout.getFPID(), path); return (T) this; } catch (IOException e) { throw new ProvisioningException(e); } }
public static FeaturePackDescription describeFeaturePack(Path fpDir, String encoding) throws ProvisioningDescriptionException { assertDirectory(fpDir); final Path fpXml = fpDir.resolve(Constants.FEATURE_PACK_XML); if(!Files.exists(fpXml)) { throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpXml)); } final FeaturePackDescription.Builder layoutBuilder; try (Reader is = Files.newBufferedReader(fpXml, Charset.forName(encoding))) { final FeaturePackSpec.Builder specBuilder = FeaturePackSpec.builder(); XmlParsers.parse(is, specBuilder); layoutBuilder = FeaturePackDescription.builder(specBuilder); } catch (IOException e) { throw new ProvisioningDescriptionException(Errors.openFile(fpXml)); } catch (XMLStreamException e) { throw new ProvisioningDescriptionException(Errors.parseXml(fpXml), e); } final Path packagesDir = fpDir.resolve(Constants.PACKAGES); if(Files.exists(packagesDir)) { processPackages(layoutBuilder, packagesDir, encoding); } return layoutBuilder.build(); }