Search in sources :

Example 1 with ExportManifestDto

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto in project pentaho-platform by pentaho.

the class ExportManifest method getExportManifestDto.

ExportManifestDto getExportManifestDto() {
    ExportManifestDto rawExportManifest = new ExportManifestDto();
    List<ExportManifestEntityDto> rawEntityList = rawExportManifest.getExportManifestEntity();
    rawExportManifest.setExportManifestInformation(manifestInformation);
    TreeSet<String> ts = new TreeSet<String>(exportManifestEntities.keySet());
    for (String path : ts) {
        rawEntityList.add(exportManifestEntities.get(path).getExportManifestEntityDto());
    }
    rawExportManifest.getExportManifestMetadata().addAll(this.metadataList);
    rawExportManifest.getExportManifestMondrian().addAll(this.mondrianList);
    rawExportManifest.getExportManifestSchedule().addAll(this.scheduleList);
    rawExportManifest.getExportManifestDatasource().addAll(this.datasourceList);
    rawExportManifest.getExportManifestUser().addAll(this.getUserExports());
    rawExportManifest.getExportManifestRole().addAll(this.getRoleExports());
    rawExportManifest.setExportManifestMetaStore(this.getMetaStore());
    rawExportManifest.getGlobalUserSettings().addAll(this.getGlobalUserSettings());
    return rawExportManifest;
}
Also used : ExportManifestDto(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto) TreeSet(java.util.TreeSet) ExportManifestEntityDto(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestEntityDto)

Example 2 with ExportManifestDto

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto in project pentaho-platform by pentaho.

the class ExportManifest method fromXml.

public static ExportManifest fromXml(ByteArrayInputStream input) throws JAXBException {
    SAXParserFactory secureSAXParserFactory;
    try {
        secureSAXParserFactory = XMLParserFactoryProducer.createSecureSAXParserFactory();
    } catch (SAXNotSupportedException | SAXNotRecognizedException | ParserConfigurationException ex) {
        throw new JAXBException(ex);
    }
    XMLReader xmlReader;
    try {
        xmlReader = secureSAXParserFactory.newSAXParser().getXMLReader();
        xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
    } catch (SAXException | ParserConfigurationException ex) {
        throw new JAXBException(ex);
    }
    Source xmlSource = new SAXSource(xmlReader, new InputSource(input));
    JAXBContext jc = JAXBContext.newInstance("org.pentaho.platform.plugin.services.importexport.exportManifest.bindings");
    Unmarshaller u = jc.createUnmarshaller();
    try {
        JAXBElement<ExportManifestDto> o = (JAXBElement) (u.unmarshal(xmlSource));
        ExportManifestDto exportManifestDto = o.getValue();
        ExportManifest exportManifest = new ExportManifest(exportManifestDto);
        return exportManifest;
    } catch (Exception e) {
        System.out.println(e.toString());
        return null;
    }
}
Also used : InputSource(org.xml.sax.InputSource) JAXBException(javax.xml.bind.JAXBException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Source(javax.xml.transform.Source) InputSource(org.xml.sax.InputSource) SAXSource(javax.xml.transform.sax.SAXSource) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) JAXBException(javax.xml.bind.JAXBException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) SAXException(org.xml.sax.SAXException) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) SAXSource(javax.xml.transform.sax.SAXSource) ExportManifestDto(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Unmarshaller(javax.xml.bind.Unmarshaller) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 3 with ExportManifestDto

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto in project pentaho-platform by pentaho.

the class ExportManifest method toXmlString.

public String toXmlString() throws JAXBException {
    StringWriter sw = new StringWriter();
    Marshaller marshaller = getMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.marshal(new JAXBElement<ExportManifestDto>(new QName("http://www.pentaho.com/schema/", "ExportManifest"), ExportManifestDto.class, getExportManifestDto()), sw);
    return sw.toString();
}
Also used : Marshaller(javax.xml.bind.Marshaller) StringWriter(java.io.StringWriter) ExportManifestDto(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto) QName(javax.xml.namespace.QName)

Example 4 with ExportManifestDto

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto in project pentaho-platform by pentaho.

the class ExportManifest method toXml.

/**
 * Marshals the manifest object into xml on the given output stream
 *
 * @param outputStream
 * @throws JAXBException
 * @throws ExportManifestFormatException
 */
public void toXml(OutputStream outputStream) throws JAXBException, ExportManifestFormatException {
    if (!isValid()) {
        throw new ExportManifestFormatException("Invalid root Folder for manifest");
    }
    final JAXBContext jaxbContext = JAXBContext.newInstance(ExportManifestDto.class);
    Marshaller marshaller = getMarshaller();
    marshaller.marshal(new JAXBElement<ExportManifestDto>(new QName("http://www.pentaho.com/schema/", "ExportManifest"), ExportManifestDto.class, getExportManifestDto()), outputStream);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ExportManifestDto(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto) QName(javax.xml.namespace.QName) JAXBContext(javax.xml.bind.JAXBContext)

Aggregations

ExportManifestDto (org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestDto)4 JAXBContext (javax.xml.bind.JAXBContext)2 Marshaller (javax.xml.bind.Marshaller)2 QName (javax.xml.namespace.QName)2 StringWriter (java.io.StringWriter)1 TreeSet (java.util.TreeSet)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 Source (javax.xml.transform.Source)1 SAXSource (javax.xml.transform.sax.SAXSource)1 ExportManifestEntityDto (org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestEntityDto)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)1 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)1 XMLReader (org.xml.sax.XMLReader)1