Search in sources :

Example 6 with InvalidAttributeException

use of org.apache.aries.application.InvalidAttributeException in project aries by apache.

the class ModelledResourceManagerImpl method model.

private ModelledResource model(String uri, BundleManifest bm, ParsedServiceElements pse) throws ModellerException {
    Attributes attributes = bm.getRawAttributes();
    ModelledResource mbi = null;
    try {
        mbi = _modellingManager.getModelledResource(uri, attributes, pse.getReferences(), pse.getServices());
    } catch (InvalidAttributeException iae) {
        ModellerException me = new ModellerException(iae);
        _logger.debug(LOG_EXIT, "getModelledResource", me);
        throw me;
    }
    _logger.debug(LOG_EXIT, "getModelledResource", mbi);
    return mbi;
}
Also used : InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) Attributes(java.util.jar.Attributes) ModellerException(org.apache.aries.application.modelling.ModellerException) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Example 7 with InvalidAttributeException

use of org.apache.aries.application.InvalidAttributeException in project aries by apache.

the class ModellingHelperImpl method buildFragmentHost_.

public static ImportedBundle buildFragmentHost_(String fragmentHostHeader) throws InvalidAttributeException {
    logger.debug(LOG_ENTRY, "buildFragmentHost_", new Object[] { fragmentHostHeader });
    if (fragmentHostHeader == null) {
        return null;
    }
    Map<String, Map<String, String>> parsedFragHost = ManifestHeaderProcessor.parseImportString(fragmentHostHeader);
    if (parsedFragHost.size() != 1)
        throw new InvalidAttributeException(MessageUtil.getMessage("MORE_THAN_ONE_FRAG_HOST", new Object[] { fragmentHostHeader }, "An internal error occurred. A bundle fragment manifest must define exactly one Fragment-Host entry. The following entry was found" + fragmentHostHeader + "."));
    String hostName = parsedFragHost.keySet().iterator().next();
    Map<String, String> attribs = parsedFragHost.get(hostName);
    String bundleVersion = attribs.remove(BUNDLE_VERSION_ATTRIBUTE);
    if (bundleVersion != null && attribs.get(VERSION_ATTRIBUTE) == null) {
        attribs.put(VERSION_ATTRIBUTE, bundleVersion);
    }
    attribs.put(ModellingConstants.OBR_SYMBOLIC_NAME, hostName);
    String filter = ManifestHeaderProcessor.generateFilter(attribs);
    ImportedBundle result = new ImportedBundleImpl(filter, attribs);
    logger.debug(LOG_EXIT, "buildFragmentHost_", result);
    return result;
}
Also used : InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) ImportedBundleImpl(org.apache.aries.application.modelling.impl.ImportedBundleImpl) ImportedBundle(org.apache.aries.application.modelling.ImportedBundle) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with InvalidAttributeException

use of org.apache.aries.application.InvalidAttributeException in project aries by apache.

the class OBRAriesResolver method toImportedBundle.

private Collection<ImportedBundle> toImportedBundle(Collection<Content> content) throws ResolverException {
    log.debug(LOG_ENTRY, "toImportedBundle", content);
    List<ImportedBundle> result = new ArrayList<ImportedBundle>();
    for (Content c : content) {
        try {
            result.add(modellingManager.getImportedBundle(c.getContentName(), c.getVersion().toString()));
        } catch (InvalidAttributeException iae) {
            throw new ResolverException(iae);
        }
    }
    log.debug(LOG_EXIT, "toImportedBundle", result);
    return result;
}
Also used : ResolverException(org.apache.aries.application.management.ResolverException) InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) Content(org.apache.aries.application.Content) ArrayList(java.util.ArrayList) ImportedBundle(org.apache.aries.application.modelling.ImportedBundle)

Example 9 with InvalidAttributeException

use of org.apache.aries.application.InvalidAttributeException in project aries by apache.

the class DeploymentManifestManagerImpl method toImportedBundle.

/**
   * Covert a collection of contents to a collection of ImportedBundle objects
   * @param content a collection of content
   * @return a collection of ImportedBundle objects
   * @throws ResolverException
   */
private Set<ImportedBundle> toImportedBundle(Collection<Content> content) throws ResolverException {
    _logger.debug(LOG_ENTRY, "toImportedBundle", new Object[] { content });
    Set<ImportedBundle> result = new HashSet<ImportedBundle>();
    for (Content c : content) {
        try {
            result.add(modellingManager.getImportedBundle(c.getContentName(), c.getVersion().toString()));
        } catch (InvalidAttributeException iax) {
            ResolverException rx = new ResolverException(iax);
            _logger.debug(LOG_EXIT, "toImportedBundle", new Object[] { rx });
            throw rx;
        }
    }
    _logger.debug(LOG_EXIT, "toImportedBundle", new Object[] { result });
    return result;
}
Also used : ResolverException(org.apache.aries.application.management.ResolverException) InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) Content(org.apache.aries.application.Content) ImportedBundle(org.apache.aries.application.modelling.ImportedBundle) HashSet(java.util.HashSet)

Example 10 with InvalidAttributeException

use of org.apache.aries.application.InvalidAttributeException in project aries by apache.

the class DeploymentMetadataImpl method getFilters.

private Collection<Filter> getFilters(String filterString) throws InvalidAttributeException {
    Collection<Filter> filters = new ArrayList<Filter>();
    List<String> fs = ManifestProcessor.split(filterString, ",");
    if ((fs != null) && (!!!fs.isEmpty())) {
        for (String filter : fs) {
            try {
                filters.add(FrameworkUtil.createFilter(FilterUtils.removeMandatoryFilterToken(filter)));
            } catch (InvalidSyntaxException ise) {
                InvalidAttributeException iae = new InvalidAttributeException(ise);
                throw iae;
            }
        }
    }
    return filters;
}
Also used : InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) Filter(org.osgi.framework.Filter) ArrayList(java.util.ArrayList) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException)

Aggregations

InvalidAttributeException (org.apache.aries.application.InvalidAttributeException)10 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ResolverException (org.apache.aries.application.management.ResolverException)4 ImportedBundle (org.apache.aries.application.modelling.ImportedBundle)4 HashSet (java.util.HashSet)3 Content (org.apache.aries.application.Content)3 ModelledResource (org.apache.aries.application.modelling.ModelledResource)3 Map (java.util.Map)2 ImportedPackage (org.apache.aries.application.modelling.ImportedPackage)2 Filter (org.osgi.framework.Filter)2 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)2 List (java.util.List)1 Set (java.util.Set)1 Attributes (java.util.jar.Attributes)1 BundleInfo (org.apache.aries.application.management.BundleInfo)1 PreResolveHook (org.apache.aries.application.management.spi.resolve.PreResolveHook)1 DeployedBundles (org.apache.aries.application.modelling.DeployedBundles)1 ExportedPackage (org.apache.aries.application.modelling.ExportedPackage)1 ExportedService (org.apache.aries.application.modelling.ExportedService)1