parent
a67f9f1c4b
commit
7967ab217b
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.beans;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel(description = "Error List Item")
|
||||||
|
public class ErrorListItem {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String code = null;
|
||||||
|
@NotNull
|
||||||
|
private String message = null;
|
||||||
|
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
@JsonProperty("code")
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorListItem() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorListItem(String code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description about individual errors occurred
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(required = true, value = "Description about individual errors occurred")
|
||||||
|
@JsonProperty("message")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("errorItem {\n");
|
||||||
|
|
||||||
|
sb.append(" code: ").append(code).append("\n");
|
||||||
|
sb.append(" message: ").append(message).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,193 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.beans;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel(description = "Error Response")
|
||||||
|
public class ErrorResponse {
|
||||||
|
|
||||||
|
private Long code = null;
|
||||||
|
private String message = null;
|
||||||
|
private String description = null;
|
||||||
|
private String moreInfo = null;
|
||||||
|
private List<ErrorListItem> errorItems = new ArrayList<>();
|
||||||
|
|
||||||
|
private ErrorResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "code")
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
public Long getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(Long code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "message")
|
||||||
|
@ApiModelProperty(required = true, value = "ErrorResponse message.")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "description")
|
||||||
|
@ApiModelProperty(value = "A detail description about the error message.")
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "moreInfo")
|
||||||
|
@ApiModelProperty(value = "Preferably an url with more details about the error.")
|
||||||
|
public String getMoreInfo() {
|
||||||
|
return moreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoreInfo(String moreInfo) {
|
||||||
|
this.moreInfo = moreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addErrorListItem(ErrorListItem item) {
|
||||||
|
this.errorItems.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there are more than one error list them out. \nFor example, list out validation errors by each field.
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "errorItems")
|
||||||
|
@ApiModelProperty(value = "If there are more than one error list them out. \n" +
|
||||||
|
"For example, list out validation errors by each field.")
|
||||||
|
public List<ErrorListItem> getErrorItems() {
|
||||||
|
return errorItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorItems(List<ErrorListItem> error) {
|
||||||
|
this.errorItems = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// sb.append("{");
|
||||||
|
// boolean cont = false;
|
||||||
|
// if (code != null) {
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"code\": ").append(code);
|
||||||
|
// }
|
||||||
|
// if (message != null) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"message\": \"").append(message).append("\"");
|
||||||
|
// }
|
||||||
|
// if (description != null) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"description\": ").append(description).append("\"");
|
||||||
|
// }
|
||||||
|
// if (moreInfo != null) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// cont = true;
|
||||||
|
// sb.append(" \"moreInfo\": \"").append(moreInfo).append("\"");
|
||||||
|
// }
|
||||||
|
// if (error != null && error.size() > 0) {
|
||||||
|
// if (cont) {
|
||||||
|
// sb.append(",");
|
||||||
|
// }
|
||||||
|
// sb.append(" \"errorItems\": ").append(error);
|
||||||
|
// }
|
||||||
|
// sb.append("}");
|
||||||
|
// return sb.toString();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ErrorResponseBuilder {
|
||||||
|
|
||||||
|
private Long code = null;
|
||||||
|
private String message = null;
|
||||||
|
private String description = null;
|
||||||
|
private String moreInfo = null;
|
||||||
|
private List<ErrorListItem> error;
|
||||||
|
|
||||||
|
|
||||||
|
public ErrorResponseBuilder() {
|
||||||
|
this.error = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setCode(long code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setMoreInfo(String moreInfo) {
|
||||||
|
this.moreInfo = moreInfo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder addErrorItem(String code, String msg) {
|
||||||
|
ErrorListItem item = new ErrorListItem();
|
||||||
|
item.setCode(code);
|
||||||
|
item.setMessage(msg);
|
||||||
|
this.error.add(item);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponse build() {
|
||||||
|
ErrorResponse errorResponse = new ErrorResponse();
|
||||||
|
errorResponse.setCode(code);
|
||||||
|
errorResponse.setMessage(message);
|
||||||
|
errorResponse.setErrorItems(error);
|
||||||
|
errorResponse.setDescription(description);
|
||||||
|
errorResponse.setMoreInfo(moreInfo);
|
||||||
|
return errorResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,21 +1,120 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<!--
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
~
|
||||||
<modelVersion>4.0.0</modelVersion>
|
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>io.entgra.device.mgt.core</groupId>
|
<groupId>io.entgra.device.mgt.core</groupId>
|
||||||
<artifactId>device-mgt-extensions-feature</artifactId>
|
<artifactId>device-mgt-extensions-feature</artifactId>
|
||||||
<version>5.0.31-SNAPSHOT</version>
|
<version>5.0.31-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>org.example</groupId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature</artifactId>
|
<artifactId>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>WSO2 Carbon - Device Organization Management API Feature</name>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
<description>This feature contains the APIs required for Device Organization Management.</description>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactItems>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>io.entgra.device.mgt.core</groupId>
|
||||||
|
<artifactId>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api
|
||||||
|
</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>war</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>
|
||||||
|
${project.build.directory}/maven-shared-archive-resources/webapps
|
||||||
|
</outputDirectory>
|
||||||
|
<destFileName>api#deviceOrganization-mgt#v1.0.war</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
</artifactItems>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>src/main/resources</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>build.properties</include>
|
||||||
|
<include>p2.inf</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.wso2.maven</groupId>
|
||||||
|
<artifactId>carbon-p2-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>p2-feature-generation</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>p2-feature-gen</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<id>io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api</id>
|
||||||
|
<propertiesFile>../../../features/etc/feature.properties
|
||||||
|
</propertiesFile>
|
||||||
|
<adviceFile>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<propertyDef>org.wso2.carbon.p2.category.type:server
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
</propertyDef>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<propertyDef>org.eclipse.equinox.p2.type.group:false
|
||||||
|
</propertyDef>
|
||||||
</properties>
|
</properties>
|
||||||
|
</adviceFile>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
Loading…
Reference in new issue