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

feat(deploy) add sp swtbot it (#1864)

Closes BST-475
parent 35fb911a
......@@ -45,6 +45,7 @@ import org.bonitasoft.studio.actors.model.organization.OrganizationFactory;
import org.bonitasoft.studio.actors.model.organization.util.OrganizationXMLProcessor;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.engine.BOSEngineManager;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
......@@ -72,7 +73,7 @@ public abstract class PublishOrganizationOperation implements IRunnableWithProgr
this.session = session;
}
public PublishOrganizationOperation doNotAllProfileToUsers() {
public PublishOrganizationOperation doNotApplyAllProfileToUsers() {
shouldApplyAllProfileToUser = false;
return this;
}
......@@ -99,6 +100,7 @@ public abstract class PublishOrganizationOperation implements IRunnableWithProgr
processApi.deleteArchivedProcessInstances(info.getProcessId(), 0, Integer.MAX_VALUE);
}
importOrganization(identityAPI);
new ActiveOrganizationProvider().saveActiveOrganization(organization.getName());
if (shouldApplyAllProfileToUsers()) {
applyAllProfileToUsers(identityAPI, BOSEngineManager.getInstance().getProfileAPI(session));
}
......
......@@ -256,7 +256,7 @@ public class OrganizationFileStore extends EMFFileStore implements IDeployable,
? new UpdateOrganizationOperation(organization)
: new CleanPublishOrganizationOperation(organization);
if(!PlatformUtil.isACommunityBonitaProduct()) {
operation.doNotAllProfileToUsers();
operation.doNotApplyAllProfileToUsers();
}
operation.setSession(session);
try {
......
......@@ -138,7 +138,6 @@ public class DeployOrganizationHandler {
try {
final Parameterization p = new Parameterization(cmd.getParameter("artifact"), fileStore.getName());
handlerService.executeCommand(new ParameterizedCommand(cmd, new Parameterization[] { p }), null);
activeOrganizationProvider.saveActiveOrganization(fileStore.getDisplayName());
AbstractFileStore.refreshExplorerView();
} catch (final Exception e) {
throw new InvocationTargetException(e);
......
......@@ -98,7 +98,8 @@ Export-Package: org.bonitasoft.studio.application,
org.bonitasoft.studio.application.test,
org.bonitasoft.studio.diagram.test,
org.bonitasoft.studio.swtbot.framework,
org.bonitasoft.studio.swtbot.framework.ex",
org.bonitasoft.studio.swtbot.framework.ex,
org.bonitasoft.studio.tests.ex",
org.bonitasoft.studio.application.operation,
org.bonitasoft.studio.application.splash,
org.bonitasoft.studio.application.views,
......
......@@ -99,4 +99,5 @@ pagesAndLayouts=Pages & Layouts
deployCancel=Deploy operation has been canceled.
saveOpenedEditorsTitle=Save opened editors
saveOpenedEditors=Save opened editors before deploy?
savingEditors=Saving editors...
\ No newline at end of file
savingEditors=Saving editors...
deploySuccessButNoAppToOpenMsg=All artifacts has been deployed successfully, but the current default user (%s) cannot access any application.
\ No newline at end of file
......@@ -56,6 +56,7 @@ import org.bonitasoft.studio.common.jface.BonitaErrorDialog;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.common.repository.model.DeployOptions;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.configuration.EnvironmentProviderFactory;
......@@ -299,13 +300,17 @@ public class DeployArtifactsHandler {
BOSEngineManager.getInstance().getApplicationAPI(session),
BOSEngineManager.getInstance().getProfileAPI(session),
BOSEngineManager.getInstance().getIdentityAPI(session));
if (IDialogConstants.OPEN_ID == DeploySuccessDialog.open(activeShell, contentProvider,
WorkbenchPlugin.getDefault().getDialogSettings())) {
try {
new OpenBrowserOperation(contentProvider.getSelectedURL()).execute();
} catch (MalformedURLException | UnsupportedEncodingException | URISyntaxException e) {
BonitaStudioLog.error(e);
if (contentProvider.getItems().length > 0) {
if (IDialogConstants.OPEN_ID == DeploySuccessDialog.open(activeShell, contentProvider,
WorkbenchPlugin.getDefault().getDialogSettings())) {
try {
new OpenBrowserOperation(contentProvider.getSelectedURL()).execute();
} catch (MalformedURLException | UnsupportedEncodingException | URISyntaxException e) {
BonitaStudioLog.error(e);
}
}
} else {
MessageDialog.openWarning(activeShell, Messages.deployStatus, String.format(Messages.deploySuccessButNoAppToOpenMsg, new ActiveOrganizationProvider().getDefaultUser()));
}
if (session != null) {
BOSEngineManager.getInstance().logoutDefaultTenant(session);
......
......@@ -137,6 +137,7 @@ public class Messages extends NLS {
public static String saveOpenedEditorsTitle;
public static String saveOpenedEditors;
public static String savingEditors;
public static String deploySuccessButNoAppToOpenMsg;
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
......
......@@ -43,6 +43,7 @@ public class DeployTenantResourcesOperation implements IRunnableWithStatus {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
status = artifactsToDeploy.stream()
.sorted()
.map(artifact -> artifact.deploy(apiSession, deployOptions, monitor))
.collect(StatusCollectors.toMultiStatus());
}
......
......@@ -57,7 +57,7 @@ public class DeployedAppContentProvider {
this.selection = applications.stream()
.findFirst()
.map(ApplicationItem::toString)
.orElseThrow(() -> new IllegalStateException("No application found."));
.orElse(null);
}
private Collection<? extends ApplicationItem> portalApplications(ProfileAPI profileAPI, UserAPI userAPI) {
......
......@@ -17,12 +17,13 @@ package org.bonitasoft.studio.application.ui.control.model;
import java.util.Map;
import org.bonitasoft.engine.session.APISession;
import org.bonitasoft.studio.application.views.ProjectExplorerViewerComparator;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.ITenantResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
public class TenantArtifact extends FileStoreArtifact implements ITenantResource {
public class TenantArtifact extends FileStoreArtifact implements ITenantResource, Comparable<TenantArtifact> {
public TenantArtifact(RepositoryStore parent, IRepositoryFileStore fStore) {
super(parent, fStore);
......@@ -32,5 +33,10 @@ public class TenantArtifact extends FileStoreArtifact implements ITenantResource
public IStatus deploy(APISession session, Map<String, Object> options, IProgressMonitor monitor) {
return ((ITenantResource)fStore).deploy(session, options, monitor);
}
@Override
public int compareTo(TenantArtifact artifact) {
return Integer.compare(ProjectExplorerViewerComparator.REPO_STORE_ORDER.get(((RepositoryStore) getParent()).getName()), ProjectExplorerViewerComparator.REPO_STORE_ORDER.get(((RepositoryStore) artifact.getParent()).getName()));
}
}
......@@ -19,7 +19,6 @@ import java.io.IOException;
import java.net.URL;
import org.bonitasoft.studio.importer.bos.i18n.Messages;
// import org.bonitasoft.studio.importer.bos.i18n.Messages;
import org.bonitasoft.studio.swtbot.framework.BotWizardDialog;
import org.bonitasoft.studio.swtbot.framework.application.BotDeployDialog;
import org.eclipse.core.runtime.FileLocator;
......
......@@ -30,6 +30,7 @@ import org.bonitasoft.engine.page.PageNotFoundException;
import org.bonitasoft.engine.platform.LoginException;
import org.bonitasoft.engine.search.SearchOptionsBuilder;
import org.bonitasoft.engine.session.APISession;
import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
import org.bonitasoft.studio.application.i18n.Messages;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryManager;
......@@ -62,7 +63,8 @@ public class DeployWizardIT {
new UndeployProcessOperation(BOSEngineManager.getInstance())
.undeployAll().run(Repository.NULL_PROGRESS_MONITOR);
Repository currentRepository = RepositoryManager.getInstance().getCurrentRepository();
currentRepository.getAllStores().stream().flatMap(store -> store.getChildren().stream())
currentRepository.getAllStores().stream().filter(store -> !OrganizationRepositoryStore.class.isInstance(store))
.flatMap(store -> store.getChildren().stream())
.filter(fStore -> fStore.canBeDeleted()).forEach(IRepositoryFileStore::delete);
}
......
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