-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathBulkUserPermissionRequest.java
More file actions
66 lines (56 loc) · 3.03 KB
/
BulkUserPermissionRequest.java
File metadata and controls
66 lines (56 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.rallydev.rest.request;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
/**
* Represents a WSAPI request to bulk provision a user.
*/
public class BulkUserPermissionRequest extends Request {
private static final String PROJECTPERMISSION_BULKUPDATE = "/projectpermission/bulkupdate";
private String userOID;
private Collection<String> excludedRootProjectOIDs;
private String rootProjectOID;
private String permission;
private boolean forceDowngradePermissions;
/**
*
* @param userOID
* The OID (ObjectID) of the User who will be granted new project permissions
* @param excludedRootProjectOIDs
* The OIDs of any child Project (or a child of a child, or any ancestor to any level) under the root project which are to be excluded from the
* permission change operation.
* @param rootProjectOID
* The OID of the root of the Project tree of which to change the permissions for the given user. The user's Project permission for all Projects
* rooted at this one will be changed, unless (see below for further explanation)
* the Project is on the exclusions list, or
* the operation would result in a downgrade but the force downgrade parameters was not set to tree.
* @param permission
* The permission to grant. Must be one of No Access, Viewer, Editor, or Project Admin.
* @param forceDowngradePermissions
* If you intend to downgrade any existing project permissions, set this to true.
*/
public BulkUserPermissionRequest(String userOID, Collection<String> excludedRootProjectOIDs, String rootProjectOID, String permission,
boolean forceDowngradePermissions) {
super();
this.userOID = userOID;
this.excludedRootProjectOIDs = excludedRootProjectOIDs;
this.rootProjectOID = rootProjectOID;
this.permission = permission;
this.forceDowngradePermissions = forceDowngradePermissions;
}
@Override
public String toUrl() {
List<NameValuePair> params = new ArrayList<NameValuePair>(getParams());
params.add(new BasicNameValuePair("userOID", userOID));
params.add(new BasicNameValuePair("rootProjectOID", rootProjectOID));
params.add(new BasicNameValuePair("permission", permission));
params.add(new BasicNameValuePair("forceDowngradePermissions", Boolean.toString(forceDowngradePermissions)));
if (excludedRootProjectOIDs != null && !excludedRootProjectOIDs.isEmpty()) {
params.add(new BasicNameValuePair("excludedRootProjectOIDs", String.join(",", excludedRootProjectOIDs)));
}
return String.format("%s?%s", PROJECTPERMISSION_BULKUPDATE, URLEncodedUtils.format(params, "utf-8"));
}
}