You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/02/20 14:53:33 UTC
svn commit: r746241 - in /poi/trunk/src/ooxml:
java/org/apache/poi/openxml4j/opc/
java/org/apache/poi/openxml4j/opc/internal/
java/org/apache/poi/openxml4j/opc/internal/marshallers/
java/org/apache/poi/openxml4j/opc/internal/signature/ java/org/apache/...
Author: yegor
Date: Fri Feb 20 13:53:32 2009
New Revision: 746241
URL: http://svn.apache.org/viewvc?rev=746241&view=rev
Log:
replaced log4j with POILogger in openxml4j, also converted non-ascii characters into unicode to keep javadoc quiet
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java Fri Feb 20 13:53:32 2009
@@ -85,7 +85,8 @@
/**
* TIFF image format.
*
- * @see http://partners.adobe.com/public/developer/tiff/index.html#spec
+ * @see <a href="http://partners.adobe.com/public/developer/tiff/index.html#spec">
+ * http://partners.adobe.com/public/developer/tiff/index.html#spec</a>
*/
public static final String IMAGE_TIFF = "image/tiff";
@@ -94,7 +95,8 @@
/**
* Pict image format.
*
- * @see http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html
+ * @see <a href="http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html">
+ * http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html</a>
*/
public static final String IMAGE_PICT = "image/pict";
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java Fri Feb 20 13:53:32 2009
@@ -32,7 +32,6 @@
import java.util.Hashtable;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -48,6 +47,8 @@
import org.apache.poi.openxml4j.opc.internal.unmarshallers.PackagePropertiesUnmarshaller;
import org.apache.poi.openxml4j.opc.internal.unmarshallers.UnmarshallContext;
import org.apache.poi.openxml4j.util.Nullable;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Represents a container that can store multiple data objects.
@@ -60,7 +61,7 @@
/**
* Logger.
*/
- protected static Logger logger = Logger.getLogger("org.openxml4j.opc");
+ private static POILogger logger = POILogFactory.getLogger(Package.class);
/**
* Default package access.
@@ -340,7 +341,7 @@
public void close() throws IOException {
if (this.packageAccess == PackageAccess.READ) {
logger
- .warn("The close() method is intended to SAVE a package. This package is open in READ ONLY mode, use the revert() method instead !");
+ .log(POILogger.WARN, "The close() method is intended to SAVE a package. This package is open in READ ONLY mode, use the revert() method instead !");
return;
}
@@ -539,7 +540,7 @@
}
} catch (OpenXML4JException e) {
logger
- .warn("Can't retrieve parts by relationship type: an exception has been thrown by getRelationshipsByType method");
+ .log(POILogger.WARN, "Can't retrieve parts by relationship type: an exception has been thrown by getRelationshipsByType method");
return null;
}
return retArr;
@@ -619,7 +620,7 @@
if (unmarshallPart instanceof PackagePropertiesPart)
this.packageProperties = (PackagePropertiesPart) unmarshallPart;
} catch (IOException ioe) {
- logger.warn("Unmarshall operation : IOException for "
+ logger.log(POILogger.WARN, "Unmarshall operation : IOException for "
+ part.partName);
continue;
} catch (InvalidOperationException invoe) {
@@ -650,7 +651,7 @@
* If rule M1.12 is not verified : Packages shall not contain
* equivalent part names and package implementers shall neither
* create nor recognize packages with equivalent part names.
- * @see {@link#createPartImpl(URI, String)}
+ * @see #createPartImpl(PackagePartName, String, boolean)
*/
public PackagePart createPart(PackagePartName partName, String contentType) {
return this.createPart(partName, contentType, true);
@@ -732,7 +733,7 @@
* disk
*
* @return The new part.
- * @see {@link #createPart(PackagePartName, String)}
+ * @see #createPart(PackagePartName, String)
*/
public PackagePart createPart(PackagePartName partName, String contentType,
ByteArrayOutputStream content) {
@@ -846,7 +847,7 @@
sourcePartName = PackagingURIHelper.createPartName(sourceURI);
} catch (InvalidFormatException e) {
logger
- .error("Part name URI '"
+ .log(POILogger.ERROR, "Part name URI '"
+ sourceURI
+ "' is not valid ! This message is not intended to be displayed !");
return;
@@ -947,7 +948,7 @@
this.deletePartRecursive(targetPartName);
}
} catch (InvalidFormatException e) {
- logger.warn("An exception occurs while deleting part '"
+ logger.log(POILogger.WARN, "An exception occurs while deleting part '"
+ partName.getName()
+ "'. Some parts may remain in the package. - "
+ e.getMessage());
@@ -1126,7 +1127,7 @@
*
* @return All package relationships of this package.
* @throws OpenXML4JException
- * @see {@link #getRelationshipsHelper(String)}
+ * @see #getRelationshipsHelper(String)
*/
public PackageRelationshipCollection getRelationships()
throws OpenXML4JException {
@@ -1230,7 +1231,7 @@
try {
partMarshallers.put(new ContentType(contentType), marshaller);
} catch (InvalidFormatException e) {
- logger.warn("The specified content type is not valid: '"
+ logger.log(POILogger.WARN, "The specified content type is not valid: '"
+ e.getMessage() + "'. The marshaller will not be added !");
}
}
@@ -1248,7 +1249,7 @@
try {
partUnmarshallers.put(new ContentType(contentType), unmarshaller);
} catch (InvalidFormatException e) {
- logger.warn("The specified content type is not valid: '"
+ logger.log(POILogger.WARN, "The specified content type is not valid: '"
+ e.getMessage()
+ "'. The unmarshaller will not be added !");
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java Fri Feb 20 13:53:32 2009
@@ -211,12 +211,12 @@
/**
* Add a relationship to a part (except relationships part).
- *
+ * <p>
* Check rule M1.25: The Relationships part shall not have relationships to
* any other part. Package implementers shall enforce this requirement upon
* the attempt to create such a relationship and shall treat any such
* relationship as invalid.
- *
+ * </p>
* @param targetPartName
* Name of the target part. This one must be relative to the
* source root directory of the part.
@@ -281,12 +281,12 @@
/**
* Add a relationship to a part (except relationships part).
- *
+ * <p>
* Check rule M1.25: The Relationships part shall not have relationships to
* any other part. Package implementers shall enforce this requirement upon
* the attempt to create such a relationship and shall treat any such
* relationship as invalid.
- *
+ * </p>
* @param targetURI
* URI of the target part. Must be relative to the source root
* directory of the part.
@@ -572,14 +572,14 @@
}
/**
- * @return
+ * @return true if this part is a relationship
*/
public boolean isRelationshipPart() {
return this.isRelationshipPart;
}
/**
- * @return
+ * @return true if this part has been logically deleted
*/
public boolean isDeleted() {
return isDeleted;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java Fri Feb 20 13:53:32 2009
@@ -29,7 +29,7 @@
* @author Julien Chable
* @version 0.1
*
- * @see http://www.ietf.org/rfc/rfc3986.txt
+ * @see <a href="http://www.ietf.org/rfc/rfc3986.txt">http://www.ietf.org/rfc/rfc3986.txt</a>
*/
public final class PackagePartName implements Comparable<PackagePartName> {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java Fri Feb 20 13:53:32 2009
@@ -60,7 +60,7 @@
private String id;
/**
- * R�f�rence vers le package.
+ * Reference to the package.
*/
private Package container;
@@ -87,7 +87,7 @@
/**
* Constructor.
*
- * @param packageParent
+ * @param pkg
* @param sourcePart
* @param targetUri
* @param targetMode
@@ -170,7 +170,7 @@
/**
*
- * @return
+ * @return URL of the source part of this relationship
*/
public URI getSourceURI() {
if (source == null) {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java Fri Feb 20 13:53:32 2009
@@ -22,13 +22,14 @@
import java.util.Iterator;
import java.util.TreeMap;
-import org.apache.log4j.Logger;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Represents a collection of PackageRelationship elements that are owned by a
@@ -40,7 +41,7 @@
public final class PackageRelationshipCollection implements
Iterable<PackageRelationship> {
- private static Logger logger = Logger.getLogger("org.openxml4j.opc");
+ private static POILogger logger = POILogFactory.getLogger(PackageRelationshipCollection.class);
/**
* Package relationships ordered by ID.
@@ -300,7 +301,7 @@
throws InvalidFormatException {
try {
SAXReader reader = new SAXReader();
- logger.debug("Parsing relationship: " + relPart.getPartName());
+ logger.log(POILogger.DEBUG, "Parsing relationship: " + relPart.getPartName());
Document xmlRelationshipsDoc = reader
.read(relPart.getInputStream());
@@ -352,7 +353,7 @@
if (value.indexOf("\\") != -1) {
logger
- .info("target contains \\ therefore not a valid URI"
+ .log(POILogger.INFO, "target contains \\ therefore not a valid URI"
+ value + " replaced by /");
value = value.replaceAll("\\\\", "/");
// word can save external relationship with a \ instead
@@ -361,14 +362,14 @@
target = new URI(value);
} catch (URISyntaxException e) {
- logger.error("Cannot convert " + value
+ logger.log(POILogger.ERROR, "Cannot convert " + value
+ " in a valid relationship URI-> ignored", e);
continue;
}
addRelationship(target, targetMode, type, id);
}
} catch (Exception e) {
- logger.error(e);
+ logger.log(POILogger.ERROR, e);
throw new InvalidFormatException(e.getMessage());
}
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java Fri Feb 20 13:53:32 2009
@@ -218,13 +218,12 @@
}
/**
- * Combine les deux URI.
+ * Combine two URIs.
*
- * @param prefix
- * L'URI de pr�fixe.
- * @param suffix
- * L'URI de suffixe.
- * @return
+ * @param prefix the prefix URI
+ * @param suffix the suffix URI
+ *
+ * @return the combined URI
*/
public static URI combine(URI prefix, URI suffix) {
URI retUri = null;
@@ -406,11 +405,11 @@
URI relationshipPartUri) {
if (relationshipPartUri == null)
throw new IllegalArgumentException(
- "Le param�tre relationshipPartUri ne doit pas �tre null !");
+ "Must not be null");
if (!isRelationshipPartURI(relationshipPartUri))
throw new IllegalArgumentException(
- "L'URI ne doit pas �tre celle d'une partie de type relation.");
+ "Must be a relationship part");
if (relationshipPartUri.compareTo(PACKAGE_RELATIONSHIPS_ROOT_URI) == 0)
return PACKAGE_ROOT_URI;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java Fri Feb 20 13:53:32 2009
@@ -40,12 +40,12 @@
/**
* Add a relationship to a part (except relationships part).
- *
+ * <p>
* Check rule M1.25: The Relationships part shall not have relationships to
* any other part. Package implementers shall enforce this requirement upon
* the attempt to create such a relationship and shall treat any such
* relationship as invalid.
- *
+ * </p>
* @param targetPartName
* Name of the target part. This one must be relative to the
* source root directory of the part.
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java Fri Feb 20 13:53:32 2009
@@ -28,7 +28,6 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -43,6 +42,8 @@
import org.apache.poi.openxml4j.util.ZipEntrySource;
import org.apache.poi.openxml4j.util.ZipFileZipEntrySource;
import org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Physical zip package.
@@ -52,7 +53,7 @@
*/
public final class ZipPackage extends Package {
- private static Logger logger = Logger.getLogger("org.openxml4j");
+ private static POILogger logger = POILogFactory.getLogger(ZipPackage.class);
/**
* Zip archive, as either a file on disk,
@@ -220,7 +221,7 @@
}
} catch (Exception e) {
// We assume we can continue, even in degraded mode ...
- logger.warn("Entry "
+ logger.log(POILogger.WARN,"Entry "
+ entry.getName()
+ " is not valid, so this part won't be add to the package.");
return null;
@@ -308,7 +309,7 @@
// temporary file
if (!tempFile.delete()) {
logger
- .warn("The temporary file: '"
+ .log(POILogger.WARN,"The temporary file: '"
+ targetFile.getAbsolutePath()
+ "' cannot be deleted ! Make sure that no other application use it.");
}
@@ -353,7 +354,7 @@
* current package
*
*
- * @see #getPart(URI)
+ * @see #getPart(PackageRelationship)
*/
@Override
protected PackagePart getPartImpl(PackagePartName partName) {
@@ -371,7 +372,6 @@
* The stream use to save this package.
*
* @see #save(OutputStream)
- * @see #saveInZip(ZipOutputStream)
*/
@Override
public void saveImpl(OutputStream outputStream) {
@@ -389,7 +389,7 @@
// we save it as well
if (this.getPartsByRelationshipType(
PackageRelationshipTypes.CORE_PROPERTIES).size() == 0) {
- logger.debug("Save core properties part");
+ logger.log(POILogger.DEBUG,"Save core properties part");
// We have to save the core properties part ...
new ZipPackagePropertiesMarshaller().marshall(
@@ -408,13 +408,13 @@
}
// Save package relationships part.
- logger.debug("Save package relationships");
+ logger.log(POILogger.DEBUG,"Save package relationships");
ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
zos);
// Save content type part.
- logger.debug("Save content types part");
+ logger.log(POILogger.DEBUG,"Save content types part");
this.contentTypeManager.save(zos);
// Save parts.
@@ -424,7 +424,7 @@
if (part.isRelationshipPart())
continue;
- logger.debug("Save part '"
+ logger.log(POILogger.DEBUG,"Save part '"
+ ZipHelper.getZipItemNameFromOPCName(part
.getPartName().getName()) + "'");
PartMarshaller marshaller = partMarshallers
@@ -449,7 +449,7 @@
zos.close();
} catch (Exception e) {
logger
- .error("Fail to save: an error occurs while saving the package : "
+ .log(POILogger.ERROR,"Fail to save: an error occurs while saving the package : "
+ e.getMessage());
}
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java Fri Feb 20 13:53:32 2009
@@ -25,28 +25,28 @@
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
/**
- * Represents a immutable MIME ContentType value (RFC 2616 �3.7)
- *
+ * Represents a immutable MIME ContentType value (RFC 2616 §3.7)
+ * <p>
* media-type = type "/" subtype *( ";" parameter ) type = token<br>
* subtype = token<br>
- *
+ * </p><p>
* Rule M1.13 : Package implementers shall only create and only recognize parts
* with a content type; format designers shall specify a content type for each
* part included in the format. Content types for package parts shall fit the
- * definition and syntax for media types as specified in RFC 2616,��3.7.
- *
+ * definition and syntax for media types as specified in RFC 2616, \§3.7.
+ * </p><p>
* Rule M1.14: Content types shall not use linear white space either between the
* type and subtype or between an attribute and its value. Content types also
* shall not have leading or trailing white spaces. Package implementers shall
* create only such content types and shall require such content types when
* retrieving a part from a package; format designers shall specify only such
* content types for inclusion in the format.
- *
+ * </p>
* @author Julien Chable
* @version 0.1
*
- * @see http://www.ietf.org/rfc/rfc2045.txt
- * @see http://www.ietf.org/rfc/rfc2616.txt
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">http://www.ietf.org/rfc/rfc2045.txt</a>
+ * @see <a href="http://www.ietf.org/rfc/rfc2616.txt">http://www.ietf.org/rfc/rfc2616.txt</a>
*/
public final class ContentType {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java Fri Feb 20 13:53:32 2009
@@ -27,7 +27,6 @@
import java.util.Map.Entry;
import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
@@ -42,6 +41,8 @@
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Manage package content types ([Content_Types].xml part).
@@ -51,7 +52,7 @@
*/
public abstract class ContentTypeManager {
- protected static Logger logger = Logger.getLogger("org.openxml4j");
+ private static POILogger logger = POILogFactory.getLogger(ContentTypeManager.class);
/**
* Reference to the package using this content type manager.
@@ -95,7 +96,7 @@
/**
* Constructor. Parses the content of the specified input stream.
*
- * @param archive
+ * @param in
* If different of <i>null</i> then the content types part is
* retrieve and parse.
* @throws InvalidFormatException
@@ -118,43 +119,39 @@
/**
* Build association extention-> content type (will be stored in
* [Content_Types].xml) for example ContentType="image/png" Extension="png"
- *
+ * <p>
* [M2.8]: When adding a new part to a package, the package implementer
* shall ensure that a content type for that part is specified in the
* Content Types stream; the package implementer shall perform the steps
- * described in��9.1.2.3:
- *
+ * described in §9.1.2.3:
+ * </p><p>
* 1. Get the extension from the part name by taking the substring to the
* right of the rightmost occurrence of the dot character (.) from the
* rightmost segment.
- *
+ * </p><p>
* 2. If a part name has no extension, a corresponding Override element
* shall be added to the Content Types stream.
- *
+ * </p><p>
* 3. Compare the resulting extension with the values specified for the
* Extension attributes of the Default elements in the Content Types stream.
* The comparison shall be case-insensitive ASCII.
- *
+ * </p><p>
* 4. If there is a Default element with a matching Extension attribute,
* then the content type of the new part shall be compared with the value of
* the ContentType attribute. The comparison might be case-sensitive and
* include every character regardless of the role it plays in the
* content-type grammar of RFC 2616, or it might follow the grammar of RFC
* 2616.
- *
+ * </p><p>
* a. If the content types match, no further action is required.
- *
+ * </p><p>
* b. If the content types do not match, a new Override element shall be
* added to the Content Types stream. .
- *
+ * </p><p>
* 5. If there is no Default element with a matching Extension attribute, a
* new Default element or Override element shall be added to the Content
* Types stream.
- *
- *
- * @param partUri
- * the uri that will be stored
- * @return <b>false</b> if an error occured.
+ * </p>
*/
public void addContentType(PackagePartName partName, String contentType) {
boolean defaultCTExists = false;
@@ -197,18 +194,19 @@
}
/**
+ * <p>
* Delete a content type based on the specified part name. If the specified
* part name is register with an override content type, then this content
* type is remove, else the content type is remove in the default content
* type list if it exists and if no part is associated with it yet.
- *
+ * </p><p>
* Check rule M2.4: The package implementer shall require that the Content
* Types stream contain one of the following for every part in the package:
* One matching Default element One matching Override element Both a
* matching Default element and a matching Override element, in which case
* the Override element takes precedence.
- *
- * @param partUri
+ * </p>
+ * @param partName
* The part URI associated with the override content type to
* delete.
* @exception InvalidOperationException
@@ -290,34 +288,34 @@
/**
* Get the content type for the specified part, if any.
- *
+ * <p>
* Rule [M2.9]: To get the content type of a part, the package implementer
- * shall perform the steps described in��9.1.2.4:
- *
+ * shall perform the steps described in §9.1.2.4:
+ * </p><p>
* 1. Compare the part name with the values specified for the PartName
* attribute of the Override elements. The comparison shall be
* case-insensitive ASCII.
- *
+ * </p><p>
* 2. If there is an Override element with a matching PartName attribute,
* return the value of its ContentType attribute. No further action is
* required.
- *
+ * </p><p>
* 3. If there is no Override element with a matching PartName attribute,
* then a. Get the extension from the part name by taking the substring to
* the right of the rightmost occurrence of the dot character (.) from the
* rightmost segment. b. Check the Default elements of the Content Types
* stream, comparing the extension with the value of the Extension
* attribute. The comparison shall be case-insensitive ASCII.
- *
+ * </p><p>
* 4. If there is a Default element with a matching Extension attribute,
* return the value of its ContentType attribute. No further action is
* required.
- *
+ * </p><p>
* 5. If neither Override nor Default elements with matching attributes are
* found for the specified part name, the implementation shall not map this
* part name to a part.
- *
- * @param partUri
+ * </p>
+ * @param partName
* The URI part to check.
* @return The content type associated with the URI (in case of an override
* content type) or the extension (in case of default content type),
@@ -460,7 +458,7 @@
* XML parent element use to append this override type element.
* @param entry
* The values to append.
- * @see #save(ZipOutputStream)
+ * @see #save(java.io.OutputStream)
*/
private void appendSpecificTypes(Element root,
Entry<PackagePartName, String> entry) {
@@ -477,7 +475,7 @@
* XML parent element use to append this default type element.
* @param entry
* The values to append.
- * @see #save(ZipOutputStream)
+ * @see #save(java.io.OutputStream)
*/
private void appendDefaultType(Element root, Entry<String, String> entry) {
root.addElement(DEFAULT_TAG_NAME).addAttribute(
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java Fri Feb 20 13:53:32 2009
@@ -29,6 +29,8 @@
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.Package;
import org.apache.poi.openxml4j.opc.StreamHelper;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Zip implementation of the ContentTypeManager.
@@ -38,6 +40,7 @@
* @see ContentTypeManager
*/
public class ZipContentTypeManager extends ContentTypeManager {
+ private static POILogger logger = POILogFactory.getLogger(ZipContentTypeManager.class);
/**
* Delegate constructor to the super constructor.
@@ -81,7 +84,7 @@
}
zos.closeEntry();
} catch (IOException ioe) {
- logger.error("Cannot write: " + CONTENT_TYPES_PART_NAME
+ logger.log(POILogger.ERROR, "Cannot write: " + CONTENT_TYPES_PART_NAME
+ " in Zip !", ioe);
return false;
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java Fri Feb 20 13:53:32 2009
@@ -24,7 +24,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -41,6 +40,8 @@
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.openxml4j.opc.internal.PartMarshaller;
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Zip part marshaller. This marshaller is use to save any part in a zip stream.
@@ -49,7 +50,7 @@
* @version 0.1
*/
public class ZipPartMarshaller implements PartMarshaller {
- private static Logger logger = Logger.getLogger("org.openxml4j");
+ private static POILogger logger = POILogFactory.getLogger(ZipPartMarshaller.class);
/**
* Save the specified part.
@@ -60,7 +61,7 @@
public boolean marshall(PackagePart part, OutputStream os)
throws OpenXML4JException {
if (!(os instanceof ZipOutputStream)) {
- logger.error("Unexpected class " + os.getClass().getName());
+ logger.log(POILogger.ERROR,"Unexpected class " + os.getClass().getName());
throw new OpenXML4JException("ZipOutputStream expected !");
// Normally should happen only in developpement phase, so just throw
// exception
@@ -88,7 +89,7 @@
}
zos.closeEntry();
} catch (IOException ioe) {
- logger.error("Cannot write: " + part.getPartName() + ": in ZIP",
+ logger.log(POILogger.ERROR,"Cannot write: " + part.getPartName() + ": in ZIP",
ioe);
return false;
}
@@ -110,7 +111,7 @@
*
* @param rels
* The relationships collection to marshall.
- * @param relPartURI
+ * @param relPartName
* Part name of the relationship part to marshall.
* @param zos
* Zip output stream in which to save the XML content of the
@@ -137,19 +138,19 @@
.getSourcePartUriFromRelationshipPartUri(relPartName.getURI());
for (PackageRelationship rel : rels) {
- // L'�l�ment de la relation
+ // the relationship element
Element relElem = root
.addElement(PackageRelationship.RELATIONSHIP_TAG_NAME);
- // L'attribut ID
+ // the relationship ID
relElem.addAttribute(PackageRelationship.ID_ATTRIBUTE_NAME, rel
.getId());
- // L'attribut Type
+ // the relationship Type
relElem.addAttribute(PackageRelationship.TYPE_ATTRIBUTE_NAME, rel
.getRelationshipType());
- // L'attribut Target
+ // the relationship Target
String targetValue;
URI uri = rel.getTargetURI();
if (rel.getTargetMode() == TargetMode.EXTERNAL) {
@@ -157,7 +158,7 @@
// alter it etc
targetValue = uri.toString();
- // add TargetMode attribut (as it is external link external)
+ // add TargetMode attribute (as it is external link external)
relElem.addAttribute(
PackageRelationship.TARGET_MODE_ATTRIBUTE_NAME,
"External");
@@ -178,14 +179,13 @@
ZipEntry ctEntry = new ZipEntry(ZipHelper.getZipURIFromOPCName(
relPartName.getURI().toASCIIString()).getPath());
try {
- // Cr�ation de l'entr�e dans le fichier ZIP
zos.putNextEntry(ctEntry);
if (!StreamHelper.saveXmlInStream(xmlOutDoc, zos)) {
return false;
}
zos.closeEntry();
} catch (IOException e) {
- logger.error("Cannot create zip entry " + relPartName, e);
+ logger.log(POILogger.ERROR,"Cannot create zip entry " + relPartName, e);
return false;
}
return true; // success
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java Fri Feb 20 13:53:32 2009
@@ -75,5 +75,4 @@
return false;
}
- // TODO Introduire le concept de partie typ�e d�s cette partie
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java Fri Feb 20 13:53:32 2009
@@ -310,25 +310,26 @@
/**
* Check the element for the following OPC compliance rules:
- *
+ * <p>
* Rule M4.2: A format consumer shall consider the use of the Markup
* Compatibility namespace to be an error.
- *
+ * </p><p>
* Rule M4.3: Producers shall not create a document element that contains
* refinements to the Dublin Core elements, except for the two specified in
* the schema: <dcterms:created> and <dcterms:modified> Consumers shall
* consider a document element that violates this constraint to be an error.
- *
+ * </p><p>
* Rule M4.4: Producers shall not create a document element that contains
* the xml:lang attribute. Consumers shall consider a document element that
* violates this constraint to be an error.
- *
+ * </p><p>
* Rule M4.5: Producers shall not create a document element that contains
* the xsi:type attribute, except for a <dcterms:created> or
* <dcterms:modified> element where the xsi:type attribute shall be present
* and shall hold the value dcterms:W3CDTF, where dcterms is the namespace
* prefix of the Dublin Core namespace. Consumers shall consider a document
* element that violates this constraint to be an error.
+ * </p>
*/
public void checkElementForOPCCompliance(Element el)
throws InvalidFormatException {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java Fri Feb 20 13:53:32 2009
@@ -46,7 +46,7 @@
/**
* Get the store value if any.
*
- * @return
+ * @return the store value
*/
public E getValue() {
return value;
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java?rev=746241&r1=746240&r2=746241&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java Fri Feb 20 13:53:32 2009
@@ -34,7 +34,7 @@
* recognize parts with a content type; format designers shall specify a
* content type for each part included in the format. Content types for
* package parts shall fit the definition and syntax for media types as
- * specified in RFC 2616, §3.7.
+ * specified in RFC 2616, \u00A73.7.
*/
public void testContentTypeValidation() throws InvalidFormatException {
String[] contentTypesToTest = new String[] { "text/xml",
@@ -50,7 +50,7 @@
* recognize parts with a content type; format designers shall specify a
* content type for each part included in the format. Content types for
* package parts shall fit the definition and syntax for media types as
- * specified in RFC 2616, §3.7.
+ * specified in RFC 2616, \u00A3.7.
*
* Check rule M1.14: Content types shall not use linear white space either
* between the type and subtype or between an attribute and its value.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org