public byte[] marshallToXML(final ApplicationNodeContainer applicationNodeContainer) throws JAXBException, IOException, SAXException { return IOUtils.marshallObjectToXML(applicationNodeContainer, ApplicationNodeContainer.class.getResource(APPLICATION_XSD)); }
public BusinessObjectModel unmarshall(final byte[] bomXML) throws JAXBException, IOException, SAXException { return IOUtils.unmarshallXMLtoObject(bomXML, BusinessObjectModel.class, xsdUrl); }
public static File createDirectoryIfNotExists(File dir) { if (!dir.exists()) { return createDirectory(dir); } return dir; }
public BusinessObjectModel unzip(final byte[] zippedBOM) throws IOException, JAXBException, SAXException { final Map<String, byte[]> files = IOUtils.unzip(zippedBOM); final byte[] bomXML = files.get(BOM_XML); if (bomXML == null) { throw new IOException("the file " + BOM_XML + " is missing in the zip"); } return unmarshall(bomXML); }
/** * protected for testing - must be changed */ protected void addPersistenceFile(final File directory, final BusinessObjectModel bom) throws CodeGenerationException { try { final List<BusinessObject> entities = bom.getBusinessObjects(); final PersistenceUnitBuilder builder = new PersistenceUnitBuilder(); for (final BusinessObject businessObject : entities) { builder.addClass(businessObject.getQualifiedName()); } final Document document = builder.done(); final File metaInf = IOUtils.createSubDirectory(directory, "META-INF"); IOUtils.saveDocument(document, new File(metaInf, "persistence.xml")); } catch (Exception e) { throw new CodeGenerationException("Error when generating persistence.xml file", e); } }
private static File createPackageDirectory(URL javaFile, String originalPackage, File destDirectory) { File packageDirectory = new File(destDirectory, packageOf(javaFile.toString(), originalPackage)); return createDirectoryIfNotExists(packageDirectory); }
public byte[] zip(final BusinessObjectModel bom) throws IOException, JAXBException, SAXException { return IOUtils.zip(BOM_XML, marshall(bom)); }
public BusinessObjectModel unzip(final byte[] zippedBOM) throws IOException, JAXBException, SAXException { final Map<String, byte[]> files = IOUtils.unzip(zippedBOM); final byte[] bomXML = files.get(BOM_XML); if (bomXML == null) { throw new IOException("the file " + BOM_XML + " is missing in the zip"); } return unmarshall(bomXML); }
/** * protected for testing - must be changed */ protected void addPersistenceFile(final File directory, final BusinessObjectModel bom) throws CodeGenerationException { try { final List<BusinessObject> entities = bom.getBusinessObjects(); final PersistenceUnitBuilder builder = new PersistenceUnitBuilder(); for (final BusinessObject businessObject : entities) { builder.addClass(businessObject.getQualifiedName()); } final Document document = builder.done(); final File metaInf = IOUtils.createSubDirectory(directory, "META-INF"); IOUtils.saveDocument(document, new File(metaInf, "persistence.xml")); } catch (Exception e) { throw new CodeGenerationException("Error when generating persistence.xml file", e); } }
private static File createPackageDirectory(URL javaFile, String originalPackage, File destDirectory) { File packageDirectory = new File(destDirectory, packageOf(javaFile.toString(), originalPackage)); return createDirectoryIfNotExists(packageDirectory); }
public byte[] zip(final BusinessObjectModel bom) throws IOException, JAXBException, SAXException { return IOUtils.zip(BOM_XML, marshall(bom)); }
public BusinessObjectModel unmarshall(final byte[] bomXML) throws JAXBException, IOException, SAXException { return IOUtils.unmarshallXMLtoObject(bomXML, BusinessObjectModel.class, xsdUrl); }
public byte[] marshallToXML(final ApplicationNodeContainer applicationNodeContainer) throws JAXBException, IOException, SAXException { return IOUtils.marshallObjectToXML(applicationNodeContainer, ApplicationNodeContainer.class.getResource(APPLICATION_XSD)); }
@Override public BusinessObjectModel getBusinessObjectModel() throws SBusinessDataRepositoryException { try { byte[] clientBdmZip = getClientBDMZip(); final Map<String, byte[]> zipContent = IOUtils.unzip(clientBdmZip); if (zipContent.containsKey(BOM_NAME)) { final byte[] bomZip = zipContent.get(BOM_NAME); return getBusinessObjectModel(bomZip); } } catch (SBusinessDataRepositoryException e) { if (isBDMDeployed()) { // This is not a problem of BDM not deployed, let exception go up: throw e; } } catch (IOException e) { throw new SBusinessDataRepositoryException(e); } return null; }
public static File createDirectoryIfNotExists(File dir) { if (!dir.exists()) { return createDirectory(dir); } return dir; }
public ApplicationNodeContainer unmarshallFromXML(final byte[] applicationXML) throws JAXBException, IOException, SAXException { return IOUtils.unmarshallXMLtoObject(applicationXML, ApplicationNodeContainer.class, ApplicationNodeContainer.class.getResource(APPLICATION_XSD)); }
public byte[] export(final ApplicationNodeContainer applicationNodeContainer) throws ExportException { final URL resource = ApplicationNodeContainer.class.getResource("/application.xsd"); try { return IOUtils.marshallObjectToXML(applicationNodeContainer, resource); } catch (final Exception e) { throw new ExportException(e); } }
@Override public BusinessObjectModel getBusinessObjectModel() throws SBusinessDataRepositoryException { try { byte[] clientBdmZip = getClientBDMZip(); final Map<String, byte[]> zipContent = IOUtils.unzip(clientBdmZip); if (zipContent.containsKey(BOM_NAME)) { final byte[] bomZip = zipContent.get(BOM_NAME); return getBusinessObjectModel(bomZip); } } catch (SBusinessDataRepositoryException e) { if (isBDMDeployed()) { // This is not a problem of BDM not deployed, let exception go up: throw e; } } catch (IOException e) { throw new SBusinessDataRepositoryException(e); } return null; }
public static File createTempDirectory(final String prefix) throws IOException { final File tmpDirectory = File.createTempFile(prefix, null); return createDirectory(tmpDirectory); }
public ApplicationNodeContainer unmarshallFromXML(final byte[] applicationXML) throws JAXBException, IOException, SAXException { return IOUtils.unmarshallXMLtoObject(applicationXML, ApplicationNodeContainer.class, ApplicationNodeContainer.class.getResource(APPLICATION_XSD)); }