Skip to content

Commit d24c014

Browse files
committed
wip
1 parent e5e4b52 commit d24c014

52 files changed

Lines changed: 2313 additions & 2319 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

roda-core/roda-core/src/main/resources/config/roda-roles.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ core.roles.org.roda.wui.api.v2.controller.JobsController.createJob = job.manage
9494
core.roles.org.roda.wui.api.v2.controller.JobsController.obtainJobCommand = job.manage
9595

9696
# Member roles
97+
core.roles.org.roda.wui.api.v2.controller.MembersController.getMember = member.read
9798
core.roles.org.roda.wui.api.v2.controller.MembersController.getUser = member.read
9899
core.roles.org.roda.wui.api.v2.controller.MembersController.getGroup = member.read
99100
core.roles.org.roda.wui.api.v2.controller.MembersController.deleteMultipleMembers = member.manage

roda-ui/roda-wui/src/main/java/config/i18n/client/ClientMessages.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,4 +2773,16 @@ SafeHtml representationInformationAssociatedWithDescription(String field, String
27732773
String disposalRuleSuccessfullyCreated();
27742774

27752775
String disposalRuleSuccessfullyUpdated();
2776+
2777+
String userSuccessfullyCreated();
2778+
2779+
String userSuccessfullyUpdated();
2780+
2781+
String groupSuccessfullyCreated();
2782+
2783+
String groupSuccessfullyUpdated();
2784+
2785+
String failedToUpdateGroup();
2786+
2787+
String failedToUpdateUser();
27762788
}

roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private static Set<String> mapCasGroupstoRODAGroups(Set<String> casGroups) {
274274
}
275275

276276
@Override
277-
public RODAMember getUser(String name) {
277+
public RODAMember getMember(String name) {
278278
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
279279
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
280280
LogEntryState state = LogEntryState.SUCCESS;
@@ -298,6 +298,26 @@ public RODAMember getUser(String name) {
298298
}
299299
}
300300

301+
@Override
302+
public User getUser(String name) {
303+
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
304+
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
305+
LogEntryState state = LogEntryState.SUCCESS;
306+
307+
try {
308+
// check user permissions
309+
controllerAssistant.checkRoles(requestContext.getUser());
310+
311+
return membersService.retrieveUser(name);
312+
} catch (RODAException e) {
313+
state = LogEntryState.FAILURE;
314+
throw new RESTException(e);
315+
} finally {
316+
// register action
317+
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USERNAME_PARAM, name);
318+
}
319+
}
320+
301321
@Override
302322
public User getAuthenticatedUser() {
303323
User user = UserUtility.getUser(request);
@@ -617,7 +637,7 @@ public Group createGroup(@RequestBody CreateGroupRequest groupRequest) {
617637
}
618638

619639
@Override
620-
public Void updateGroup(@RequestBody Group modifiedGroup) {
640+
public Group updateGroup(@RequestBody Group modifiedGroup) {
621641
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
622642
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
623643
LogEntryState state = LogEntryState.SUCCESS;
@@ -626,15 +646,14 @@ public Void updateGroup(@RequestBody Group modifiedGroup) {
626646
// check user permissions
627647
controllerAssistant.checkRoles(requestContext.getUser());
628648
// delegate
629-
membersService.updateGroup(modifiedGroup);
649+
return membersService.updateGroup(modifiedGroup);
630650
} catch (RODAException e) {
631651
state = LogEntryState.FAILURE;
632652
throw new RESTException(e);
633653
} finally {
634654
// register action
635655
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUP_PARAM, modifiedGroup);
636656
}
637-
return null;
638657
}
639658

640659
@Override
@@ -721,7 +740,7 @@ public Group removeMembersFromGroup(String id, String userId) {
721740
} finally {
722741
// register action
723742
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUP_PARAM, id,
724-
RodaConstants.CONTROLLER_USER_PARAM, userId);
743+
RodaConstants.CONTROLLER_USER_PARAM, userId);
725744
}
726745
}
727746

roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/MembersService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ public Group createGroup(Group group) throws GenericException, AlreadyExistsExce
271271
return newGroup;
272272
}
273273

274-
public void updateGroup(Group group) throws GenericException, NotFoundException, AuthorizationDeniedException {
275-
RodaCoreFactory.getModelService().updateGroup(group, true);
274+
public Group updateGroup(Group group) throws GenericException, NotFoundException, AuthorizationDeniedException {
275+
Group updatedGroup = RodaCoreFactory.getModelService().updateGroup(group, true);
276276
RodaCoreFactory.getIndexService().commit(true, RODAMember.class);
277+
return updatedGroup;
277278
}
278279

279280
public void deleteGroup(String groupname) throws GenericException, AuthorizationDeniedException {

roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/BrowseObjectActionsToolbar.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
import org.roda.core.data.v2.index.IsIndexed;
1414
import org.roda.core.data.v2.ip.AIPState;
1515
import org.roda.core.data.v2.ip.Permissions;
16-
import org.roda.wui.client.GenericDataPanel;
16+
import org.roda.wui.client.common.forms.GenericDataPanel;
1717
import org.roda.wui.client.common.actions.Actionable;
1818
import org.roda.wui.client.common.labels.Tag;
1919

2020
import com.google.gwt.user.client.rpc.AsyncCallback;
21-
import org.roda.wui.client.disposal.rule.DisposalRuleDataPanel;
2221

2322
/**
2423
*
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE file at the root of the source
4+
* tree and available online at
5+
*
6+
* https://github.com/keeps/roda
7+
*/
8+
package org.roda.wui.client.common;
9+
10+
import java.util.List;
11+
12+
import org.roda.core.data.v2.user.RODAMember;
13+
import org.roda.wui.client.common.actions.AbstractActionable;
14+
import org.roda.wui.client.common.actions.ActionableInterceptor;
15+
import org.roda.wui.client.common.actions.RODAMemberAction;
16+
import org.roda.wui.client.common.actions.RODAMemberToolbarActions;
17+
import org.roda.wui.client.common.actions.model.ActionableObject;
18+
import org.roda.wui.client.common.actions.widgets.ActionableWidgetBuilder;
19+
20+
import com.google.gwt.user.client.rpc.AsyncCallback;
21+
22+
/**
23+
*
24+
* @author Miguel Guimarães <mguimaraes@keep.pt>
25+
*/
26+
public class CreateOrUpdateUserActionsToolbar extends BrowseObjectActionsToolbar<RODAMember> {
27+
private boolean isCreate = true;
28+
29+
public void setIsCreate(boolean isCreate) {
30+
this.isCreate = isCreate;
31+
}
32+
33+
public void buildIcon() {
34+
// do nothing
35+
}
36+
37+
public void buildTags() {
38+
// do nothing
39+
}
40+
41+
public void buildActions() {
42+
this.actions.clear();
43+
44+
// Determine the correct action based on context
45+
final RODAMemberAction targetAction = isCreate ? RODAMemberAction.SAVE_USER : RODAMemberAction.UPDATE_USER;
46+
47+
// Create an interceptor that checks validity before calling the backend
48+
AbstractActionable<RODAMember> interceptor = new ActionableInterceptor<RODAMember>(
49+
RODAMemberToolbarActions.get()) {
50+
51+
@Override
52+
public void act(Action<RODAMember> action, RODAMember member, AsyncCallback<ActionImpact> callback) {
53+
54+
if (RODAMemberAction.SAVE_USER.equals(action) || RODAMemberAction.UPDATE_USER.equals(action)) {
55+
// FRONT-END VALIDATION
56+
if (getDataPanel() != null && !getDataPanel().isValid()) {
57+
callback.onSuccess(ActionImpact.NONE);
58+
return;
59+
}
60+
61+
// Pass the freshly validated data down the chain
62+
RODAMember value = getDataPanel().getValue();
63+
if (!isCreate) {
64+
value.setId(member.getId());
65+
}
66+
super.act(action, value, callback);
67+
} else {
68+
super.act(action, member, callback);
69+
}
70+
}
71+
};
72+
73+
// Bind the SAVE button to our new interceptor
74+
this.actions.add(new ActionableWidgetBuilder<RODAMember>(interceptor).withActionCallback(actionCallback)
75+
.buildUngroupedActions(new ActionableObject<>(object), List.of(targetAction)));
76+
}
77+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE file at the root of the source
4+
* tree and available online at
5+
*
6+
* https://github.com/keeps/roda
7+
*/
8+
package org.roda.wui.client.common;
9+
10+
import org.roda.core.data.v2.user.RODAMember;
11+
12+
/**
13+
*
14+
* @author Miguel Guimarães <mguimaraes@keep.pt>
15+
*/
16+
public class NoActionsToolbar extends BrowseObjectActionsToolbar<RODAMember> {
17+
18+
public void build() {
19+
setObjectAndBuild(null, null, null);
20+
}
21+
22+
public void buildIcon() {
23+
// do nothing
24+
}
25+
26+
public void buildTags() {
27+
// do nothing
28+
}
29+
30+
public void buildActions() {
31+
this.actions.clear();
32+
}
33+
}

roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/RODAMemberAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public enum RODAMemberAction implements Actionable.Action<RODAMember> {
1414
NEW_USER(RodaConstants.PERMISSION_METHOD_CREATE_USER), NEW_GROUP(RodaConstants.PERMISSION_METHOD_CREATE_GROUP),
1515
ACTIVATE(RodaConstants.PERMISSION_METHOD_UPDATE_USER), DEACTIVATE(RodaConstants.PERMISSION_METHOD_UPDATE_USER),
16+
CHANGE_PASSWORD(RodaConstants.PERMISSION_METHOD_UPDATE_USER),
1617
EDIT(RodaConstants.PERMISSION_METHOD_UPDATE_USER), REMOVE(RodaConstants.PERMISSION_METHOD_DELETE_USER),
1718
ADD_NEW_GROUP(RodaConstants.PERMISSION_METHOD_UPDATE_USER),
1819
ADD_NEW_MEMBER(RodaConstants.PERMISSION_METHOD_UPDATE_USER),

0 commit comments

Comments
 (0)