diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java b/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java index 8692ead6..d3134d77 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java @@ -39,7 +39,7 @@ public class LabelController extends BaseController { private LabelService labelService; - @RequestMapping(method = RequestMethod.POST, value = "/labels", consumes = {"application/json"}) + @RequestMapping(method = RequestMethod.POST, value = "/labels", consumes = {"application/json", "application/xml"}) @ResponseStatus(value = HttpStatus.CREATED) public void createLabel(@RequestBody RestLabel restLabel, @NotNull HttpServletResponse response, @RequestParam(required = false) String title) throws WiseMappingException { // Overwrite title if it was specified by parameter. @@ -56,7 +56,7 @@ public class LabelController extends BaseController { response.setHeader("ResourceId", Integer.toString(label.getId())); } - @RequestMapping(method = RequestMethod.GET, value = "/labels", produces = {"application/json"}) + @RequestMapping(method = RequestMethod.GET, value = "/labels", produces = {"application/json", "application/xml"}) public RestLabelList retrieveList() { final User user = Utils.getUser(); assert user != null; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabelList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabelList.java index f832e104..044ad1af 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabelList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabelList.java @@ -1,16 +1,30 @@ package com.wisemapping.rest.model; import com.wisemapping.model.Label; +import org.codehaus.jackson.annotate.JsonAutoDetect; import org.jetbrains.annotations.NotNull; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +@XmlRootElement(name = "labels") +@XmlAccessorType(XmlAccessType.PROPERTY) +@JsonAutoDetect( + fieldVisibility = JsonAutoDetect.Visibility.NONE, + getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, + isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) public class RestLabelList { @NotNull private final List restLabels; + public RestLabelList(){ + this.restLabels = new ArrayList<>(); + } + public RestLabelList(@NotNull final List