forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AS7-6464] Re-working of the add-user utility states for: -
1 - Quicker reporting of a problem to the user i.e. Don't ask for three values then tell them the first one is rejected. 2 - Improved workflow regarding validation to prevent checks from being skipped should a previous check fail.
- Loading branch information
1 parent
712dfd5
commit 5401ec6
Showing
20 changed files
with
654 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
.../src/main/java/org/jboss/as/domain/management/security/state/AbstractValidationState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.jboss.as.domain.management.security.state; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* Where multiple stages of validation need to be performed this {@link State} provides a way to coordinate ensuring each stage | ||
* of the validation is performed. | ||
* | ||
* One instance of this state should be created when the validation begins and as each step passes this instance should be used | ||
* as the next state. Should validation fail then the instance of this State should be discarded so that validation can commence | ||
* from the beginning if alternative values are provided. | ||
* | ||
* @author <a href="mailto:darran.lofthouse@jboss.com">Darran Lofthouse</a> | ||
*/ | ||
public abstract class AbstractValidationState implements State { | ||
|
||
private Iterator<State> stateIterator; | ||
|
||
@Override | ||
public State execute() { | ||
if (stateIterator == null) { | ||
stateIterator = getValidationStates().iterator(); | ||
} | ||
|
||
if (stateIterator.hasNext()) { | ||
return stateIterator.next(); | ||
} | ||
|
||
return getSuccessState(); | ||
} | ||
|
||
/** | ||
* Get a {@link Collection} containing all states required to perform the validation needed. | ||
* | ||
* On initialisation an Iterator will be created for this collection - each time this state is called the next state | ||
* returned by the Iterator will be called to perform validation. Once the Iterator is exhausted the success state will be | ||
* returned instead. | ||
* | ||
* If validation fails then it is expected that the individual validation states will transition away from this state, this | ||
* is why there is no error or failure state. | ||
*/ | ||
protected abstract Collection<State> getValidationStates(); | ||
|
||
/** | ||
* Get the state to transition to once all validation is complete. | ||
* | ||
* @return The state to transition to once all validation is complete. | ||
*/ | ||
protected abstract State getSuccessState(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.