Commit 71b0aada authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Merge pull request #339 from bonitasoft/feat/BS-14686_do_not_clean_db_on_exit_by_default

BS-14686 Do not clean databases by default
parents 0df4c1a1 449a6747
......@@ -59,6 +59,7 @@ Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
org.bonitasoft.engine.bpm.bar,
org.bonitasoft.engine.bpm.process,
org.bonitasoft.engine.exception,
org.bonitasoft.engine.filter,
org.bonitasoft.engine.identity,
org.bonitasoft.engine.profile,
......
......@@ -16,7 +16,14 @@ package org.bonitasoft.studio.actors.action;
import java.io.FileNotFoundException;
import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.exception.BonitaHomeNotSetException;
import org.bonitasoft.engine.exception.SearchException;
import org.bonitasoft.engine.exception.ServerAPIException;
import org.bonitasoft.engine.exception.UnknownAPITypeException;
import org.bonitasoft.engine.search.SearchOptionsBuilder;
import org.bonitasoft.engine.session.APISession;
import org.bonitasoft.engine.session.InvalidSessionException;
import org.bonitasoft.studio.actors.operation.PublishOrganizationOperation;
import org.bonitasoft.studio.actors.repository.OrganizationFileStore;
import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
......@@ -24,6 +31,7 @@ import org.bonitasoft.studio.common.extension.IEngineAction;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.engine.BOSEngineManager;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
......@@ -44,7 +52,8 @@ public class PublishActiveOrganizationAction implements IEngineAction {
*/
@Override
public void run(final APISession session) throws Exception {
if (BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore().getBoolean(BonitaPreferenceConstants.LOAD_ORGANIZATION)) {
if (noOrganizationDeployed(session)
|| BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore().getBoolean(BonitaPreferenceConstants.LOAD_ORGANIZATION)) {
final String artifactId = activeOrganizationProvider.getActiveOrganization();
final OrganizationRepositoryStore store = RepositoryManager.getInstance().getRepositoryStore(OrganizationRepositoryStore.class);
final OrganizationFileStore organizationFileStore = store.getChild(artifactId + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
......@@ -57,4 +66,11 @@ public class PublishActiveOrganizationAction implements IEngineAction {
}
}
private boolean noOrganizationDeployed(final APISession session)
throws InvalidSessionException, BonitaHomeNotSetException, ServerAPIException, UnknownAPITypeException, SearchException {
final IdentityAPI identityAPI = BOSEngineManager.getInstance().getIdentityAPI(session);
return identityAPI.searchUsers(new SearchOptionsBuilder(0, 1).done()).getCount() == 0
&& identityAPI.searchGroups(new SearchOptionsBuilder(0, 1).done()).getCount() == 0
&& identityAPI.searchRoles(new SearchOptionsBuilder(0, 1).done()).getCount() == 0;
}
}
......@@ -15,7 +15,11 @@
package org.bonitasoft.studio.application.dialog;
import org.bonitasoft.studio.application.i18n.Messages;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.bonitasoft.studio.preferences.dialog.BonitaPreferenceDialog;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.layout.GridDataFactory;
......@@ -34,13 +38,44 @@ import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
public class ExitDialog extends MessageDialogWithToggle {
public static ExitDialog openExitDialog(final Shell parentShell) {
final ExitDialog exitDialog = new ExitDialog(parentShell, IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, null, null, WARNING, new String[] {
IDialogConstants.OK_LABEL,
IDialogConstants.CANCEL_LABEL },
0, IDEWorkbenchMessages.PromptOnExitDialog_choice, false);
exitDialog.open();
return exitDialog;
public static MessageDialogWithToggle openExitDialog(final Shell parentShell) {
MessageDialogWithToggle dialog = null;
if (deleteTenantOnExit()) {
dialog = new ExitDialog(parentShell, IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, null, null, WARNING, new String[] {
IDialogConstants.OK_LABEL,
IDialogConstants.CANCEL_LABEL },
0, IDEWorkbenchMessages.PromptOnExitDialog_choice, false);
dialog.open();
} else {
dialog = MessageDialogWithToggle
.openOkCancelConfirm(parentShell,
IDEWorkbenchMessages.PromptOnExitDialog_shellTitle,
exitMessage(),
IDEWorkbenchMessages.PromptOnExitDialog_choice,
false, null, null);
}
return dialog;
}
private static boolean deleteTenantOnExit() {
return BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore().getBoolean(BonitaPreferenceConstants.DELETE_TENANT_ON_EXIT);
}
protected static String exitMessage() {
String productName = null;
final IProduct product = Platform.getProduct();
if (product != null) {
productName = product.getName();
}
String message = null;
if (productName == null) {
message = IDEWorkbenchMessages.PromptOnExitDialog_message0;
} else {
message = NLS.bind(
IDEWorkbenchMessages.PromptOnExitDialog_message1,
productName);
}
return message;
}
public ExitDialog(final Shell parentShell, final String dialogTitle, final Image image, final String message, final int dialogImageType,
......@@ -89,4 +124,5 @@ public class ExitDialog extends MessageDialogWithToggle {
SWT.DEFAULT).applyTo(messageLabel);
return composite;
}
}
......@@ -37,7 +37,7 @@ public class EnginePreferencesInitializer extends AbstractPreferenceInitializer
store.setDefault(EnginePreferenceConstants.REMOTE_DEPLOYMENT_CHOICE, EnginePreferenceConstants.STANDARD_MODE);
store.setDefault(EnginePreferenceConstants.TOGGLE_STATE_FOR_NO_INITIATOR, MessageDialogWithToggle.NEVER);
store.setDefault(EnginePreferenceConstants.TOGGLE_STATE_FOR_CONTRACT_AND_NOFORM_AND_INITIATOR, MessageDialogWithToggle.NEVER);
store.setDefault(EnginePreferenceConstants.DROP_BUSINESS_DATA_DB_ON_EXIT_PREF, true);
store.setDefault(EnginePreferenceConstants.DROP_BUSINESS_DATA_DB_ON_EXIT_PREF, false);
store.setDefault(EnginePreferenceConstants.DROP_BUSINESS_DATA_DB_ON_INSTALL, false);
store.setDefault(DesignerPreferenceConstants.FORCE_INTERNAL_FORM_MAPPING, true);
}
......
......@@ -48,8 +48,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer impleme
initDefaultWebPreferences(store, webStore);
store.setDefault(SHOW_CONDITION_ON_TRANSITION, "false");
store.setDefault(DELETE_TENANT_ON_EXIT, true);
store.setDefault(LOAD_ORGANIZATION, true);
store.setDefault(DELETE_TENANT_ON_EXIT, false);
store.setDefault(LOAD_ORGANIZATION, false);
store.setDefault(AUTOMATIC_ID, "true");
initDefaultLocalesPreference(store);
......
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