Package org.docx4j.openpackaging.exceptions

Examples of org.docx4j.openpackaging.exceptions.Docx4JException


     
      ctm.parseContentTypesFile(is);

    } catch (Exception e) {
      e.printStackTrace();
      throw new Docx4JException("Failed to get package", e);
    }
   
  }
View Full Code Here


     
     
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      throw new Docx4JException("Error getting document from JCR Part:" + partName, e);
    }
 
  }
View Full Code Here

          + " Source is " + rp.getSourceP().getPartName()
          + ", Target is " + r.getTarget() );
      try {       
        getPart(jcrSession, docxNode, pkg, rp, r);
      } catch (Exception e) {
        throw new Docx4JException("Failed to add parts from relationships", e);
      }
    }
   
  }
View Full Code Here

         
      }
    } catch (Exception ex) {
      // PathNotFoundException, ValueFormatException, RepositoryException, URISyntaxException
      ex.printStackTrace();
      throw new Docx4JException("Failed to getPart", ex);
    }
    return part;
  }
View Full Code Here

    } catch (Exception ex) {
      // PathNotFoundException, ValueFormatException, RepositoryException,
      // URISyntaxException
      ex.printStackTrace();
      throw new Docx4JException("Failed to getPart", ex);
    }
    return part;
  }
View Full Code Here

   
    EmbeddedPackagePart epp  = (EmbeddedPackagePart) ppt
      .getParts().get(new PartName(xlsPartName));
   
    if (epp==null) {
      throw new Docx4JException("Could find EmbeddedPackagePart: " + xlsPartName);
    }
   
    InputStream is = BufferUtil.newInputStream(epp.getBuffer());
   
    SpreadsheetMLPackage spreadSheet = (SpreadsheetMLPackage) SpreadsheetMLPackage.load(is);
View Full Code Here

     
    WordprocessingMLPackage wordMLPackage  = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
   
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
    if (wordMLPackage.getMainDocumentPart().getXPathsPart() == null) {
      throw new Docx4JException("OpenDoPE XPaths part missing");
    } else {
      xPaths = wordMLPackage.getMainDocumentPart().getXPathsPart()
          .getJaxbElement();
//      System.out.println(XmlUtils.marshaltoString(xPaths, true, true));
    }
View Full Code Here

    }

    public static Object nodeToObjectModel(Node n, Class declaredType) throws Docx4JException {
     
      if (n==null) {
        throw new Docx4JException("null input");
      }
     
//      if (log.isDebugEnabled() ) {
//        System.out.println("IN: " + XmlUtils.w3CDomNodeToString(n));
//      }
     
    Object jaxb=null;
    try {
      jaxb = XmlUtils.unmarshal(n, Context.jcPML, declaredType);
    } catch (JAXBException e1) {
      throw new Docx4JException("Couldn't unmarshall " + XmlUtils.w3CDomNodeToString(n), e1);
    }
    try {
      if (jaxb instanceof JAXBElement ) {
       
        JAXBElement jb = (JAXBElement)jaxb;
        if (jb.getDeclaredType().getName().equals(declaredType.getName() )) {
          return jb.getValue();
        } else {
            log.error("UNEXPECTED " +
                XmlUtils.JAXBElementDebug(jb)
                );
            throw new Docx4JException("Expected " + declaredType.getName() + " but got " +
                XmlUtils.JAXBElementDebug(jb) );
        }
      } else if (jaxb.getClass().getName().equals(declaredType.getName() )) {           
        return jaxb;
      } else {
        log.error( jaxb.getClass().getName() );
        throw new Docx4JException("Expected " + declaredType.getName() + " but got " +
            jaxb.getClass().getName() );
      }
    } catch (ClassCastException e) {
      throw new Docx4JException("Expected " + declaredType.getName() + " but got " +
          jaxb.getClass().getName(), e );
    }                             
    }
View Full Code Here

      } catch (Exception e) {
      e.printStackTrace() ;
      if (e instanceof Docx4JException) {
        throw (Docx4JException)e;
      } else {
        throw new Docx4JException("Failed to save package", e);
      }
      }

      log.info("...Done!" );   
View Full Code Here

      }   
   
    } catch (Exception e) {
      e.printStackTrace();
      log.error(e.getMessage(), e);
      throw new Docx4JException("Problem saving part " + part.getPartName(), e);
    }
   
  }
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.exceptions.Docx4JException

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.