[daisy] Q : Java API - setPart Unhandled Exception

Andreas Deininger adeininger at googlemail.com
Tue Jun 26 02:00:19 CDT 2007


2007/6/25, Brandt Solovij <bso at qad.com>:
>
> Hey everyone, I'm a bit green to the Daisy Java API. My experience thus far
> with it is limited, though I have successfully read a huge text file,
> created 17k xml documents, then with the API imported them into my daisy
> instance with Field value pairs and such all correctly configured...
>
> which is why this is irking me :
>
> I'm trying to import an image via the Java API, but my IDE  (eclipse) keeps
> choking on an " Unhandled exception type
> DocumentTypeInconsistencyException "
>
>
> Heres's my code :
>
>                 Document   _document = repory.createDocument(_title,
> "UGImage", "main", "default");
>                  File testFile = new java.io.File(_file);
>                  FilePartDataSource _dataSource = new
> FilePartDataSource(testFile);
>                  String _docType = "UGImage";
>                  String _docName = "image/pjpeg";
>                  _document.setPart(_docType, _docName, _dataSource);
>                  _document.setCustomField( _CustField, _CustValue );
>                  _document.addToCollection(OurCollection);
>                  _document.save();
>
>
> all the variables if not init'd in that block are being passed into the
> method that contains this code.  the error occurs @ "
> _document.setPart(_docType, _docName, _dataSource); "

I don't think anything is wrong with your code. Have a look at the Daisy API:

http://cocoondev.org/javadoc/daisy/2.0/org/outerj/daisy/repository/Document.html#setPart(long,%20java.lang.String,%20org.outerj.daisy.repository.PartDataSource)

setPart

void setPart(long partTypeId,
             String mimeType,
             PartDataSource partDataSource)
             throws DocumentTypeInconsistencyException

    Sets a part.

    This is a variant-level method.

    Throws:
        DocumentTypeInconsistencyException

The method setPart (and save) of the Interface Document throws a
DocumentTypeInconsistencyException, so you have to handle that
Exception inside your code (either by catching it or by adding a throw
clause in your own method (where setPart is called).

Hope that helps

Andreas


More information about the daisy mailing list