Skip to content

Commit 5c21912

Browse files
committed
Update create/edit user and group forms to use the new generic form
1 parent e5e4b52 commit 5c21912

56 files changed

Lines changed: 2513 additions & 2328 deletions

File tree

Some content is hidden

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

.github/workflows/staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
3131
restore-keys: ${{ runner.os }}-maven-
3232
- name: Install clamdscan
33-
run: sudo apt-get install clamdscan -y
33+
run: sudo apt-get update && sudo apt-get install clamdscan -y
3434
- name: Run tests & install
3535
run: mvn $MAVEN_CLI_OPTS -Dtestng.groups="travis" -Denforcer.skip=true clean org.jacoco:jacoco-maven-plugin:prepare-agent install
3636
env:

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: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
import org.springframework.beans.factory.annotation.Autowired;
8080
import org.springframework.http.ResponseEntity;
8181
import org.springframework.ldap.NamingException;
82-
import org.springframework.web.bind.annotation.PathVariable;
8382
import org.springframework.web.bind.annotation.RequestBody;
8483
import org.springframework.web.bind.annotation.RequestMapping;
8584
import org.springframework.web.bind.annotation.RestController;
@@ -274,7 +273,7 @@ private static Set<String> mapCasGroupstoRODAGroups(Set<String> casGroups) {
274273
}
275274

276275
@Override
277-
public RODAMember getUser(String name) {
276+
public RODAMember getMember(String name) {
278277
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
279278
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
280279
LogEntryState state = LogEntryState.SUCCESS;
@@ -298,6 +297,26 @@ public RODAMember getUser(String name) {
298297
}
299298
}
300299

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

619638
@Override
620-
public Void updateGroup(@RequestBody Group modifiedGroup) {
639+
public Group updateGroup(@RequestBody Group modifiedGroup) {
621640
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
622641
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
623642
LogEntryState state = LogEntryState.SUCCESS;
@@ -626,15 +645,14 @@ public Void updateGroup(@RequestBody Group modifiedGroup) {
626645
// check user permissions
627646
controllerAssistant.checkRoles(requestContext.getUser());
628647
// delegate
629-
membersService.updateGroup(modifiedGroup);
648+
return membersService.updateGroup(modifiedGroup);
630649
} catch (RODAException e) {
631650
state = LogEntryState.FAILURE;
632651
throw new RESTException(e);
633652
} finally {
634653
// register action
635654
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUP_PARAM, modifiedGroup);
636655
}
637-
return null;
638656
}
639657

640658
@Override
@@ -721,7 +739,7 @@ public Group removeMembersFromGroup(String id, String userId) {
721739
} finally {
722740
// register action
723741
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUP_PARAM, id,
724-
RodaConstants.CONTROLLER_USER_PARAM, userId);
742+
RodaConstants.CONTROLLER_USER_PARAM, userId);
725743
}
726744
}
727745

@@ -786,7 +804,7 @@ public User updateUser(@RequestBody UpdateUserRequest userRequest) {
786804
} finally {
787805
// register action
788806
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USER_PARAM,
789-
requestContext.getUser());
807+
requestContext.getUser().getFullName());
790808
}
791809
}
792810

@@ -808,7 +826,7 @@ public User updateMyUser(@RequestBody UpdateUserRequest userOperations) {
808826
} finally {
809827
// register action
810828
controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USER_PARAM,
811-
userOperations.getUser());
829+
userOperations.getUser().getFullName());
812830
}
813831
}
814832

@@ -997,7 +1015,7 @@ public LongResponse count(@RequestBody CountRequest countRequest) {
9971015
}
9981016

9991017
@Override
1000-
public List<String> suggest(SuggestRequest suggestRequest) {
1018+
public List<String> suggest(@RequestBody SuggestRequest suggestRequest) {
10011019
return indexService.suggest(suggestRequest, RODAMember.class);
10021020
}
10031021

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: 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)