Commit d2ce5e4a authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub
Browse files

feat(app) deploy uid artifact (#360)

* deploy per application

Closes BS-16336
parent 025311b8
......@@ -10,6 +10,7 @@ Bundle-Vendor: Bonitasoft S.A.
Bundle-Localization: plugin
Export-Package: org.bonitasoft.studio.designer,
org.bonitasoft.studio.designer.core,
org.bonitasoft.studio.designer.core.bar,
org.bonitasoft.studio.designer.core.expression,
org.bonitasoft.studio.designer.core.operation,
org.bonitasoft.studio.designer.core.preference,
......
......@@ -18,7 +18,6 @@ import static com.google.common.io.ByteStreams.toByteArray;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import javax.inject.Inject;
......@@ -44,16 +43,18 @@ public class CustomPageBarResourceFactory {
this.pageDesignerURLFactory = pageDesignerURLFactory;
}
public BarResource newBarResource(final String targetFormCustomPageId, final String formPageTechnicalUUID) throws BarResourceCreationException {
public BarResource newBarResource(final String targetFormCustomPageId, final String formPageTechnicalUUID)
throws BarResourceCreationException {
try {
return new BarResource(BAR_CUSTOMPAGES_LOCATION + "/" + targetFormCustomPageId + ".zip",
export(formPageTechnicalUUID));
} catch (ResourceException | IOException e) {
throw new BarResourceCreationException(String.format("Failed to create a BarResource for form %s", targetFormCustomPageId), e);
throw new BarResourceCreationException(
String.format("Failed to create a BarResource for form %s", targetFormCustomPageId), e);
}
}
private byte[] export(final String formPageTechnicalUUID) throws IOException, MalformedURLException {
public byte[] export(final String formPageTechnicalUUID) throws IOException {
try (final InputStream is = get(pageDesignerURLFactory.exportPage(formPageTechnicalUUID).toString());) {
if (is == null) {
throw new IOException(String.format("Failed to export custom page for form %s", formPageTechnicalUUID));
......
......@@ -15,6 +15,8 @@
package org.bonitasoft.studio.designer.core.repository;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import javax.inject.Inject;
......@@ -32,7 +34,7 @@ import org.eclipse.swt.graphics.Image;
public class WebPageRepositoryStore extends AbstractFolderRepositoryStore<WebPageFileStore> {
private static final String PAGE_ICON_PATH = "page.png";
private final static Set<String> extensions = new HashSet<String>();
private final static Set<String> extensions = new HashSet<>();
public static final String JSON_EXTENSION = "json";
public static final String WEB_FORM_REPOSITORY_NAME = "web_page";
......@@ -70,4 +72,10 @@ public class WebPageRepositoryStore extends AbstractFolderRepositoryStore<WebPag
return webPageFileStore;
}
public Optional<WebPageFileStore> findByPageId(String pageId) {
return getChildren().stream()
.filter(fStore -> Objects.equals(pageId, "custompage_" + fStore.getDisplayName()))
.findFirst();
}
}
......@@ -5,12 +5,10 @@
* 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/>.
*/
......@@ -18,7 +16,6 @@ package org.bonitasoft.studio.engine.operation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
......@@ -28,13 +25,11 @@ import java.net.URLEncoder;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class PortalURLBuilderTest {
......@@ -54,19 +49,11 @@ public class PortalURLBuilderTest {
doReturn("fr").when(portalURLBuilder).getWebLocale();
doReturn("william.jobs").when(portalURLBuilder).getDefaultUsername();
doReturn("bpm").when(portalURLBuilder).getDefaultPassword();
doReturn(null).when(portalURLBuilder).getConfiguration();
loginURL = "http://fakeLoginURL";
doReturn(loginURL).when(portalURLBuilder).buildLoginUrl(anyString(),
anyString());
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for
* {@link org.bonitasoft.studio.engine.operation.ApplicationURLBuilder#toURL(org.eclipse.core.runtime.IProgressMonitor)}
......@@ -81,14 +68,7 @@ public class PortalURLBuilderTest {
"portal/homepage", "UTF-8");
final String validLocale = URLEncoder.encode("_l=fr", "UTF-8");
assertThat(url.toString()).contains(validApplicationPath)
.contains(validLocale).startsWith(loginURL);
}
@Test
public void shouldGetConfigurationReturnNull() {
doCallRealMethod().when(portalURLBuilder).getConfiguration();
assertThat(portalURLBuilder.getConfiguration()).isNull();
.contains(validLocale).startsWith(loginURL);
}
}
......@@ -22,7 +22,6 @@ import java.net.URLEncoder;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.engine.BOSWebServerManager;
import org.bonitasoft.studio.model.configuration.Configuration;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
......@@ -32,7 +31,8 @@ public abstract class AbstractBonitaURLBuilder {
protected static final String ENCODING_UTF8 = "UTF-8";
protected abstract String getRedirectURL(final String locale, final IProgressMonitor monitor) throws UnsupportedEncodingException;
protected abstract String getRedirectURL(final String locale, final IProgressMonitor monitor)
throws UnsupportedEncodingException;
protected abstract String getLocaleParameter(final String locale);
......@@ -64,14 +64,16 @@ public abstract class AbstractBonitaURLBuilder {
return getActiveOrganizationProvider().getDefaultUser();
}
public URL toURL(final IProgressMonitor monitor) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException {
public URL toURL(final IProgressMonitor monitor)
throws MalformedURLException, UnsupportedEncodingException, URISyntaxException {
final String locale = getWebLocale();
final String loginURL = buildLoginUrl();
return new URL(loginURL + "&redirectUrl="
+ URLEncoder.encode(getRedirectURL(locale, monitor), ENCODING_UTF8));
}
public URL toTechnicalUserLoginURL(final IProgressMonitor monitor) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException {
public URL toTechnicalUserLoginURL(final IProgressMonitor monitor)
throws MalformedURLException, UnsupportedEncodingException, URISyntaxException {
final String locale = getWebLocale();
final String loginURL = buildLoginUrl("install", "install");
return new URL(loginURL + "&redirectUrl="
......@@ -79,17 +81,9 @@ public abstract class AbstractBonitaURLBuilder {
}
protected String buildLoginUrl() {
String userName = getDefaultUsername();
String password = getDefaultPassword();
final Configuration conf = getConfiguration();
if (conf != null && conf.getUsername() != null) {
userName = conf.getUsername();
password = conf.getPassword();
}
final String userName = getDefaultUsername();
final String password = getDefaultPassword();
return buildLoginUrl(userName, password);
}
protected abstract Configuration getConfiguration();
}
......@@ -5,12 +5,10 @@
* 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/>.
*/
......@@ -27,7 +25,6 @@ import org.bonitasoft.studio.diagram.custom.repository.ProcessConfigurationRepos
import org.bonitasoft.studio.model.configuration.Configuration;
import org.bonitasoft.studio.model.process.AbstractProcess;
public abstract class AbstractProcessRelatedURLBuilder extends AbstractBonitaURLBuilder {
protected final AbstractProcess process;
......@@ -38,7 +35,6 @@ public abstract class AbstractProcessRelatedURLBuilder extends AbstractBonitaURL
this.configurationId = configurationId;
}
@Override
protected Configuration getConfiguration() {
if (process != null) {
initConfigurationId();
......@@ -51,6 +47,24 @@ public abstract class AbstractProcessRelatedURLBuilder extends AbstractBonitaURL
return null;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.engine.operation.AbstractBonitaURLBuilder#buildLoginUrl()
*/
@Override
protected String buildLoginUrl() {
String userName = getDefaultUsername();
String password = getDefaultPassword();
final Configuration conf = getConfiguration();
if (conf != null && conf.getUsername() != null) {
userName = conf.getUsername();
password = conf.getPassword();
}
return buildLoginUrl(userName, password);
}
protected void initConfigurationId() {
if (configurationId == null) {
configurationId = ConfigurationPlugin
......
......@@ -5,12 +5,10 @@
* 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/>.
*/
......@@ -18,14 +16,13 @@ package org.bonitasoft.studio.engine.operation;
import java.io.UnsupportedEncodingException;
import org.bonitasoft.studio.model.configuration.Configuration;
import org.eclipse.core.runtime.IProgressMonitor;
public class LoginUrlBuilder extends AbstractBonitaURLBuilder {
@Override
protected String getRedirectURL(final String locale, final IProgressMonitor monitor) throws UnsupportedEncodingException {
protected String getRedirectURL(final String locale, final IProgressMonitor monitor)
throws UnsupportedEncodingException {
return "";
}
......@@ -34,9 +31,4 @@ public class LoginUrlBuilder extends AbstractBonitaURLBuilder {
return "";
}
@Override
protected Configuration getConfiguration() {
return null;
}
}
......@@ -16,17 +16,16 @@ package org.bonitasoft.studio.engine.operation;
import java.io.UnsupportedEncodingException;
import org.bonitasoft.studio.model.configuration.Configuration;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @author Romain Bioteau
*
*/
public class PortalURLBuilder extends AbstractBonitaURLBuilder {
@Override
protected String getRedirectURL(final String locale, final IProgressMonitor monitor) throws UnsupportedEncodingException {
protected String getRedirectURL(final String locale, final IProgressMonitor monitor)
throws UnsupportedEncodingException {
return "portal/homepage?" + getLocaleParameter(locale);
}
......@@ -35,9 +34,4 @@ public class PortalURLBuilder extends AbstractBonitaURLBuilder {
return "_l=" + locale;
}
@Override
protected Configuration getConfiguration() {
return null;
}
}
......@@ -6,44 +6,25 @@ Bundle-Version: 7.5.0.qualifier
Bundle-Activator: org.bonitasoft.studio.la.LivingApplicationPlugin
Bundle-Vendor: BonitaSoft S.A.
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.bonitasoft.studio.common.repository;bundle-version="7.5.0",
org.eclipse.ui.workbench,
Require-Bundle: org.bonitasoft.studio.common.repository;bundle-version="7.5.0",
org.eclipse.ui;bundle-version="3.106.0",
org.bonitasoft.studio.common,
org.eclipse.e4.ui.model.workbench;bundle-version="1.1.0.v20140512-1820",
org.eclipse.e4.core.di,
org.bonitasoft.studio.ui;bundle-version="7.5.0",
org.eclipse.core.databinding;bundle-version="1.4.2",
org.eclipse.core.databinding.beans,
org.eclipse.ui.forms,
org.eclipse.wst.xml.core;bundle-version="1.1.902",
org.eclipse.wst.xml.ui;bundle-version="1.1.501",
org.eclipse.wst.sse.core;bundle-version="1.1.900",
org.eclipse.wst.sse.ui;bundle-version="1.3.301",
org.eclipse.wst.common.ui;bundle-version="1.1.500",
org.eclipse.ui.ide,
org.eclipse.e4.core.commands,
org.eclipse.e4.core.contexts;bundle-version="1.3.100",
org.eclipse.jface.databinding,
org.bonitasoft.studio.browser,
org.bonitasoft.studio.engine;bundle-version="7.5.0",
org.bonitasoft.studio.designer,
org.bonitasoft.studio.tests-utils;bundle-version="6.4.1";resolution:=optional,
org.eclipse.wst.xml.ui;bundle-version="1.1.501",
org.junit;bundle-version="4.11.0";resolution:=optional,
assertj-core;bundle-version="3.6.1";resolution:=optional,
org.mockito;bundle-version="1.10.19";resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
org.bonitasoft.engine.business.application,
Import-Package: org.bonitasoft.engine.business.application,
org.bonitasoft.engine.business.application.exporter,
org.bonitasoft.engine.business.application.xml,
org.bonitasoft.engine.exception,
org.bonitasoft.engine.platform,
org.bonitasoft.engine.search,
org.bonitasoft.engine.search.impl,
org.bonitasoft.engine.session
org.bonitasoft.engine.business.application.xml
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.la.core,
org.bonitasoft.studio.la.i18n,
......
package org.bonitasoft.studio.ui.util;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.Collector;
......@@ -13,7 +14,7 @@ public class StatusCollectors {
public static Collector<IStatus, ?, MultiStatus> toMultiStatus() {
return Collector.of(multiStatusSupplier(),
MultiStatus::add,
multiStatusAccumulator(),
(left, right) -> {
left.addAll(right);
return left;
......@@ -24,4 +25,14 @@ public class StatusCollectors {
return () -> new MultiStatus("unknownId", IStatus.OK, "", null);
}
private static BiConsumer<MultiStatus, IStatus> multiStatusAccumulator() {
return (multi, status) -> {
if (status.isMultiStatus()) {
multi.addAll(status);
} else {
multi.add(status);
}
};
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment