You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Pruitt, Byron S" <st...@hp.com> on 2011/07/20 23:02:01 UTC
InvalidOperation retrieving InputStream
I am having a problem with the openxml4j library in poi 3.7.
OPCPackage pkg = OPCPackage.open(filePath);
PackagePartName corePartName = PackagingURIHelper.createPartName("/docProps/core.xml");
PackagePart dCore = pkg.getPart(corePartName);
System.out.println(dCore.getContentType());
System.out.println(dCore.getPartName().getName());
InputStream strmCore = dCore.getInputStream();
The above code produces this exception:
org.apache.poi.openxml4j.exceptions.InvalidOperationException: Operation not authorized
at org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart.getInputStreamImpl(PackagePropertiesPart.java:599)
at org.apache.poi.openxml4j.opc.PackagePart.getInputStream(PackagePart.java:466)
at com.test.DocTest.main(DocTest.java:42)
Line 42 is the getInputStream call. The two sys outs show the expected values. I must be missing something very obvious.
Thanks for any help.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: InvalidOperation retrieving InputStream
Posted by "Pruitt, Byron S" <st...@hp.com>.
Yes, of course. This is a classic example of assuming the problem is harder than it really is. The PackageProperties works for what I need.
Thanks.
-----Original Message-----
From: Nick Burch [mailto:nick.burch@alfresco.com]
Sent: Thursday, July 21, 2011 9:26 AM
To: POI Users List
Subject: RE: InvalidOperation retrieving InputStream
On Thu, 21 Jul 2011, Pruitt, Byron S wrote:
> I simply need to extract it for read only purposes.
You have two choices. One is to use the methods provided by POI to read
and manipulate the core properties part - PackagePropertiesPart
The other, if you don't want any of the checking or validation or helpers,
is simply just to open the file as a regular .zip and read the core part
from that
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: InvalidOperation retrieving InputStream
Posted by Nick Burch <ni...@alfresco.com>.
On Thu, 21 Jul 2011, Pruitt, Byron S wrote:
> I simply need to extract it for read only purposes.
You have two choices. One is to use the methods provided by POI to read
and manipulate the core properties part - PackagePropertiesPart
The other, if you don't want any of the checking or validation or helpers,
is simply just to open the file as a regular .zip and read the core part
from that
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: InvalidOperation retrieving InputStream
Posted by "Pruitt, Byron S" <st...@hp.com>.
I simply need to extract it for read only purposes.
-----Original Message-----
From: Nick Burch [mailto:nick.burch@alfresco.com]
Sent: Wednesday, July 20, 2011 6:42 PM
To: POI Users List
Subject: Re: InvalidOperation retrieving InputStream
On Wed, 20 Jul 2011, Pruitt, Byron S wrote:
> I am having a problem with the openxml4j library in poi 3.7.
>
> OPCPackage pkg = OPCPackage.open(filePath);
> PackagePartName corePartName = PackagingURIHelper.createPartName("/docProps/core.xml");
> PackagePart dCore = pkg.getPart(corePartName);
>
> System.out.println(dCore.getContentType());
> System.out.println(dCore.getPartName().getName());
>
> InputStream strmCore = dCore.getInputStream();
I think you're not supposed to work with the core part in this way. It's a
special part with certain restrictions, which POI enforces
What were you hoping to do with the core part? (There may well be a better
way to do it)
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: InvalidOperation retrieving InputStream
Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 20 Jul 2011, Pruitt, Byron S wrote:
> I am having a problem with the openxml4j library in poi 3.7.
>
> OPCPackage pkg = OPCPackage.open(filePath);
> PackagePartName corePartName = PackagingURIHelper.createPartName("/docProps/core.xml");
> PackagePart dCore = pkg.getPart(corePartName);
>
> System.out.println(dCore.getContentType());
> System.out.println(dCore.getPartName().getName());
>
> InputStream strmCore = dCore.getInputStream();
I think you're not supposed to work with the core part in this way. It's a
special part with certain restrictions, which POI enforces
What were you hoping to do with the core part? (There may well be a better
way to do it)
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org