import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.io.XmlSourceUtil;
import org.apache.fop.util.DefaultErrorListener;
import org.apache.fop.util.UnclosableInputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
+
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.StreamedResourceGroup;
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
/**
* Manages the streaming of the AFP output
import java.net.URI;
-import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.fonts.FontManager;
/**
* @return the default base URI
*/
URI getDefaultBaseURI();
+
+ /** @see FopFactoryConfig#getFallbackResolver() */
+ FallbackResolver getFallbackResolver();
}
import java.net.URI;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.RestrictedFallbackResolver;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.UnrestrictedFallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontCacheManager;
import org.apache.fop.fonts.FontCacheManagerFactory;
return new Profile(defaultBaseUri, resourceResolver,
createFontManager(defaultBaseUri, resourceResolver,
FontDetectorFactory.createDefault(),
- FontCacheManagerFactory.createDefault()));
+ FontCacheManagerFactory.createDefault()),
+ new UnrestrictedFallbackResolver());
}
/**
return new Profile(defaultBaseUri, resourceResolver,
createFontManager(defaultBaseUri, resourceResolver,
FontDetectorFactory.createDisabled(),
- FontCacheManagerFactory.createDisabled()));
+ FontCacheManagerFactory.createDisabled()),
+ new RestrictedFallbackResolver());
}
private static final class Profile implements EnvironmentProfile {
private final URI defaultBaseURI;
+ private final FallbackResolver fallbackResolver;
+
private Profile(URI defaultBaseURI, ResourceResolver resourceResolver,
- FontManager fontManager) {
+ FontManager fontManager, FallbackResolver fallbackResolver) {
if (defaultBaseURI == null) {
throw new IllegalArgumentException("Default base URI must not be null");
}
this.defaultBaseURI = defaultBaseURI;
this.resourceResolver = resourceResolver;
this.fontManager = fontManager;
+ this.fallbackResolver = fallbackResolver;
}
public ResourceResolver getResourceResolver() {
public URI getDefaultBaseURI() {
return defaultBaseURI;
}
+
+ public FallbackResolver getFallbackResolver() {
+ return fallbackResolver;
+ }
}
private static FontManager createFontManager(URI defaultBaseUri, ResourceResolver resourceResolver,
/** Set of keywords applicable to this document. */
protected String keywords = null;
- private ImageSessionContext imageSessionContext = new AbstractImageSessionContext() {
-
- public ImageContext getParentContext() {
- return factory;
- }
-
- public float getTargetResolution() {
- return FOUserAgent.this.getTargetResolution();
- }
-
- public Source resolveURI(String uri) {
- return FOUserAgent.this.resolveURI(uri);
- }
-
- };
+ private final ImageSessionContext imageSessionContext;
/**
* Main constructor. <b>This constructor should not be called directly. Please use the
* @param resourceResolver the resolver used to acquire resources
* @see org.apache.fop.apps.FopFactory
*/
- FOUserAgent(FopFactory factory, InternalResourceResolver resourceResolver) {
+ FOUserAgent(final FopFactory factory, InternalResourceResolver resourceResolver) {
this.factory = factory;
this.resourceResolver = resourceResolver;
setTargetResolution(factory.getTargetResolution());
setAccessibility(factory.isAccessibilityEnabled());
+ imageSessionContext = new AbstractImageSessionContext(factory.getFallbackResolver()) {
+
+ public ImageContext getParentContext() {
+ return factory;
+ }
+
+ public float getTargetResolution() {
+ return FOUserAgent.this.getTargetResolution();
+ }
+
+ public Source resolveURI(String uri) {
+ return FOUserAgent.this.resolveURI(uri);
+ }
+ };
}
/**
import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry;
import org.apache.xmlgraphics.image.loader.util.Penalty;
+import org.apache.xmlgraphics.io.ResourceResolver;
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.hyphenation.HyphenationTreeCache;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.apps.io.InternalResourceResolver;
return config.getFontManager();
}
+ /** @see FopFactoryConfig#getFallbackResolver() */
+ FallbackResolver getFallbackResolver() {
+ return config.getFallbackResolver();
+ }
+
/**
* Returns the color space cache for this instance.
* <p>
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
public Map<String, String> getHyphenationPatternNames() {
return hyphPatNames;
}
+
+ public FallbackResolver getFallbackResolver() {
+ return enviro.getFallbackResolver();
+ }
}
private interface FopFactoryConfigBuilder {
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
/** @return the hyphenation pattern names */
Map<String, String> getHyphenationPatternNames();
+
+ /**
+ * Controls the mechanisms that are used in the event that {@link javax.xml.transform.Source}
+ * used for resources couldn't be read.
+ * @return the fallback resolver
+ */
+ FallbackResolver getFallbackResolver();
}
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
import org.apache.xmlgraphics.util.uri.DataURIResolver;
/**
* This object holds the base URI from which to resolve URIs against as well as the resolver for
* resource acquisition. It also does some URI sanitization of common URI syntactical errors. This
- * class takes in a {@link org.apache.fop.apps.io.ResourceResolver} and delegates all relevant
+ * class takes in a {@link org.apache.xmlgraphics.io.ResourceResolver} and delegates all relevant
* URIs to it.
*/
public class InternalResourceResolver {
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps.io;
-
-import java.io.FilterInputStream;
-import java.io.InputStream;
-
-/**
- * This class represents a resolved resource. The type property is used by FOP to identify the resource
- * content.
- *
- */
-public class Resource extends FilterInputStream {
-
- private final String type;
-
- /**
- * @param type resource type
- * @param inputStream input stream of the resource
- */
- public Resource(String type, InputStream inputStream) {
- super(inputStream);
- this.type = type;
- }
-
- /**
- * Constructs a resource of 'unknown' type.
- *
- * @param inputStream input stream of the resource
- */
- public Resource(InputStream inputStream) {
- this("unknown", inputStream);
- }
-
- /**
- * @return the resource type
- */
- public String getType() {
- return this.type;
- }
-
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps.io;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-
-/**
- * Implementations of this resource resolver allow FOP users to control the URI resolution
- * mechanism. All resource and output stream acquisition goes through this when its implementation
- * is given to the {@link org.apache.fop.apps.EnvironmentProfile}.
- */
-public interface ResourceResolver {
-
- /**
- * Get a resource given the URI pointing to said resource.
- *
- * @param uri the resource URI
- * @return the resource
- * @throws IOException if an I/O error occured during resource acquisition
- */
- Resource getResource(URI uri) throws IOException;
-
- /**
- * Gets an output stream of a given URI.
- *
- * @param uri the output stream URI
- * @return the output stream
- * @throws IOException if an I/O error occured while creating an output stream
- */
- OutputStream getOutputStream(URI uri) throws IOException;
-
-}
import java.util.HashMap;
import java.util.Map;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
+import org.apache.xmlgraphics.io.TempResourceResolver;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
+
/**
* A factory class for {@link ResourceResolver}s.
*/
}
/**
- * Creates a temporary-resource-schema aware resource resolver. Temporary resource URIs are
+ * Creates a temporary-resource-scheme aware resource resolver. Temporary resource URIs are
* created by {@link TempResourceURIGenerator}.
*
- * @param tempResourceResolver the temporary-resource-schema resolver to use
+ * @param tempResourceResolver the temporary-resource-scheme resolver to use
* @param defaultResourceResolver the default resource resolver to use
* @return the ressource resolver
*/
}
/**
- * This creates the builder class for binding URI schemas to implementations of
- * {@link ResourceResolver}. This allows users to define their own URI schemas such that they
+ * This creates the builder class for binding URI schemes to implementations of
+ * {@link ResourceResolver}. This allows users to define their own URI schemes such that they
* have finer control over the acquisition of resources.
*
* @param defaultResolver the default resource resolver that should be used in the event that
- * none of the other registered resolvers match the schema
- * @return the schema aware {@link ResourceResolver} builder
+ * none of the other registered resolvers match the scheme
+ * @return the scheme aware {@link ResourceResolver} builder
*/
- public static SchemaAwareResourceResolverBuilder createSchemaAwareResourceResolverBuilder(
+ public static SchemeAwareResourceResolverBuilder createSchemeAwareResourceResolverBuilder(
ResourceResolver defaultResolver) {
- return new SchemaAwareResourceResolverBuilderImpl(defaultResolver);
+ return new SchemeAwareResourceResolverBuilderImpl(defaultResolver);
}
private static final class DefaultResourceResolver implements ResourceResolver {
this.defaultResourceResolver = defaultResourceResolver;
}
- private static boolean isTempUri(URI uri) {
- return TempResourceURIGenerator.isTempUri(uri);
+ private static boolean isTempURI(URI uri) {
+ return TempResourceURIGenerator.isTempURI(uri);
}
/** {@inheritDoc} */
public Resource getResource(URI uri) throws IOException {
- if (isTempUri(uri)) {
+ if (isTempURI(uri)) {
return tempResourceResolver.getResource(uri.getPath());
} else {
return defaultResourceResolver.getResource(uri);
/** {@inheritDoc} */
public OutputStream getOutputStream(URI uri) throws IOException {
- if (isTempUri(uri)) {
+ if (isTempURI(uri)) {
return tempResourceResolver.getOutputStream(uri.getPath());
} else {
return defaultResourceResolver.getOutputStream(uri);
}
}
- private static final class SchemaAwareResourceResolver implements ResourceResolver {
+ private static final class SchemeAwareResourceResolver implements ResourceResolver {
- private final Map<String, ResourceResolver> schemaHandlingResourceResolvers;
+ private final Map<String, ResourceResolver> schemeHandlingResourceResolvers;
private final ResourceResolver defaultResolver;
- private SchemaAwareResourceResolver(
- Map<String, ResourceResolver> schemaHandlingResourceResolvers,
+ private SchemeAwareResourceResolver(
+ Map<String, ResourceResolver> schemEHandlingResourceResolvers,
ResourceResolver defaultResolver) {
- this.schemaHandlingResourceResolvers = schemaHandlingResourceResolvers;
+ this.schemeHandlingResourceResolvers = schemEHandlingResourceResolvers;
this.defaultResolver = defaultResolver;
}
- private ResourceResolver getResourceResolverForSchema(URI uri) {
- String schema = uri.getScheme();
- if (schemaHandlingResourceResolvers.containsKey(schema)) {
- return schemaHandlingResourceResolvers.get(schema);
+ private ResourceResolver getResourceResolverForScheme(URI uri) {
+ String scheme = uri.getScheme();
+ if (schemeHandlingResourceResolvers.containsKey(scheme)) {
+ return schemeHandlingResourceResolvers.get(scheme);
} else {
return defaultResolver;
}
/** {@inheritDoc} */
public Resource getResource(URI uri) throws IOException {
- return getResourceResolverForSchema(uri).getResource(uri);
+ return getResourceResolverForScheme(uri).getResource(uri);
}
/** {@inheritDoc} */
public OutputStream getOutputStream(URI uri) throws IOException {
- return getResourceResolverForSchema(uri).getOutputStream(uri);
+ return getResourceResolverForScheme(uri).getOutputStream(uri);
}
}
/**
* Implementations of this interface will be builders for {@link ResourceResolver}, they bind
- * URI schemas to their respective resolver. This gives users more control over the mechanisms
+ * URI schemes to their respective resolver. This gives users more control over the mechanisms
* by which URIs are resolved.
* <p>
* Here is an example of how this could be used:
* </p>
* <p><code>
- * SchemaAwareResourceResolverBuilder builder
- * = ResourceResolverFactory.createSchemaAwareResourceResolverBuilder(defaultResolver);
- * builder.registerResourceResolverForSchema("test", testResolver);
- * builder.registerResourceResolverForSchema("anotherTest", test2Resolver);
+ * SchemeAwareResourceResolverBuilder builder
+ * = ResourceResolverFactory.createSchemeAwareResourceResolverBuilder(defaultResolver);
+ * builder.registerResourceResolverForScheme("test", testResolver);
+ * builder.registerResourceResolverForScheme("anotherTest", test2Resolver);
* ResourceResolver resolver = builder.build();
* </code></p>
* This will result in all URIs for the form "test:///..." will be resolved using the
* <code>testResolver</code> object; URIs of the form "anotherTest:///..." will be resolved
* using <code>test2Resolver</code>; all other URIs will be resolved from the defaultResolver.
*/
- public interface SchemaAwareResourceResolverBuilder {
+ public interface SchemeAwareResourceResolverBuilder {
/**
- * Register a schema with its respective {@link ResourceResolver}. This resolver will be
- * used as the only resolver for the specified schema.
+ * Register a scheme with its respective {@link ResourceResolver}. This resolver will be
+ * used as the only resolver for the specified scheme.
*
- * @param schema the schema to be used with the given resolver
+ * @param scheme the scheme to be used with the given resolver
* @param resourceResolver the resource resolver
*/
- void registerResourceResolverForSchema(String schema, ResourceResolver resourceResolver);
+ void registerResourceResolverForScheme(String scheme, ResourceResolver resourceResolver);
/**
* Builds a {@link ResourceResolver} that will delegate to the respective resource resolver
- * when a registered URI schema is given
+ * when a registered URI scheme is given
*
- * @return a resolver that delegates to the appropriate schema resolver
+ * @return a resolver that delegates to the appropriate scheme resolver
*/
ResourceResolver build();
}
- private static final class CompletedSchemaAwareResourceResolverBuilder
- implements SchemaAwareResourceResolverBuilder {
+ private static final class CompletedSchemeAwareResourceResolverBuilder
+ implements SchemeAwareResourceResolverBuilder {
- private static final SchemaAwareResourceResolverBuilder INSTANCE
- = new CompletedSchemaAwareResourceResolverBuilder();
+ private static final SchemeAwareResourceResolverBuilder INSTANCE
+ = new CompletedSchemeAwareResourceResolverBuilder();
/** {@inheritDoc} */
public ResourceResolver build() {
}
/** {@inheritDoc} */
- public void registerResourceResolverForSchema(String schema,
+ public void registerResourceResolverForScheme(String scheme,
ResourceResolver resourceResolver) {
throw new IllegalStateException("Resource resolver already built");
}
}
- private static final class ActiveSchemaAwareResourceResolverBuilder
- implements SchemaAwareResourceResolverBuilder {
+ private static final class ActiveSchemeAwareResourceResolverBuilder
+ implements SchemeAwareResourceResolverBuilder {
- private final Map<String, ResourceResolver> schemaHandlingResourceResolvers
+ private final Map<String, ResourceResolver> schemeHandlingResourceResolvers
= new HashMap<String, ResourceResolver>();
private final ResourceResolver defaultResolver;
- private ActiveSchemaAwareResourceResolverBuilder(ResourceResolver defaultResolver) {
+ private ActiveSchemeAwareResourceResolverBuilder(ResourceResolver defaultResolver) {
this.defaultResolver = defaultResolver;
}
/** {@inheritDoc} */
- public void registerResourceResolverForSchema(String schema,
+ public void registerResourceResolverForScheme(String scheme,
ResourceResolver resourceResolver) {
- schemaHandlingResourceResolvers.put(schema, resourceResolver);
+ schemeHandlingResourceResolvers.put(scheme, resourceResolver);
}
/** {@inheritDoc} */
public ResourceResolver build() {
- return new SchemaAwareResourceResolver(
- Collections.unmodifiableMap(schemaHandlingResourceResolvers), defaultResolver);
+ return new SchemeAwareResourceResolver(
+ Collections.unmodifiableMap(schemeHandlingResourceResolvers), defaultResolver);
}
}
- private static final class SchemaAwareResourceResolverBuilderImpl
- implements SchemaAwareResourceResolverBuilder {
+ private static final class SchemeAwareResourceResolverBuilderImpl
+ implements SchemeAwareResourceResolverBuilder {
- private SchemaAwareResourceResolverBuilder delegate;
+ private SchemeAwareResourceResolverBuilder delegate;
- private SchemaAwareResourceResolverBuilderImpl(ResourceResolver defaultResolver) {
- this.delegate = new ActiveSchemaAwareResourceResolverBuilder(defaultResolver);
+ private SchemeAwareResourceResolverBuilderImpl(ResourceResolver defaultResolver) {
+ this.delegate = new ActiveSchemeAwareResourceResolverBuilder(defaultResolver);
}
/** {@inheritDoc} */
- public void registerResourceResolverForSchema(String schema,
+ public void registerResourceResolverForScheme(String scheme,
ResourceResolver resourceResolver) {
- delegate.registerResourceResolverForSchema(schema, resourceResolver);
+ delegate.registerResourceResolverForScheme(scheme, resourceResolver);
}
/** {@inheritDoc} */
public ResourceResolver build() {
ResourceResolver resourceResolver = delegate.build();
- delegate = CompletedSchemaAwareResourceResolverBuilder.INSTANCE;
+ delegate = CompletedSchemeAwareResourceResolverBuilder.INSTANCE;
return resourceResolver;
}
}
-
}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps.io;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Implementations of this interface resolve URIs for temporary files used by FOP. The temporary-
- * resource URI scheme comes from {@link TempResourceURIGenerator#TMP_SCHEMA}.
- */
-public interface TempResourceResolver {
-
- /**
- * Get a temporary-resource given the URI pointing to said resource.
- *
- * @param uri the resource URI
- * @return the resource
- * @throws IOException if an I/O error occured during resource acquisition
- */
- Resource getResource(String uri) throws IOException;
-
- /**
- * Gets an temporary-output stream of a given URI.
- *
- * @param uri the output stream URI
- * @return the output stream
- * @throws IOException if an I/O error occured while creating an output stream
- */
- OutputStream getOutputStream(String uri) throws IOException;
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.fop.apps.io;
-
-import java.net.URI;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Creates a URI for any temporary resource used within FOP.
- */
-public final class TempResourceURIGenerator {
-
- public static final String TMP_SCHEMA = "tmp";
-
- private final String tempURIPrefix;
-
- private final AtomicLong counter;
-
- /**
- * @param uriPrefix a prefix used to name the unique URI
- */
- public TempResourceURIGenerator(String uriPrefix) {
- counter = new AtomicLong();
- tempURIPrefix = URI.create(TMP_SCHEMA + ":///" + uriPrefix).toASCIIString();
- }
-
- /**
- * Generate a unique URI for a temporary resource
- * @return the URI
- */
- public URI generate() {
- return URI.create(tempURIPrefix + getUniqueId());
- }
-
- private String getUniqueId() {
- return Long.toHexString(counter.getAndIncrement());
- }
-
- public static boolean isTempUri(URI uri) {
- return TMP_SCHEMA.equals(uri.getScheme());
- }
-}
import org.apache.commons.io.IOUtils;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
import org.apache.fop.fonts.FontInfo;
/**
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.substitute.FontSubstitutions;
import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.io.XmlSourceUtil;
import org.apache.xmlgraphics.util.MimeConstants;
import org.apache.xmlgraphics.util.UnitConv;
}
}
if (info != null) {
- ImageUtil.closeQuietly(src); //Image is fully read
+ XmlSourceUtil.closeQuietly(src); //Image is fully read
}
return info;
}
DOMSource domSrc = (DOMSource)src;
doc = (SVGDocument)domSrc.getNode();
} else {
- in = new UnclosableInputStream(ImageUtil.needInputStream(src));
+ in = new UnclosableInputStream(XmlSourceUtil.needInputStream(src));
int length = in.available();
in.mark(length + 1);
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.io.XmlSourceUtil;
import org.apache.fop.util.UnclosableInputStream;
}
}
if (info != null) {
- ImageUtil.closeQuietly(src); //Image is fully read
+ XmlSourceUtil.closeQuietly(src); //Image is fully read
}
return info;
}
ImageContext context) {
// parse document and get the size attributes of the svg element
- InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src));
+ InputStream in = new UnclosableInputStream(XmlSourceUtil.needInputStream(src));
try {
in.mark(4 + 1);
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
import org.apache.xmlgraphics.java2d.Dimension2DDouble;
import org.apache.xmlgraphics.ps.DSCConstants;
import org.apache.xmlgraphics.ps.PSDictionary;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
import org.apache.fop.render.intermediate.IFContext;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FopFactoryBuilder;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.apps.io.Resource;
-import org.apache.fop.apps.io.ResourceResolver;
/**
* Example servlet to generate a PDF from a servlet.
import org.apache.xpath.XPathAPI;
import org.apache.xpath.objects.XObject;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FopFactoryBuilder;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.apps.io.Resource;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.render.xml.XMLRenderer;
import org.junit.Test;
-import org.apache.fop.apps.io.ResourceResolver;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
public class EnvironmentalProfileFactoryTestCase {
private final URI testURI = URI.create("this.is.purely.for.test.purposes");
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
public Map<String, String> getHyphenationPatternNames() {
return delegate.getHyphenationPatternNames();
}
+
+ public FallbackResolver getFallbackResolver() {
+ return delegate.getFallbackResolver();
+ }
}
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import static org.junit.Assert.assertTrue;
+import org.apache.xmlgraphics.io.Resource;
+
public class FontURIResolver extends BaseURIResolutionTest {
public enum Event {
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
+import org.apache.xmlgraphics.io.TempResourceResolver;
+
public class ResourceResolverFactoryTestCase {
private static final byte[] DATA = new byte[]{(byte) 0, (byte) 1, (byte) 2};
final ResourceResolver sut;
TestCreateSchemaAwareResourceResolverBuilderHelper() {
- ResourceResolverFactory.SchemaAwareResourceResolverBuilder builder
- = ResourceResolverFactory.createSchemaAwareResourceResolverBuilder(
+ ResourceResolverFactory.SchemeAwareResourceResolverBuilder builder
+ = ResourceResolverFactory.createSchemeAwareResourceResolverBuilder(
defaultResourceResolver);
- builder.registerResourceResolverForSchema(SCHEMA, registedResourceResolver);
+ builder.registerResourceResolverForScheme(SCHEMA, registedResourceResolver);
sut = builder.build();
}
import java.util.HashMap;
import java.util.Map;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
abstract class TestingResourceResolver implements ResourceResolver {
private final Map<URI, Object> checker;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
public class URIResolverWrapperTestCase {
private static final List<String> BASE_URIS = Collections.unmodifiableList(Arrays.asList(
import org.apache.xpath.XPathAPI;
import org.apache.xpath.objects.XObject;
+import org.apache.fop.apps.EnvironmentProfile;
+import org.apache.fop.apps.EnvironmentalProfileFactory;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FopFactoryBuilder;
+import org.apache.fop.apps.io.ResourceResolverFactory;
/**
* Helper class for running FOP tests.
public FopFactory getFopFactory(Document testDoc) {
boolean base14KerningEnabled = isBase14KerningEnabled(testDoc);
boolean strictValidation = isStrictValidation(testDoc);
- FopFactoryBuilder builder = new FopFactoryBuilder(testDir.getParentFile().toURI());
+ EnvironmentProfile envProfile = EnvironmentalProfileFactory.createRestrictedIO(
+ testDir.getParentFile().toURI(),
+ ResourceResolverFactory.createDefaultResourceResolver());
+ FopFactoryBuilder builder = new FopFactoryBuilder(envProfile);
builder.setStrictFOValidation(strictValidation);
builder.getFontManager().setBase14KerningEnabled(base14KerningEnabled);
return builder.build();
import static org.junit.Assert.assertEquals;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.CIDSet;
import org.apache.fop.fonts.CIDSubset;