Skip to content

Commit

Permalink
fixing MID-4563 and MID-4562
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Apr 5, 2018
1 parent 2fe2ec0 commit e2d24af
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -43,6 +43,7 @@
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.model.api.AuthenticationEvaluator;
import com.evolveum.midpoint.model.api.context.PasswordAuthenticationContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
Expand Down Expand Up @@ -93,6 +94,11 @@ public class PageAccountActivation extends PageBase {
public PageAccountActivation(PageParameters params) {

UserType user = loadUser(params);

if (user == null) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
throw new RestartResponseException(PageLogin.class);
}

userModel = new LoadableModel<UserType>(false) {

Expand All @@ -119,11 +125,16 @@ private UserType loadUser(PageParameters params){
OperationResult result = new OperationResult(LOAD_USER);

return runPrivileged(new Producer<UserType>() {
private static final long serialVersionUID = 1L;

@Override
public UserType run() {
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(UserType.F_LINK_REF, GetOperationOptions.createResolve());
return WebModelServiceUtils.loadObject(UserType.class, userOid, options, PageAccountActivation.this, task, result).asObjectable();
PrismObject<UserType> user = WebModelServiceUtils.loadObject(UserType.class, userOid, options, PageAccountActivation.this, task, result);
if (user == null) {
return null;
}
return user.asObjectable();
}
});

Expand All @@ -143,7 +154,7 @@ public boolean isVisible() {

});

Form form = new com.evolveum.midpoint.web.component.form.Form<>(ID_MAIN_FORM);
Form<?> form = new com.evolveum.midpoint.web.component.form.Form<>(ID_MAIN_FORM);
activationContainer.add(form);

Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", new PropertyModel<>(userModel, "name.orig")));
Expand Down Expand Up @@ -272,6 +283,7 @@ private void propagatePassword(AjaxRequestTarget target,
}

OperationResult result = runPrivileged(new Producer<OperationResult>() {
private static final long serialVersionUID = 1L;

@Override
public OperationResult run() {
Expand Down Expand Up @@ -305,7 +317,7 @@ private List<ShadowType> getShadowsToActivate(){
if (shadowsToActivate == null || shadowsToActivate.isEmpty()) {
return new ArrayList<>();
}
return shadowsToActivate.parallelStream().filter(shadow -> shadow.getLifecycleState().equals(SchemaConstants.LIFECYCLE_PROPOSED)).collect(Collectors.toList());
return shadowsToActivate.parallelStream().filter(shadow -> SchemaConstants.LIFECYCLE_PROPOSED.equals(shadow.getLifecycleState())).collect(Collectors.toList());
}

}

0 comments on commit e2d24af

Please sign in to comment.