Commit 03cfeaee authored by Marco Descher's avatar Marco Descher

[21003] Extend LockResponse/LockInfo

parent 074bab2f
Pipeline #16070 passed with stages
in 7 minutes and 16 seconds
......@@ -26,11 +26,17 @@ public class LockInfo {
private Date creationDate;
@XmlElement
private String systemUuid;
@XmlElement
private String systemLabel;
public LockInfo() {
}
public LockInfo(String storeToString, String userId, String systemUuid) {
this(storeToString, userId, systemUuid, "");
}
public LockInfo(String storeToString, String userId, String systemUuid, String systemLabel) {
String[] split = storeToString.split(StringConstants.DOUBLECOLON);
if (split.length == 2) {
this.elementId = split[1];
......@@ -38,6 +44,7 @@ public class LockInfo {
this.user = userId;
this.creationDate = new Date();
this.systemUuid = systemUuid;
this.systemLabel = systemLabel;
} else {
throw new IllegalArgumentException(storeToString);
}
......@@ -72,6 +79,10 @@ public class LockInfo {
public String getSystemUuid() {
return systemUuid;
}
public String getSystemLabel(){
return systemLabel;
}
public static String getElementId(String storeToString) {
String[] split = storeToString.split(StringConstants.DOUBLECOLON);
......
......@@ -4,52 +4,65 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class LockResponse {
public static final LockResponse OK = new LockResponse(Status.OK, null);
public static final LockResponse ERROR = new LockResponse(Status.ERROR, null);
public enum Status{
OK, DENIED, DENIED_PERMANENT, ERROR
public enum Status {
OK, DENIED, DENIED_PERMANENT, ERROR
};
private Status status;
private LockInfo lockInfo;
public LockResponse() {
private LockRequest.Type lockRequestType;
public LockResponse(){
status = Status.OK;
lockInfo = new LockInfo();
}
public LockResponse(Status status, LockInfo lockInfo) {
public LockResponse(Status status, LockInfo lockInfo){
this(status, lockInfo, null);
}
public LockResponse(Status status, LockInfo lockInfo, LockRequest.Type lockRequestType) {
this.status = status;
this.lockInfo = (lockInfo!=null) ? lockInfo : new LockInfo();
this.lockInfo = (lockInfo != null) ? lockInfo : new LockInfo();
this.lockRequestType = lockRequestType;
}
public Status getStatus() {
public Status getStatus(){
return status;
}
public void setStatus(Status status) {
public void setStatus(Status status){
this.status = status;
}
public LockInfo getLockInfo() {
public LockInfo getLockInfo(){
return lockInfo;
}
public void setLockInfo(LockInfo lockInfo) {
public void setLockInfo(LockInfo lockInfo){
this.lockInfo = lockInfo;
}
public static LockResponse OK(LockInfo lie) {
/**
* @return the request type this response answers to
*/
public LockRequest.Type getLockRequestType(){
return lockRequestType;
}
public static LockResponse OK(LockInfo lie){
return new LockResponse(Status.OK, lie);
}
public static LockResponse DENIED(LockInfo lie) {
public static LockResponse DENIED(LockInfo lie){
return new LockResponse(Status.DENIED, lie);
}
public boolean isOk() {
return getStatus()==Status.OK;
public boolean isOk(){
return getStatus() == Status.OK;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment