Commit ed7725d0 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

tr(java11) run tests with java 11 (#1540)

* use maven toolchain plugin to run only tests with jdk11
* use jaxb-api from engine dependency
* hack context classloader due to tyyco-surefire-plugin bug
* log a warning when refreshing repository store
* add flag to run tests with java 11
* configure toolchain maven plugin
* test la-builder with java 11
* add jaxws-ri for webservice connector tests

Closes BST-14
parent b236d8b1
......@@ -562,13 +562,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
version="0.0.0"
unpack="false"/>
<plugin
id="javax.xml.bind"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="javax.annotation"
download-size="0"
......
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.bonitasoft.studio.bundles</groupId>
<artifactId>plugins</artifactId>
<version>7.9.0-SNAPSHOT</version>
</parent>
<groupId>org.bonitasoft.studio.bundles.plugins</groupId>
<artifactId>bonita-business-data-generator</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.bonitasoft.engine.data</groupId>
<artifactId>bonita-business-data-generator</artifactId>
<version>${engine.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>studio</shadedClassifierName>
<filters>
<!-- exclude eclipse compiler because studio already have it in classpath -->
<filter>
<artifact>org.eclipse.jdt.core.compiler:ecj</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>javax.xml.bind:jaxb-api</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.sun.xml.fastinfoset:FastInfoset</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>javax.xml.bind:jsr173_api</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.sun.xml.bind:jaxb-impl</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.sun.xml.bind:jaxb-core</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.sun.istack:istack-commons-runtime</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<!-- exclude bonita-common because studio already have it in classpath -->
<filter>
<artifact>org.bonitasoft.engine:bonita-common</artifact>
<includes>
<include>com/bonitasoft/engine/bdm/*</include>
<include>com/bonitasoft/engine/bdm/dao/*</include>
<include>org/bonitasoft/engine/bdm/dao/*</include>
<include>org/bonitasoft/engine/bdm/lazy/*</include>
<include>org/bonitasoft/engine/bdm/model/field/*</include>
<include>org/bonitasoft/engine/bdm/serialization/*</include>
<include>org/bonitasoft/engine/bdm/validator/rule/composition/*</include>
<include>org/bonitasoft/engine/bdm/validator/rule/*</include>
<include>org/bonitasoft/engine/bdm/validator/*</include>
<include>org/bonitasoft/engine/bdm/*</include>
<include>org/bonitasoft/engine/io/IOUtils.*</include>
<include>org/bonitasoft/engine/xml/parser/*</include>
<include>*</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
......@@ -30,7 +30,7 @@
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.bonitasoft.engine.data</groupId>
<groupId>org.bonitasoft.studio.bundles.plugins</groupId>
<artifactId>bonita-business-data-generator</artifactId>
<version>${engine.version}</version>
<classifier>studio</classifier>
......
......@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
import java.io.InputStream;
import org.bonitasoft.engine.bdm.BusinessObjectModelConverter;
import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.engine.bdm.model.BusinessObjectModel;
import org.bonitasoft.engine.bdm.model.field.FieldType;
......@@ -89,6 +90,7 @@ public class BusinessObjectModelFileStoreTest {
employee.setQualifiedName("org.bonita.Employee");
bdm.addBusinessObject(employee);
fileStoreUnderTest = spy(new BusinessObjectModelFileStore("bdm.zip", store));
doReturn(new BusinessObjectModelConverter()).when(fileStoreUnderTest).getConverter();
doReturn(iResource).when(fileStoreUnderTest).getResource();
doReturn(bdm).when(fileStoreUnderTest).getContent();
}
......
......@@ -66,13 +66,10 @@ public class BusinessObjectModelFileStore extends AbstractBDMFileStore implement
private static final String DEFINE_BDM_COMMAND_ID = "org.bonitasoft.studio.businessobject.manage";
private final BusinessObjectModelConverter converter;
private final Map<Long, BusinessObjectModel> cachedBusinessObjectModel = new HashMap<>();
public BusinessObjectModelFileStore(final String fileName, final IRepositoryStore<AbstractBDMFileStore> store) {
super(fileName, store);
converter = new BusinessObjectModelConverter();
}
@Override
......@@ -87,7 +84,7 @@ public class BusinessObjectModelFileStore extends AbstractBDMFileStore implement
return cachedBusinessObjectModel.get(modificationStamp);
}
try (InputStream contents = resource.getContents()) {
final BusinessObjectModel bom = converter.unmarshall(ByteStreams.toByteArray(contents));
final BusinessObjectModel bom = getConverter().unmarshall(ByteStreams.toByteArray(contents));
cachedBusinessObjectModel.clear();
cachedBusinessObjectModel.put(modificationStamp, bom);
return bom;
......@@ -97,6 +94,10 @@ public class BusinessObjectModelFileStore extends AbstractBDMFileStore implement
return null;
}
protected BusinessObjectModelConverter getConverter() {
return ((BusinessObjectModelRepositoryStore) getParentStore()).getConverter();
}
@Override
public String getDisplayName() {
return Messages.businessDataModel;
......@@ -107,7 +108,7 @@ public class BusinessObjectModelFileStore extends AbstractBDMFileStore implement
Assert.isNotNull(content);
Assert.isLegal(content instanceof BusinessObjectModel);
try {
final byte[] xml = converter.marshall((BusinessObjectModel) content);
final byte[] xml = getConverter().marshall((BusinessObjectModel) content);
final ByteArrayInputStream source = new ByteArrayInputStream(xml);
final IFile resource = getResource();
if (resource.exists()) {
......@@ -198,7 +199,7 @@ public class BusinessObjectModelFileStore extends AbstractBDMFileStore implement
@Override
public byte[] toByteArray() {
try {
return converter.zip(getContent());
return getConverter().zip(getContent());
} catch (final Exception e) {
BonitaStudioLog.error(e);
}
......
......@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.bonitasoft.engine.bdm.BusinessObjectModelConverter;
......@@ -60,6 +61,9 @@ import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.wiring.BundleWiring;
import org.xml.sax.SAXException;
import com.google.common.base.Predicate;
......@@ -81,52 +85,40 @@ public class BusinessObjectModelRepositoryStore<F extends AbstractBDMFileStore>
private static final String BDM_CLIENT_POJO_JAR_NAME = "bdm-client-pojo.jar";
private BusinessObjectModelConverter converter = new BusinessObjectModelConverter();
private BusinessObjectModelConverter converter = new CustomBusinessObjectModelConverter();
static {
extensions.add(BDM_TYPE_EXTENSION);
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#createRepositoryFileStore(java.lang.String)
*/
public BusinessObjectModelConverter getConverter() {
return converter;
}
@Override
public AbstractBDMFileStore createRepositoryFileStore(final String fileName) {
return new BusinessObjectModelFileStore(fileName, this);
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#getName()
*/
@Override
public String getName() {
return STORE_NAME;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#getDisplayName()
*/
@Override
public String getDisplayName() {
return Messages.businessObjectRepositoryStoreName;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#getIcon()
*/
@Override
public Image getIcon() {
return Pics.getImage("bdm.png", BusinessObjectPlugin.getDefault());
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#getCompatibleExtensions()
*/
@Override
public Set<String> getCompatibleExtensions() {
return extensions;
......@@ -150,7 +142,7 @@ public class BusinessObjectModelRepositoryStore<F extends AbstractBDMFileStore>
F fileStore = null;
if (BusinessObjectModelFileStore.ZIP_FILENAME.equals(fileName)) {
try {
final BusinessObjectModelConverter converter = new BusinessObjectModelConverter();
BusinessObjectModelConverter converter = getConverter();
final BusinessObjectModel businessObjectModel = converter.unzip(ByteStreams.toByteArray(inputStream));
try (InputStream is = ByteSource.wrap(converter.marshall(businessObjectModel)).openBufferedStream()) {
fileStore = superDoImportInputStream(BusinessObjectModelFileStore.BOM_FILENAME, is);
......@@ -186,6 +178,7 @@ public class BusinessObjectModelRepositoryStore<F extends AbstractBDMFileStore>
final File legacyBDM = fStore.getResource().getLocation().toFile();
BusinessObjectModel businessObjectModel;
try {
BusinessObjectModelConverter converter = getConverter();
businessObjectModel = converter.unzip(Files.toByteArray(legacyBDM));
try (InputStream is = ByteSource.wrap(converter.marshall(businessObjectModel)).openBufferedStream()) {
doImportInputStream(BusinessObjectModelFileStore.BOM_FILENAME, is);
......@@ -195,7 +188,6 @@ public class BusinessObjectModelRepositoryStore<F extends AbstractBDMFileStore>
} catch (IOException | JAXBException | SAXException e1) {
throw new MigrationException("Failed to migrate Business data model", e1);
}
fStore.getResource().delete(true, monitor);
}
}
......
/**
* Copyright (C) 2019 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.businessobject.core.repository;
import java.io.IOException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.bonitasoft.engine.bdm.BusinessObjectModelConverter;
import org.bonitasoft.engine.bdm.model.BusinessObjectModel;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.wiring.BundleWiring;
import org.xml.sax.SAXException;
public class CustomBusinessObjectModelConverter extends BusinessObjectModelConverter {
@Override
public byte[] marshall(BusinessObjectModel bom) throws JAXBException, IOException, SAXException {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Bundle bundle = FrameworkUtil.getBundle(JAXBContext.class);
ClassLoader bundleClassloader = bundle.adapt(BundleWiring.class).getClassLoader();
//Due to some issue with tycho-surefire-plugin we need to set the proper context classloader
Thread.currentThread().setContextClassLoader(bundleClassloader);
return super.marshall(bom);
}finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@Override
public BusinessObjectModel unmarshall(byte[] bomXML) throws JAXBException, IOException, SAXException {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Bundle bundle = FrameworkUtil.getBundle(JAXBContext.class);
ClassLoader bundleClassloader = bundle.adapt(BundleWiring.class).getClassLoader();
//Due to some issue with tycho-surefire-plugin we need to set the proper context classloader
Thread.currentThread().setContextClassLoader(bundleClassloader);
return super.unmarshall(bomXML);
}finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
}
......@@ -73,6 +73,7 @@ public class ProjectManifestFactory {
symbolicName = DEFAULT_SYMBOLIC_NAME;
}
headers.put(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME, symbolicName);
headers.put("Automatic-Module-Name", symbolicName);
headers.put(org.osgi.framework.Constants.BUNDLE_VERSION, "1.0.0.qualifier");
headers.put(org.osgi.framework.Constants.BUNDLE_VENDOR, "Bonitasoft S.A.");
headers.put(org.osgi.framework.Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.8");
......
......@@ -340,7 +340,7 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
try {
folder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR);
} catch (final CoreException e1) {
BonitaStudioLog.error(e1);
BonitaStudioLog.warning(String.format("An error occured wihle refreshing folder %s: %s",folder.getName(),e1.getMessage()),CommonRepositoryPlugin.PLUGIN_ID);
}
}
}
......
......@@ -7,5 +7,6 @@
<classpathentry exported="true" kind="lib" path="lib/console-server.jar"/>
<classpathentry exported="true" kind="lib" path="lib/console-common.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-lang3.jar"/>
<classpathentry kind="lib" path="lib/jaxb-api.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -31,10 +31,6 @@
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jsr173_api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
......@@ -46,10 +42,6 @@
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jsr173_api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
......@@ -279,7 +271,8 @@
org.bonitasoft.console.common.server.sso;version="0.0.0",
!org.bonitasoft.engine.*.impl.db;version="0.0.0",
!org.bonitasoft.engine.*.impl.db.archive;version="0.0.0",
org.bonitasoft.engine.*;version="0.0.0"
org.bonitasoft.engine.*;version="0.0.0",
javax.xml.bind.*;version="2.2.0"
</_exportcontents>
<_nouses>true</_nouses>
<Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
......@@ -298,6 +291,7 @@
<Bundle-ClassPath>.,{maven-dependencies}</Bundle-ClassPath>
<Import-Package>!*</Import-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Require-Bundle>javax.activation;bundle-version="1.1.0"</Require-Bundle>
</instructions>
</configuration>
<executions>
......
......@@ -20,6 +20,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBContext;
import org.bonitasoft.engine.bpm.bar.BusinessArchive;
import org.bonitasoft.engine.bpm.bar.BusinessArchiveFactory;
import org.bonitasoft.studio.common.jface.FileActionDialog;
......@@ -34,6 +36,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.wiring.BundleWiring;
/**
* @author Romain Bioteau
......@@ -110,7 +115,19 @@ public class ExportBarOperation implements IRunnableWithProgress {
IProgressMonitor.UNKNOWN);
try {
final BusinessArchive bar = getBarExporter().createBusinessArchive(process, configurationId);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Bundle bundle = FrameworkUtil.getBundle(JAXBContext.class);
if(bundle != null ) {
ClassLoader bundleClassloader = bundle.adapt(BundleWiring.class).getClassLoader();
//Due to some issue with tycho-surefire-plugin we need to set the proper context classloader
Thread.currentThread().setContextClassLoader(bundleClassloader);
}
writeBusinessArchiveToFile(outputFile, bar);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
generatedBars.add(outputFile);
} catch (final Exception ex) {
BonitaStudioLog.error(ex);
......
......@@ -28,24 +28,27 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.bonitasoft.engine.business.application.ApplicationState;
import org.bonitasoft.engine.business.application.exporter.ApplicationNodeContainerConverter;
import org.bonitasoft.engine.business.application.xml.ApplicationNodeBuilder;
import org.bonitasoft.engine.business.application.xml.ApplicationNodeContainer;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.bonitasoft.studio.la.application.repository.ApplicationFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
public class ApplicationFileStoreTest {
private InputStream resourceAsStream;
private ApplicationRepositoryStore store;
@Before
public void openStreams() throws Exception {
resourceAsStream = ApplicationFileStoreTest.class.getResourceAsStream("/myApp.xml");
store = mock(ApplicationRepositoryStore.class);
Mockito.when(store.getConverter()).thenReturn(new ApplicationNodeContainerConverter());
}
@After
......@@ -55,7 +58,7 @@ public class ApplicationFileStoreTest {
@Test
public void should_retrieve_model_from_application_xml_file() throws Exception {
ApplicationFileStore applicationFileStore = spy(new ApplicationFileStore("myApp.xml", mock(IRepositoryStore.class)));
ApplicationFileStore applicationFileStore = spy(new ApplicationFileStore("myApp.xml", store));
doReturn(anIFile().withName("myApp.xml")
.withContent(resourceAsStream).build())
.when(applicationFileStore)
......@@ -70,7 +73,7 @@ public class ApplicationFileStoreTest {
@Test
public void should_create_a_new_application_xml_file_from_model() throws Exception {
ApplicationFileStore applicationFileStore = spy(new ApplicationFileStore("myApp.xml", mock(IRepositoryStore.class)));
ApplicationFileStore applicationFileStore = spy(new ApplicationFileStore("myApp.xml", store));
IFile resource = anIFile().withName("myApp.xml").build();
doReturn(resource)
.when(applicationFileStore)
......@@ -87,7 +90,7 @@ public class ApplicationFileStoreTest {
@Test
public void should_update_application_xml_file_from_model() throws Exception {
ApplicationFileStore applicationFileStore = spy(new ApplicationFileStore("myApp.xml", mock(IRepositoryStore.class)));
ApplicationFileStore applicationFileStore = spy(new ApplicationFileStore("myApp.xml", store));
IFile resource = anIFile().withName("myApp.xml").exists().build();
doReturn(resource)
.when(applicationFileStore)
......
......@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.bonitasoft.engine.business.application.exporter.ApplicationNodeContainerConverter;
import org.bonitasoft.engine.business.application.xml.ApplicationNodeBuilder;
import org.bonitasoft.engine.business.application.xml.ApplicationNodeContainer;
import org.bonitasoft.studio.la.application.ui.validator.MenuLevelValidator;
......@@ -34,7 +35,7 @@ public class MenuLevelValidatorTest {
@Test
public void should_add_warning_message() throws Exception {
final IFile resource = anIFile().build();
final MenuLevelValidator menuLevelValidator = spy(new MenuLevelValidator());
final MenuLevelValidator menuLevelValidator = spy(new MenuLevelValidator(new ApplicationNodeContainerConverter()));
doReturn(appWithDeepMenus()).when(menuLevelValidator)
.toApplicationContainer(resource);
doReturn(null).when(menuLevelValidator).createMessage(resource);
......@@ -47,7 +48,7 @@ public class MenuLevelValidatorTest {
@Test
public void should_not_add_warning_message() throws Exception {
final IFile resource = anIFile().build();
final MenuLevelValidator menuLevelValidator = spy(new MenuLevelValidator());
final MenuLevelValidator menuLevelValidator = spy(new MenuLevelValidator(new ApplicationNodeContainerConverter()));
doReturn(appWithSingleMenus()).when(menuLevelValidator)
.toApplicationContainer(resource);
doReturn(null).when(menuLevelValidator).createMessage(resource);
......
......@@ -22,13 +22,13 @@ import java.util.Optional;
import java.util.stream.Collectors;
import org.bonitasoft.engine.api.ApplicationAPI;
import org.bonitasoft.engine.business.application.exporter.ApplicationNodeContainerConverter;
import org.bonitasoft.engine.business.application.xml.ApplicationNodeContainer;
import org.bonitasoft.engine.exception.BonitaHomeNotSetException;
import org.bonitasoft.engine.exception.ServerAPIException;
import org.bonitasoft.engine.exception.UnknownAPITypeException;
import org.bonitasoft.engine.session.APISession;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.ReadFileStoreException;
import org.bonitasoft.studio.engine.BOSEngineManager;
......@@ -144,12 +144,11 @@ public class DeployApplicationAction {
onFinishButtons, status).open();
}
@SuppressWarnings("unused")
protected DeployApplicationDescriptorRunnable getDeployOperation(APISession apiSession,
final ApplicationAPI applicationAPI, final ApplicationNodeContainer applicationDescriptor)
throws BonitaHomeNotSetException, ServerAPIException, UnknownAPITypeException {
return new DeployApplicationDescriptorRunnable(applicationAPI, applicationDescriptor,
new ApplicationNodeContainerConverter());
RepositoryManager.getInstance() .getRepositoryStore(ApplicationRepositoryStore.class).getConverter());
}
}
......@@ -63,7 +63,6 @@ public class ApplicationFileStore extends AbstractFileStore implements IDeployab
public static final String APPLICATION_TO_DEPLOY_PARAMETER_NAME = "application";
public static final String DEPLOY_COMMAND = "org.bonitasoft.studio.la.deploy.command";
private final ApplicationNodeContainerConverter applicationNodeContainerConverter = new ApplicationNodeContainerConverter();
public ApplicationFileStore(String fileName, IRepositoryStore<? extends IRepositoryFileStore> parentStore) {
super(fileName, parentStore);
......@@ -76,12 +75,16 @@ public class ApplicationFileStore extends AbstractFileStore implements IDeployab
@Override
public ApplicationNodeContainer getContent() throws ReadFileStoreException {
try (InputStream inputStream = getResource().getContents()) {
return applicationNodeContainerConverter.unmarshallFromXML(ByteStreams.toByteArray(inputStream));
return getConverter().unmarshallFromXML(ByteStreams.toByteArray(inputStream));
} catch (CoreException | JAXBException | IOException | SAXException e) {
throw new ReadFileStoreException("Failed to load application model", e);
}
}
protected ApplicationNodeContainerConverter getConverter() {
return ((ApplicationRepositoryStore) getParentStore()).getConverter();
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.filestore.AbstractFileStore#doSave(java.lang.Object)
......@@ -92,7 +95,7 @@ public class ApplicationFileStore extends AbstractFileStore implements IDeployab
String.format("Only instance of %s are supported",
ApplicationNodeContainer.class));
try {
final byte[] xmlContent = applicationNodeContainerConverter
final byte[] xmlContent = getConverter()
.marshallToXML((ApplicationNodeContainer) content);
try (ByteArrayInputStream is = new ByteArrayInputStream(xmlContent)) {
final IFile resource = getResource();
......
......@@ -24,6 +24,7 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.bonitasoft.engine.business.application.exporter.ApplicationNodeContainerConverter;
import org.bonitasoft.engine.business.application.xml.ApplicationNode;
import org.bonitasoft.engine.business.application.xml.ApplicationNodeContainer;
import org.bonitasoft.studio.common.repository.model.ReadFileStoreException;
......@@ -36,10 +37,13 @@ public class ApplicationRepositoryStore extends AbstractRepositoryStore<Applicat
private static final String XML_EXTENSION = "xml";
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#getName()
*/
private final ApplicationNodeContainerConverter applicationNodeContainerConverter = new CustomApplicationNodeContainerConverter();
public ApplicationNodeContainerConverter getConverter(){
return applicationNodeContainerConverter;
}
@Override
public String getName() {
return "applications"; //$NON-NLS-N$
......