Package org.pentaho.reporting.libraries.resourceloader

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


                               final String path,
                               final Map<? extends ParameterKey, ? extends Object> factoryKeys) throws ResourceKeyCreationException
  {
    if (isSupportedKey(parent) == false)
    {
      throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
    }

    final String entry;
    final String identifier = (String) parent.getIdentifier();
    if (path != null)
    {
      if (path.length() > 0 && path.charAt(0) == '/')
      {
        entry = LoaderUtils.stripLeadingSlashes(path);
      }
      else
      {
        entry = LoaderUtils.mergePaths(identifier, path);
      }
    }
    else
    {
      entry = identifier;
    }

    final Map<ParameterKey, Object> map;
    if (factoryKeys != null)
    {
      map = new HashMap<ParameterKey, Object>();
      map.putAll(parent.getFactoryParameters());
      map.putAll(factoryKeys);
    }
    else
    {
      map = parent.getFactoryParameters();
    }

    if ("true".equals(LibDocBundleBoot.getInstance().getGlobalConfig().getConfigProperty
        ("org.pentaho.reporting.libraries.docbundle.bundleloader.directory.StrictKeyCheck", "true")))
    {
      try
      {
        final FileRepository repository = (FileRepository)
            parent.getFactoryParameters().get(new FactoryParameterKey("repository"));
        if (RepositoryUtilities.isExistsEntity(repository, RepositoryUtilities.split(entry, "/")) == false)
        {
          throw new ResourceKeyCreationException("The key does not exist: " + entry);
        }
      }
      catch (ContentIOException e)
      {
        throw new ResourceKeyCreationException("Failed to check for existing key", e);
      }
    }

    return new ResourceKey(parent.getParent(), parent.getSchema(), entry, map);
  }
View Full Code Here


                               final String path,
                               final Map<? extends ParameterKey, ? extends Object> factoryKeys) throws ResourceKeyCreationException
  {
    if (isSupportedKey(parent) == false)
    {
      throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
    }

    final String entry;
    final String identifier = (String) parent.getIdentifier();
    if (path != null)
    {
      if (path.length() > 0 && path.charAt(0) == '/')
      {
        entry = LoaderUtils.stripLeadingSlashes(path);
      }
      else
      {
        entry = LoaderUtils.mergePaths(identifier, path);
      }
    }
    else
    {
      entry = identifier;
    }

    final Map<ParameterKey, Object> map;
    if (factoryKeys != null)
    {
      map = new HashMap<ParameterKey, Object>();
      map.putAll(parent.getFactoryParameters());
      map.putAll(factoryKeys);
    }
    else
    {
      map = parent.getFactoryParameters();
    }
    if ("true".equals(LibDocBundleBoot.getInstance().getGlobalConfig().getConfigProperty
        ("org.pentaho.reporting.libraries.docbundle.bundleloader.zip.StrictKeyCheck", "true")))
    {
      try
      {
        final ZipReadRepository repository = (ZipReadRepository)
            parent.getFactoryParameters().get(new FactoryParameterKey("repository"));
        if (RepositoryUtilities.isExistsEntity(repository, RepositoryUtilities.split(entry, "/")) == false)
        {
          throw new ResourceKeyCreationException("The key does not exist: " + entry);
        }
      }
      catch (ContentIOException e)
      {
        throw new ResourceKeyCreationException("Failed to check for existing key", e);
      }
    }

    return new ResourceKey(parent.getParent(), parent.getSchema(), entry, map);
  }
View Full Code Here

      throw new NullPointerException();
    }
   
    if (isSupportedKey(parent) == false)
    {
      throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
    }

    try
    {
      final File target;
      if (path != null)
      {
        final File parentResource = (File) parent.getIdentifier();
        target = new File(parentResource.getCanonicalFile().getParentFile(), path);
        if (target.exists() == false || target.isDirectory() == false)
        {
          throw new ResourceKeyCreationException("Malformed value: " + path + " (" + target + ')');
        }

      }
      else
      {
        target = (File) parent.getIdentifier();
      }

      final Map map;
      if (factoryKeys != null)
      {
        map = new HashMap();
        map.putAll(parent.getFactoryParameters());
        map.putAll(factoryKeys);
      }
      else
      {
        map = parent.getFactoryParameters();
      }
      return new ResourceKey(parent.getSchema(), target, map);
    }
    catch (IOException ioe)
    {
      throw new ResourceKeyCreationException("Failed to create key", ioe);
    }
  }
View Full Code Here

    throw new ResourceLoadingException("This resource Loader cannot be used to create a ResourceData object.");
  }

  public ResourceKey deserialize(final ResourceKey bundleKey, final String stringKey) throws ResourceKeyCreationException
  {
    throw new ResourceKeyCreationException("This resource Loader cannot be used to deserialize ReousrceKeys");
  }
View Full Code Here

    final ResourceKey bundleKey = getBundleMainKey().getParent();
    final ResourceBundleLoader o = (ResourceBundleLoader)
        bundleKey.getFactoryParameters().get(new FactoryParameterKey("repository-loader"));
    if (o == null)
    {
      throw new ResourceKeyCreationException("Unable to create a inner-bundle key, no loader available.");
    }
    return o.deriveKey(getBundleMainKey(), entryName, factoryParameters);
  }
View Full Code Here

      throw new NullPointerException();
    }

    if (isSupportedKey(parent) == false)
    {
      throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
    }

    final String entry;
    final String identifier = (String) parent.getIdentifier();
    if (path != null)
    {
      if (path.length() > 0 && path.charAt(0) == '/')
      {
        entry = LoaderUtils.stripLeadingSlashes(path);
      }
      else
      {
        entry = LoaderUtils.mergePaths(identifier, path);
      }
    }
    else
    {
      entry = identifier;
    }

    final Map<ParameterKey, Object> map;
    if (factoryKeys != null)
    {
      map = new HashMap<ParameterKey, Object>();
      map.putAll(parent.getFactoryParameters());
      map.putAll(factoryKeys);
    }
    else
    {
      map = parent.getFactoryParameters();
    }

    if ("true".equals(LibDocBundleBoot.getInstance().getGlobalConfig().getConfigProperty
        ("org.pentaho.reporting.libraries.docbundle.bundleloader.repository.StrictKeyCheck", "true")))
    {
      try
      {
        final String[] name = RepositoryUtilities.split(entry, "/");
        if (RepositoryUtilities.isExistsEntity(repository, name) == false)
        {
          throw new ResourceKeyCreationException("The derived entry does not exist in this bundle.");
        }
      }
      catch (ContentIOException e)
      {
        throw new ResourceKeyCreationException("Error checking whether the derived entry exists in the bundle.");
      }
    }

    return new ResourceKey(parent.getParent(), parent.getSchema(), entry, map);
  }
View Full Code Here

    final ResourceKeyData resourceKeyData = ResourceKeyUtils.parse(stringKey);

    // Validate the data
    if (INNER_SCHEMA.equals(resourceKeyData.getSchema()) == false)
    {
      throw new ResourceKeyCreationException("Serialized version of key does not contain correct schema");
    }

    return new ResourceKey(bundleKey, resourceKeyData.getSchema(),
        resourceKeyData.getIdentifier(), resourceKeyData.getFactoryParameters());
  }
View Full Code Here

                               final String path,
                               final Map factoryKeys) throws ResourceKeyCreationException
  {
    if (isSupportedKey(parent) == false)
    {
      throw new ResourceKeyCreationException();
    }
    final RepositoryResourceBundleLoader o = (RepositoryResourceBundleLoader)
        parent.getFactoryParameters().get(new FactoryParameterKey("repository-loader"));

    if ("true".equals(LibDocBundleBoot.getInstance().getGlobalConfig().getConfigProperty
        ("org.pentaho.reporting.libraries.docbundle.bundleloader.memory.StrictKeyCheck", "true")))
    {
      try
      {
        final Repository repository = (Repository) parent.getFactoryParameters().get(new FactoryParameterKey("repository"));
        if (RepositoryUtilities.isExistsEntity(repository, RepositoryUtilities.split(path, "/")) == false)
        {
          throw new ResourceKeyCreationException("The key does not exist: " + path);
        }
      }
      catch (ContentIOException e)
      {
        throw new ResourceKeyCreationException("Failed to check for existing key", e);
      }
    }

    return o.deriveKey(parent, path, factoryKeys);
  }
View Full Code Here

            final Map factoryKeys)
            throws ResourceKeyCreationException
    {
        if (!isSupportedKey(parent))
        {
            throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
        }

        final InputResourceKey parentKey = (InputResourceKey) parent.getIdentifier();
        final String resource;
        if (path.startsWith("sun:oo://"))
View Full Code Here

  public ResourceKey deriveKey(final ResourceKey parent, final String path, final Map factoryKeys)
      throws ResourceKeyCreationException
  {
    if (isSupportedKey(parent) == false)
    {
      throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
    }

    final String entry;
    if (path != null)
    {
View Full Code Here

TOP

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

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.