Package org.pentaho.reporting.libraries.resourceloader

Examples of org.pentaho.reporting.libraries.resourceloader.ResourceKey


    final Object attribute = definition.getAttribute(AttributeNames.Wizard.NAMESPACE, "source");
    if (attribute != null)
    {
      try
      {
        final ResourceKey contentBase = definition.getContentBase();
        final ResourceKey resourceKey = resourceManager.deriveKey(contentBase, String.valueOf(attribute));
        final Resource resource = resourceManager.create(resourceKey, contentBase, WizardSpecification.class);
        return (WizardSpecification) resource.getResource();
      }
      catch (ResourceKeyCreationException e)
      {
        throw new ReportProcessingException("Failed to load the wizard-specification", e);
      }
      catch (ResourceException e)
      {
        throw new ReportProcessingException("Failed to load the wizard-specification", e);
      }
    }

    try
    {
      final ResourceKey contentBase = definition.getContentBase();
      final ResourceKey resourceKey = resourceManager.deriveKey(contentBase, "wizard-specification.xml");
      final Resource resource = resourceManager.create(resourceKey, contentBase, WizardSpecification.class);
      return (WizardSpecification) resource.getResource();
    }
    catch (final ResourceKeyCreationException e)
    {
View Full Code Here


    }

    final String valueRole = metaData.getValueRole();
    if ("Content".equals(valueRole))
    {
      final ResourceKey contentBase = getContentBase(element);
      final ResourceKey elementSource = getDefinitionSource(element);
      if (attributeValue instanceof ResourceKey)
      {
        final ResourceKey path = (ResourceKey) attributeValue;
        final boolean linked = BundleUtilities.isSameBundle(elementSource, path);
        return new ResourceReference[]{new ResourceReference(path, linked)};
      }
      else if (attributeValue instanceof String && contentBase != null)
      {
        try
        {
          // not a resource-key, so try to make one ..
          final ResourceKey path = resourceManager.deriveKey(contentBase, String.valueOf(attributeValue));
          // the content base may not point to a bundle location, so that the path does not point to a
          // bundle location as well. If linked is computed to false, we can be sure that the resource is loaded
          // from within the bundle, which means that the attribute value was a relative path inside the bundle.
          final boolean linked = BundleUtilities.isSameBundle(elementSource, path) == false;
          return new ResourceReference[]{new ResourceReference(path, linked)};
        }
        catch (ResourceKeyCreationException rce)
        {
          // ignore ..
        }
      }
      else if (attributeValue != null)
      {
        try
        {
          // not a resource-key, so try to make one ..
          final ResourceKey path = resourceManager.createKey(attributeValue);
          final boolean linked = BundleUtilities.isSameBundle(elementSource, path) == false;
          return new ResourceReference[]{new ResourceReference(path, linked)};
        }
        catch (ResourceKeyCreationException rce)
        {
View Full Code Here

      throw new NullPointerException();
    }
    final String propertyRole = metaData.getPropertyRole();
    if ("Content".equals(propertyRole))
    {
      final ResourceKey contentBase = reportElement.getContentBase();
      final ResourceKey elementSource = reportElement.getDefinitionSource();
      if (attributeValue instanceof ResourceKey)
      {
        final ResourceKey path = (ResourceKey) attributeValue;
        final boolean linked = BundleUtilities.isSameBundle(elementSource, path);
        return new ResourceReference[]{new ResourceReference(path, linked)};
      }
      else if (attributeValue instanceof String && contentBase != null)
      {
        try
        {
          // not a resource-key, so try to make one ..
          final ResourceKey path = resourceManager.deriveKey(contentBase, String.valueOf(attributeValue));
          // the content base may not point to a bundle location, so that the path does not point to a
          // bundle location as well. If linked is computed to false, we can be sure that the resource is loaded
          // from within the bundle, which means that the attribute value was a relative path inside the bundle.
          final boolean linked = BundleUtilities.isSameBundle(elementSource, path) == false;
          return new ResourceReference[]{new ResourceReference(path, linked)};
        }
        catch (ResourceKeyCreationException rce)
        {
          // ignore ..
        }
      }
      else if (attributeValue != null)
      {
        try
        {
          // not a resource-key, so try to make one ..
          final ResourceKey path = resourceManager.createKey(attributeValue);
          final boolean linked = BundleUtilities.isSameBundle(elementSource, path) == false;
          return new ResourceReference[]{new ResourceReference(path, linked)};
        }
        catch (ResourceKeyCreationException rce)
        {
View Full Code Here

  protected void startParsing(final Attributes attrs) throws SAXException
  {
    super.startParsing(attrs);

    final ResourceManager resourceManager = getRootHandler().getResourceManager();
    final ResourceKey context = getRootHandler().getContext();

    final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
    final Iterator keys = configuration.findPropertyKeys(ElementMetaDataParser.GLOBAL_INCLUDES_PREFIX);
    while (keys.hasNext())
    {
      final String key = (String) keys.next();
      final String href = configuration.getConfigProperty(key);
      if (StringUtils.isEmpty(href, true))
      {
        continue;
      }
      try
      {
        final ResourceKey resourceKey = resourceManager.deriveKey(context, href);
        final Resource resource = resourceManager.create(resourceKey, null, GlobalMetaDefinition.class);
        globalMetaDefinition.merge((GlobalMetaDefinition) resource.getResource());
      }
      catch (ResourceException e)
      {
View Full Code Here

    {
      throw new ParseException("Required attribute 'src' is missing", getLocator());
    }

    final ResourceManager resourceManager = getRootHandler().getResourceManager();
    final ResourceKey context = getRootHandler().getContext();
    try
    {
      final ResourceKey resourceKey = resourceManager.deriveKey(context, href);
      final Resource resource = resourceManager.create(resourceKey, null, GlobalMetaDefinition.class);
      result = (GlobalMetaDefinition) resource.getResource();
    }
    catch (ResourceException e)
    {
View Full Code Here

    }

    try
    {
      final ResourceManager resourceManager = runtime.getProcessingContext().getResourceManager();
      final ResourceKey chartKey;
      if (value instanceof String)
      {
        chartKey = resourceManager.deriveKey(runtime.getProcessingContext().getContentBase(), (String) value);
      }
      else
View Full Code Here

      return value;
    }

    try
    {
      final ResourceKey contentBase = runtime.getProcessingContext().getContentBase();
      final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
      final ResourceKey key;
      if (value instanceof ResourceKey)
      {
        key = (ResourceKey) value;
      }
      else if (value instanceof Blob)
      {
        final Blob b = (Blob) value;
        final byte[] data = IOUtils.getInstance().readBlob(b);
        key = resManager.createKey(data);
      }
      else if (value instanceof String)
      {
        final Object baseURL = element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.CONTENT_BASE);
        if (baseURL != null)
        {
          final ResourceKey baseKey = resManager.createKey(baseURL);
          key = resManager.deriveKey(baseKey, (String) value);
        }
        else
        {
          key = resManager.deriveKey(contentBase, (String) value);
View Full Code Here

    if (baseKey != null)
    {
      try
      {
        final ResourceKey resourceKey = manager.deriveKey(baseKey, propsName);
        final ResourceData resource = manager.load(resourceKey);

        final InputStream instream = resource.getResourceAsStream(manager);
        try
        {
          final LibLoaderResourceBundle resourceBundle = new LibLoaderResourceBundle(instream);
          successfulLoads.put(propsName, resourceBundle);
          return resourceBundle;
        }
        finally
        {
          instream.close();
        }
      }
      catch (Exception e)
      {
        // silently ignore ..
      }
    }

    try
    {
      // try to load the bundle via classpath ...
      final ResourceKey resourceKey = manager.createKey("res://" + propsName); // NON-NLS
      final ResourceData resource = manager.load(resourceKey);

      final InputStream instream = resource.getResourceAsStream(manager);
      try
      {
View Full Code Here

        return null;
      }
    }
    try
    {
      final ResourceKey contentBase = runtime.getProcessingContext().getContentBase();
      final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
      final ResourceKey key;
      if (value instanceof ResourceKey)
      {
        key = (ResourceKey) value;
      }
      else if (value instanceof Blob)
      {
        final Blob b = (Blob) value;
        final byte[] data = IOUtils.getInstance().readBlob(b);
        key = resManager.createKey(data);
      }
      else if (value instanceof String)
      {
        final Object baseURL = element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.CONTENT_BASE);
        if (baseURL instanceof String)
        {
          final ResourceKey baseKey = createKeyFromString(resManager, null, (String) baseURL);
          key = createKeyFromString(resManager, baseKey, (String) value);
        }
        else if (baseURL instanceof ResourceKey)
        {
          final ResourceKey baseKey = (ResourceKey) baseURL;
          key = createKeyFromString(resManager, baseKey, (String) value);
        }
        else if (baseURL != null)
        {
          // if a base-url object is given, we assume that it is indeed valid.
          final ResourceKey baseKey = resManager.createKey(baseURL);
          key = createKeyFromString(resManager, baseKey, (String) value);
        }
        else
        {
          key = createKeyFromString(resManager, contentBase, (String) value);
View Full Code Here

    else
    {
      elementStyle = styleCache.getStyleSheet(element.getStyle());
    }

    final ResourceKey rawKey;
    if (rawValue instanceof ResourceKey)
    {
      rawKey = (ResourceKey) rawValue;
    }
    else
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.resourceloader.ResourceKey

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.