Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 55ac6f7

Browse files
committed
#174 Handling role with permission referring to itself
Merged from 2.x
1 parent 6c8273b commit 55ac6f7

File tree

13 files changed

+365
-161
lines changed

13 files changed

+365
-161
lines changed

src/main/java/com/marklogic/appdeployer/command/AbstractCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected SaveReceipt saveResource(ResourceManager mgr, CommandContext context,
115115
* @param context
116116
*/
117117
protected void storeTokenForResourceId(SaveReceipt receipt, CommandContext context) {
118-
URI location = receipt.getResponse().getHeaders().getLocation();
118+
URI location = receipt.getResponse() != null ? receipt.getResponse().getHeaders().getLocation() : null;
119119

120120
String idValue = null;
121121
String resourceName = null;

src/main/java/com/marklogic/mgmt/api/API.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ public API(ManageClient client, ObjectMapper mapper) {
6464
}
6565

6666
protected void initializeAdminManager() {
67-
ManageConfig mc = manageClient.getManageConfig();
68-
if (mc.getAdminUsername() != null && mc.getAdminPassword() != null) {
69-
AdminConfig ac = new AdminConfig(mc.getHost(), 8001, mc.getAdminUsername(), mc.getAdminPassword());
70-
this.adminManager = new AdminManager(ac);
71-
}
67+
if (manageClient != null) {
68+
ManageConfig mc = manageClient.getManageConfig();
69+
if (mc.getAdminUsername() != null && mc.getAdminPassword() != null) {
70+
AdminConfig ac = new AdminConfig(mc.getHost(), 8001, mc.getAdminUsername(), mc.getAdminPassword());
71+
this.adminManager = new AdminManager(ac);
72+
}
73+
}
7274
}
7375

7476
protected ObjectMapper buildDefaultObjectMapper() {

src/main/java/com/marklogic/mgmt/api/Resource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public String save() {
4242
logger.info(format("Saved %s %s", name, label));
4343
}
4444
return format("[Path: %s; Resource ID: %s; HTTP status: %s]", receipt.getPath(), receipt.getResourceId(),
45-
receipt.getResponse().getStatusCode());
45+
receipt.getResponse() != null ? receipt.getResponse().getStatusCode() : "(none)");
4646
}
4747

4848
/**
Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
package com.marklogic.mgmt.api.security;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import javax.xml.bind.annotation.XmlAccessType;
6+
import javax.xml.bind.annotation.XmlAccessorType;
7+
import javax.xml.bind.annotation.XmlElement;
8+
9+
@XmlAccessorType(XmlAccessType.FIELD)
310
public class Permission {
411

5-
private String roleName;
6-
private String capability;
12+
@JsonProperty("role-name")
13+
@XmlElement(name = "role-name")
14+
private String roleName;
15+
private String capability;
716

8-
public String getRoleName() {
9-
return roleName;
10-
}
17+
public String getRoleName() {
18+
return roleName;
19+
}
1120

12-
public void setRoleName(String roleName) {
13-
this.roleName = roleName;
14-
}
21+
public void setRoleName(String roleName) {
22+
this.roleName = roleName;
23+
}
1524

16-
public String getCapability() {
17-
return capability;
18-
}
25+
public String getCapability() {
26+
return capability;
27+
}
1928

20-
public void setCapability(String capability) {
21-
this.capability = capability;
22-
}
29+
public void setCapability(String capability) {
30+
this.capability = capability;
31+
}
2332

2433
}

0 commit comments

Comments
 (0)