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

feat(profile) update publish organization wizard (#700)

* add user profile validator

Closes BS-17146
parent 3bc29d9e
......@@ -4,19 +4,19 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.bonitasoft.studio.actors;singleton:=true
Bundle-Version: 7.6.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.bonitasoft.studio.actors.ActorsPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.bonitasoft.studio.actors,
org.bonitasoft.studio.actors.i18n;x-friends:="org.bonitasoft.studio.actors.tests,org.bonitasoft.studio.test.swtbot.util,org.bonitasoft.studio.tests",
org.bonitasoft.studio.actors.model.organization,
org.bonitasoft.studio.actors.model.organization.impl,
org.bonitasoft.studio.actors.model.organization.util,
org.bonitasoft.studio.actors.operation,
org.bonitasoft.studio.actors.repository,
org.bonitasoft.studio.actors.ui.handler,
org.bonitasoft.studio.actors.ui.wizard.page,
org.bonitasoft.studio.actors.validator
org.bonitasoft.studio.actors.i18n;x-friends:="org.bonitasoft.studio.actors.tests,org.bonitasoft.studio.test.swtbot.util,org.bonitasoft.studio.tests",
org.bonitasoft.studio.actors.model.organization,
org.bonitasoft.studio.actors.model.organization.impl,
org.bonitasoft.studio.actors.model.organization.util,
org.bonitasoft.studio.actors.operation,
org.bonitasoft.studio.actors.repository,
org.bonitasoft.studio.actors.ui.handler,
org.bonitasoft.studio.actors.ui.wizard.page,
org.bonitasoft.studio.actors.validator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.emf.ecore;visibility:=reexport,
......@@ -55,19 +55,22 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.databinding,
org.eclipse.core.databinding.observable,
org.eclipse.jdt.groovy.core;bundle-version="2.9.1",
org.bonitasoft.studio.ui
Bundle-ActivationPolicy: lazy
org.bonitasoft.studio.ui,
org.eclipse.e4.ui.model.workbench;bundle-version="2.0.0.v20170228-1842",
org.eclipse.e4.core.di.annotations,
org.eclipse.e4.core.commands
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,
org.bonitasoft.engine.search,
org.bonitasoft.engine.session,
org.bonitasoft.studio.common.jface,
org.bonitasoft.studio.common.jface.databinding.validator,
org.bonitasoft.studio.expression.editor.filter
Bundle-Activator: org.bonitasoft.studio.actors.ActorsPlugin
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,
org.bonitasoft.engine.search,
org.bonitasoft.engine.session,
org.bonitasoft.studio.common.jface,
org.bonitasoft.studio.common.jface.databinding.validator,
org.bonitasoft.studio.expression.editor.filter
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
# Copyright (C) 2009-2012 BonitaSoft S.A.
# BonitaSoft, 31 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/>.
src.excludes = src-test/java
bin.includes = .,\
META-INF/,\
plugin.xml,\
......@@ -23,8 +8,8 @@ bin.includes = .,\
filters-def/,\
filters-impl/,\
dependencies/,\
model/
model/,\
fragment.e4xmi
output.. = bin/
jars.compile.order = .
source.. = src/
output.. = bin/
src.excludes=src-test/java
\ No newline at end of file
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmi:id="_xq6k0JPZEeefAocV7_rPmw">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_y-sg4JPZEeefAocV7_rPmw" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command" xmi:id="_3qAZcJPZEeefAocV7_rPmw" elementId="org.bonitasoft.studio.organization.publish" commandName="%loadOrganization_Label"/>
<elements xsi:type="commands:Command" xmi:id="_tLmfcJbPEeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.organization.manage" commandName="%manageOrganization_Label"/>
<elements xsi:type="commands:Command" xmi:id="_bOsOIJb0Eeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.actors.import" commandName="%import_Label"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_9OWy0JPZEeefAocV7_rPmw" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_AM0IAJPaEeefAocV7_rPmw" elementId="org.bonitasoft.studio.organization.publish.handler" contributionURI="bundleclass://org.bonitasoft.studio.actors/org.bonitasoft.studio.actors.ui.handler.DeployOrganizationHandler" command="_3qAZcJPZEeefAocV7_rPmw"/>
<elements xsi:type="commands:Handler" xmi:id="_uqPnsJbPEeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.organization.manage.handler" contributionURI="bundleclass://org.bonitasoft.studio.actors/org.bonitasoft.studio.actors.ui.handler.ManageOrganizationHandler" command="_tLmfcJbPEeew-Jqtlwxc8Q"/>
<elements xsi:type="commands:Handler" xmi:id="_cpyTIJb0Eeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.actors.import.handler" contributionURI="bundleclass://org.bonitasoft.studio.actors/org.bonitasoft.studio.actors.ui.handler.ImportOrganizationHandler" command="_bOsOIJb0Eeew-Jqtlwxc8Q"/>
</fragments>
</fragment:ModelFragments>
......@@ -74,8 +74,8 @@ addMembership=Add membership...
addMembershipEtc=Memberships...
newOrganizationMsg=Create a new organization
newOrganizationTitle=Create a new organization
synchronizeInformationTitle=Publish information
synchronizeOrganizationSuccessMsg=Organization {0} has been published successfully
deployInformationTitle=Deploy information
deployOrganizationSuccessMsg=Organization {0} has been deployed successfully
selectActorTitle=Select an actor
selectActorDesc=Choose an actor from the ones defined in this process
actorMappingDesc=Define the actor mappings using an existing organization
......@@ -103,10 +103,9 @@ exportOrganizationTitle=Export organization
defaultOrganizationName=Organization
manageOrganizationTitle=Manage organizations
manageOrganizationDesc=Add, edit or remove organizations
synchronizeOrganizationTitle=Upload to local Portal...
synchronizeOrganizationDesc=Load the selected organization into the local {0}
synchronize=Publish
synchronizingOrganization=Publishing organization...
deployOrganizationDesc=Install the selected organization into the local {0}
deploy=Deploy
deployOrganization=Deploying organization...
selectActor=Select an actor
illegalCharacter=The character '/' is not allowed
filtersSourceRepositoryName=Actor filters sources
......@@ -179,7 +178,7 @@ importOrganizationSuccessfullTitle=Import successful
importOrganizationSuccessfullMessage=Organization has been imported successfully.
errorSelectionGroups=You can't select a group and one of its affiliate.
exportActorFilterTitle=Export actor filter
UserDoesntExistError=User {0} does not exist in the current organization. Please provide another username.
UserDoesntExistError=User {0} does not exist in the current organization.
addActor=Add...
initiator=Initiator
newActor=New actor
......@@ -234,9 +233,15 @@ labelExplicationCustomUserInformation=The information below (default and custom)
details=Details
groupDisplayLengthTooLong=Group display name \"{0}\" exceed max length of 75 characters.
importOrganizationWithWarningTitle=Import completed with errors
importOrganizationWithWarningMessage=The import of organization completed but some errors has been found.\n{0}
importOrganizationWithWarningMessage=The import of organization completed but following issues has been found.
userNameIsEmpty=Username is empty
organizationName=Organization name
invalidCharInGroupName=The following groups contain the invalid character '/':\n%s
removeProcessInitiator=Unset initiator
unknownActorMappingElement=Some actors are bound to unknown organization entities (groups,roles,users,memberships). Fix the active organization before deploy.
defaultUser=Default username
publishFailed=Publish operation has failed
defaultUserTooltip=The default user used when login to the Bonita UIs (Portal, applications...)
deployOrganizationTitle=Deploy organization
deployOrganizationPageTitle=Select an organization to deploy
organizationValidationFailedMsg=Following issues have been found
\ No newline at end of file
......@@ -19,7 +19,7 @@ providerName=Bonitasoft S.A.
actors_Label=Organization
export_Label=Export...
import_Label=Import...
loadOrganization_Label=Publish...
loadOrganization_Label=Deploy...
actor_tab_label=Actors
manageOrganization_Label=Manage...
Filters=Actor filters
......
......@@ -130,12 +130,11 @@ public class Messages extends NLS {
public static String defaultOrganizationName;
public static String manageOrganizationTitle;
public static String manageOrganizationDesc;
public static String synchronizeOrganizationTitle;
public static String synchronizeInformationTitle;
public static String synchronizeOrganizationSuccessMsg;
public static String synchronizeOrganizationDesc;
public static String synchronize;
public static String synchronizingOrganization;
public static String deployInformationTitle;
public static String deployOrganizationSuccessMsg;
public static String deployOrganizationDesc;
public static String deploy;
public static String deployOrganization;
public static String selectActor;
public static String illegalCharacter;
public static String filterDefRepositoryName;
......@@ -269,4 +268,10 @@ public class Messages extends NLS {
public static String invalidCharInGroupName;
public static String removeProcessInitiator;
public static String unknownActorMappingElement;
public static String defaultUser;
public static String publishFailed;
public static String defaultUserTooltip;
public static String deployOrganizationTitle;
public static String deployOrganizationPageTitle;
public static String organizationValidationFailedMsg;
}
......@@ -79,6 +79,7 @@ public abstract class PublishOrganizationOperation implements IRunnableWithProgr
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Assert.isNotNull(organization);
flushSession = false;
BonitaStudioLog.info("Loading organization " + organization.getName() + " in portal...", ActorsPlugin.PLUGIN_ID);
try {
......
......@@ -5,48 +5,42 @@
* 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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.ui.handler;
import org.bonitasoft.studio.actors.ui.wizard.ManageOrganizationWizard;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.e4.core.commands.ECommandService;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Romain Bioteau
*
*/
public class ManageOrganizationHandler extends AbstractHandler {
public class ManageOrganizationHandler {
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final Wizard newWizard = new ManageOrganizationWizard() ;
@Execute
public void execute(ECommandService commmandService) throws ExecutionException {
final Wizard newWizard = new ManageOrganizationWizard(commmandService);
final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), newWizard) {
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
*/
@Override
protected void configureShell(final Shell newShell) {
super.configureShell(newShell);
newShell.setSize(1000, 800);
protected Point getInitialSize() {
return new Point(1200, 800);
}
};
dialog.open() ;
return null;
dialog.open();
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 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.actors.ui.handler;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.actors.ui.wizard.SynchronizeOrganizationWizard;
import org.bonitasoft.studio.common.jface.CustomWizardDialog;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Display;
/**
* @author Romain Bioteau
*
*/
public class SynchronizeOrganizationHandler extends AbstractHandler {
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final SynchronizeOrganizationWizard wizard = new SynchronizeOrganizationWizard() ;
CustomWizardDialog dialog = new CustomWizardDialog(Display.getDefault().getActiveShell(), wizard,Messages.synchronize) ;
dialog.open() ;
return null;
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 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.actors.ui.wizard.page;
import java.util.HashSet;
import java.util.Set;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.actors.model.organization.Organization;
import org.bonitasoft.studio.actors.model.organization.User;
import org.bonitasoft.studio.common.jface.databinding.validator.EmptyInputValidator;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.databinding.wizard.WizardPageSupport;
import org.eclipse.jface.fieldassist.AutoCompleteField;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* @author Romain Bioteau
*
*/
public class DefaultUserOrganizationWizardPage extends WizardPage {
private String user ;
private DataBindingContext context;
private WizardPageSupport pageSupport;
private AutoCompleteField autoCompletionField;
private Set<String> usernames;
private Text usernameText;
private Binding binding;
public DefaultUserOrganizationWizardPage() {
super(DefaultUserOrganizationWizardPage.class.getName());
setTitle(Messages.defaultUserOrganizationTitle) ;
setDescription(Messages.defaultUserOrganizationDesc) ;
usernames = new HashSet<String>() ;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
Composite mainComposite = new Composite(parent, SWT.NONE) ;
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create()) ;
context = new DataBindingContext() ;
final Label usernameLabel = new Label(mainComposite, SWT.NONE) ;
usernameLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).create()) ;
usernameLabel.setText(Messages.userName) ;
usernameText = new Text(mainComposite, SWT.BORDER) ;
usernameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ;
autoCompletionField = new AutoCompleteField(usernameText, new TextContentAdapter(), new String[]{}) ;
createBindings();
pageSupport = WizardPageSupport.create(this,context) ;
setControl(mainComposite) ;
}
@Override
public void dispose() {
super.dispose();
if(pageSupport != null){
pageSupport.dispose() ;
}
if(context != null){
context.dispose() ;
}
}
public void createBindings(){
UpdateValueStrategy strategy = new UpdateValueStrategy() ;
strategy.setAfterGetValidator(new EmptyInputValidator(Messages.userName)) ;
strategy.setBeforeSetValidator(new IValidator(){
@Override
public IStatus validate(Object value) {
String user = (String)value;
if (!usernames.contains(user)){
return ValidationStatus.error(Messages.bind(Messages.UserDoesntExistError,user));
}
return Status.OK_STATUS;
}
});
binding = context.bindValue(SWTObservables.observeText(usernameText, SWT.Modify), PojoProperties.value(DefaultUserOrganizationWizardPage.class, "user").observe(this),strategy,null) ;
}
public void setOrganization(Organization organization){
usernames.clear();
for(User user : organization.getUsers().getUser()){
usernames.add(user.getUserName()) ;
}
autoCompletionField.setProposals(usernames.toArray(new String[usernames.size()])) ;
binding.validateTargetToModel();
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public void refreshBindings(){
binding.validateTargetToModel();
}
}
......@@ -5,31 +5,32 @@
* 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.actors.validator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
/**
* @author Romain Bioteau
*
*/
public class OrganizationValidationException extends Exception {
private static final long serialVersionUID = 578679768520738028L;
private MultiStatus status;
public OrganizationValidationException(final IStatus status) {
super(status.getMessage());
public OrganizationValidationException(final MultiStatus status, String organization) {
super(organization);
this.status = status;
}
public MultiStatus getValidationStatus() {
return status;
}
public String getOrganizationName() {
return getMessage();
}
}
......@@ -29,6 +29,7 @@ import org.bonitasoft.studio.actors.ui.wizard.page.GroupContentProvider;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
/**
......@@ -42,19 +43,20 @@ public class OrganizationValidator implements IValidator, ValidatorConstants {
*/
@Override
public IStatus validate(final Object input) {
MultiStatus validationStatus = new MultiStatus(ActorsPlugin.PLUGIN_ID, 0, null, null);
final Organization organization = (Organization) input;
for (final User u : organization.getUsers().getUser()) {
if (u.getUserName() == null || u.getUserName().isEmpty()) {
return ValidationStatus.error(Messages.userNameMissing);
validationStatus.add(ValidationStatus.error(Messages.userNameMissing));
}
if (u.getPassword() == null || u.getPassword().getValue() == null || u.getPassword().getValue().isEmpty()) {
return ValidationStatus.error(Messages.bind(Messages.userPasswordMissing, u.getUserName()));
validationStatus.add(ValidationStatus.error(Messages.bind(Messages.userPasswordMissing, u.getUserName())));
}
if (u.getManager() != null && !u.getManager().isEmpty()) {
final IStatus status = checkManagerCycles(organization, u);
if (!status.isOK()) {
return status;
validationStatus.add(status);
}
}
......@@ -66,7 +68,8 @@ public class OrganizationValidator implements IValidator, ValidatorConstants {
membershipFound = true;
final String groupName = membership.getGroupName();
if (groupName == null) {
return ValidationStatus.error(Messages.bind(Messages.missingGroup, u.getUserName()));
validationStatus
.add(ValidationStatus.error(Messages.bind(Messages.missingGroup, u.getUserName())));
}
final String parentPath = membership.getGroupParentPath();
String groupPath = null;
......@@ -77,22 +80,24 @@ public class OrganizationValidator implements IValidator, ValidatorConstants {
}
final IStatus groupStatus = validateGroupExists(organization, groupPath, membership);
if (groupStatus.getSeverity() != IStatus.OK) {
return groupStatus;
validationStatus.add(groupStatus);
}
final String roleName = membership.getRoleName();
if (roleName == null) {
return ValidationStatus.error(Messages.bind(Messages.missingRole, u.getUserName()));
validationStatus
.add(ValidationStatus.error(Messages.bind(Messages.missingRole, u.getUserName())));
}
final IStatus roleStatus = validateRoleExists(organization, roleName, membership);
if (roleStatus.getSeverity() != IStatus.OK) {
return roleStatus;
validationStatus.add(roleStatus);
}
}
}
}
if (!membershipFound) {
return ValidationStatus.error(Messages.bind(Messages.missingMembershipForUser, u.getUserName()));
validationStatus
.add(ValidationStatus.error(Messages.bind(Messages.missingMembershipForUser, u.getUserName())));
}
}
......@@ -100,11 +105,12 @@ public class OrganizationValidator implements IValidator, ValidatorConstants {
.map(Group::getName)
.filter(groupName -> groupName.contains("/"))
.collect(Collectors.toList());
if (!invalidGroups.isEmpty()) {
validationStatus.add(ValidationStatus.error(String.format(Messages.invalidCharInGroupName,
invalidGroups.stream().reduce((group1, group2) -> group1 + "\n" + group2).get())));
}
return invalidGroups.isEmpty()
? ValidationStatus.ok()
: ValidationStatus.error(String.format(Messages.invalidCharInGroupName,
invalidGroups.stream().reduce((group1, group2) -> group1 + "\n" + group2).get()));
return validationStatus;
}
private IStatus checkManagerCycles(final Organization organization, final User u) {
......
......@@ -20,10 +20,12 @@ import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.preferences.OrganizationPreferenceConstants;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.e4.core.di.annotations.Creatable;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.osgi.service.prefs.BackingStoreException;
@Creatable
public class ActiveOrganizationProvider {
private static final String PLUGIN_ID = CommonRepositoryPlugin.PLUGIN_ID;
......
/**
* Copyright (C) 2017 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.ui.dialog;
import java.util.Collection;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bonitasoft.studio.common.jface.dialog.ProblemsDialog;
import org.bonitasoft.studio.common.jface.dialog.TypedLabelProvider;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;