diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml deleted file mode 100644 index e96bb9f4c2..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - application-mgt - io.entgra.device.mgt.core - 5.0.26-SNAPSHOT - ../pom.xml - - - 4.0.0 - io.entgra.device.mgt.core.application.mgt.addons - Entgra - Application Management Add-Ons - Entgra - Application Management Add-Ons - https://entgra.io - bundle - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${io.entgra.device.mgt.core.version} - Application Management Add-Ons Bundle - - com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.application.mgt.addons.jaxrs, - javax.servlet;version="[4.0,5)", - javax.servlet.http;version="[4.0,5)", - javax.validation;version="[1.1,2)", - javax.validation.executable;version="[1.1,2)", - javax.ws.rs;version="[2.1,3)", - javax.ws.rs.core;version="[2.1,3)", - javax.ws.rs.ext;version="[2.1,3)", - org.apache.commons.logging;version="[1.2,2)", - org.apache.cxf.interceptor;version="[3.5,4)", - org.apache.cxf.jaxrs.lifecycle;version="[3.5,4)", - org.apache.cxf.jaxrs.model;version="[3.5,4)", - org.apache.cxf.message;version="[3.5,4)", - org.apache.cxf.phase;version="[3.5,4)" - - - io.entgra.device.mgt.core.application.mgt.addons.* - - - - - - - - - - org.apache.felix - org.apache.felix.scr.ds-annotations - provided - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - org.ops4j.pax.logging - pax-logging-api - provided - - - commons-codec.wso2 - commons-codec - - - commons-io.wso2 - commons-io - - - io.swagger - swagger-annotations - provided - - - org.json.wso2 - json - - - com.google.code.gson - gson - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.common - - - javax.servlet - javax.servlet-api - provided - - - org.hibernate - hibernate-validator - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/ApiOriginFilter.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/ApiOriginFilter.java deleted file mode 100644 index 5e732b40ee..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/ApiOriginFilter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.application.mgt.addons; - - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -public class ApiOriginFilter implements Filter { - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } - - public void destroy() { - //do nothing - } - - public void init(FilterConfig filterConfig) throws ServletException { - //do nothing - } -} \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/FileStreamingOutput.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/FileStreamingOutput.java deleted file mode 100644 index 49e11de0ba..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/FileStreamingOutput.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.application.mgt.addons; - - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.StreamingOutput; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * io.entgra.device.mgt.core.application.mgt.addons.FileStreamingOutput to allow the user to send the files as Stream. - */ -public class FileStreamingOutput implements StreamingOutput { - private InputStream inputStream; - - public FileStreamingOutput(InputStream inputStream) { - this.inputStream = inputStream; - } - - @Override - public void write(OutputStream outputStream) throws IOException, WebApplicationException { - try { - byte[] buffer = new byte[inputStream.available()]; - inputStream.read(buffer); - outputStream.write(buffer); - outputStream.flush(); - } finally { - if (inputStream != null) { - inputStream.close(); - } - if (outputStream != null) { - outputStream.close(); - } - } - - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java deleted file mode 100644 index c9ef83455f..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.application.mgt.addons; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import io.entgra.device.mgt.core.application.mgt.addons.jaxrs.AnnotationExclusionStrategy; - -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; -import java.io.*; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; - -/** - * This provider is used to change a JSON object to complex object and inversely in request and response. - */ -@Provider -@Produces(APPLICATION_JSON) -@Consumes(APPLICATION_JSON) -public class JSONMessageHandler implements MessageBodyWriter, MessageBodyReader { - - private Gson gson; - private static final String UTF_8 = "UTF-8"; - - public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return true; - } - - private Gson getGson() { - if (gson == null) { - final GsonBuilder gsonBuilder = new GsonBuilder() - .setDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") - .setExclusionStrategies(new AnnotationExclusionStrategy()); - gson = gsonBuilder.create(); - } - return gson; - } - - public Object readFrom(Class objectClass, Type type, Annotation[] annotations, MediaType mediaType, - MultivaluedMap stringStringMultivaluedMap, InputStream entityStream) - throws IOException, WebApplicationException { - try (InputStreamReader reader = new InputStreamReader(entityStream, UTF_8)) { - return getGson().fromJson(reader, type); - } - } - - public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return true; - } - - public long getSize(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return -1; - } - - public void writeTo(Object object, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, - MultivaluedMap stringObjectMultivaluedMap, OutputStream entityStream) - throws IOException, WebApplicationException { - try (OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8)) { - getGson().toJson(object, type, writer); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java deleted file mode 100644 index fbd8df6c45..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.application.mgt.addons; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import io.entgra.device.mgt.core.application.mgt.addons.jaxrs.AnnotationExclusionStrategy; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; - -import javax.ws.rs.Consumes; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Provider; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -/** - * Provider for the text/plain type of input. Particularly use-ful for the complex objects sent along with Multipart - * request. - */ -@Provider -@Consumes(MediaType.TEXT_PLAIN) -public class MultipartCustomProvider implements MessageBodyReader { - private Gson gson; - - public MultipartCustomProvider() { - final GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") - .setExclusionStrategies(new AnnotationExclusionStrategy()); - gson = gsonBuilder.create(); - } - @Override - public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return !aClass.equals(Attachment.class); - } - - @Override - public Object readFrom(Class objectClass, Type type, Annotation[] annotations, MediaType mediaType, - MultivaluedMap headers, InputStream inputStream) throws IOException, - WebApplicationException { - ByteArrayOutputStream result = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int length; - while ((length = inputStream.read(buffer)) != -1) { - result.write(buffer, 0, length); - } - String jsonString = result.toString(); - JsonObject obj = new JsonParser().parse(jsonString).getAsJsonObject(); - return gson.fromJson(obj, type); - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/ValidationInterceptor.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/ValidationInterceptor.java deleted file mode 100644 index 9bf5cee38f..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/ValidationInterceptor.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.application.mgt.addons; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; -import org.apache.cxf.jaxrs.model.ClassResourceInfo; -import org.apache.cxf.jaxrs.model.OperationResourceInfo; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageContentsList; -import org.apache.cxf.phase.AbstractPhaseInterceptor; -import org.apache.cxf.phase.Phase; - -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import javax.validation.executable.ExecutableValidator; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Set; - -public class ValidationInterceptor extends AbstractPhaseInterceptor { - private Log log = LogFactory.getLog(getClass()); - private Validator validator = null; //validator interface is thread-safe - - public ValidationInterceptor() { - super(Phase.PRE_INVOKE); - ValidatorFactory defaultFactory = Validation.buildDefaultValidatorFactory(); - validator = defaultFactory.getValidator(); - if (validator == null) { - log.warn("Bean Validation provider could not be found, no validation will be performed"); - } else { - log.debug("Validation In-Interceptor initialized successfully"); - } - } - - @Override - public void handleMessage(Message message) throws Fault { - final OperationResourceInfo operationResource = message.getExchange().get(OperationResourceInfo.class); - if (operationResource == null) { - log.info("OperationResourceInfo is not available, skipping validation"); - return; - } - - final ClassResourceInfo classResource = operationResource.getClassResourceInfo(); - if (classResource == null) { - log.info("ClassResourceInfo is not available, skipping validation"); - return; - } - - final ResourceProvider resourceProvider = classResource.getResourceProvider(); - if (resourceProvider == null) { - log.info("ResourceProvider is not available, skipping validation"); - return; - } - - final List arguments = MessageContentsList.getContentsList(message); - final Method method = operationResource.getAnnotatedMethod(); - final Object instance = resourceProvider.getInstance(message); - if (method != null && arguments != null) { - //validate the parameters(arguments) over the invoked method - validate(method, arguments.toArray(), instance); - - //validate the fields of each argument - for (Object arg : arguments) { - if (arg != null) - validate(arg); - } - } - - } - - public void validate(final Method method, final Object[] arguments, final T instance) { - if (validator == null) { - log.warn("Bean Validation provider could not be found, no validation will be performed"); - return; - } - - ExecutableValidator methodValidator = validator.forExecutables(); - Set> violations = methodValidator.validateParameters(instance, - method, arguments); - - if (!violations.isEmpty()) { - throw new ConstraintViolationException(violations); - } - } - - public void validate(final T object) { - if (validator == null) { - log.warn("Bean Validation provider could be found, no validation will be performed"); - return; - } - - Set> violations = validator.validate(object); - - if (!violations.isEmpty()) { - throw new ConstraintViolationException(violations); - } - } - - public void handleFault(org.apache.cxf.message.Message messageParam) { - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java deleted file mode 100644 index 8be3d9cd8a..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/jaxrs/AnnotationExclusionStrategy.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.application.mgt.addons.jaxrs; - -import com.google.gson.ExclusionStrategy; -import com.google.gson.FieldAttributes; - -/** - * This class is used to exclude certain fields when serializing and de-serializing based on the annotation. - */ -public class AnnotationExclusionStrategy implements ExclusionStrategy { - - @Override - public boolean shouldSkipField(FieldAttributes f) { - return f.getAnnotation(Exclude.class) != null; - } - - @Override - public boolean shouldSkipClass(Class clazz) { - return false; - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/jaxrs/Exclude.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/jaxrs/Exclude.java deleted file mode 100644 index 2cc94b6b86..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/jaxrs/Exclude.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.application.mgt.addons.jaxrs; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This class is the representation of custom developed Exclude annotation. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Exclude { -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml deleted file mode 100644 index 3f9fe54664..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - application-mgt - io.entgra.device.mgt.core - 5.0.26-SNAPSHOT - ../pom.xml - - - 4.0.0 - io.entgra.device.mgt.core.application.mgt.api - war - Entgra - Application Management API - Entgra - Application Management API - https://entgra.io - - - - - maven-war-plugin - - WEB-INF/lib/*cxf*.jar - api#application-mgt#v1.0 - - - - - - - - deploy - - compile - - - org.apache.maven.plugins - maven-antrun-plugin - - - compile - - run - - - - - - - - - - - - - - - - - - client - - test - - - org.codehaus.mojo - exec-maven-plugin - - - test - - java - - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - junit - junit - test - - - org.codehaus.jackson - jackson-jaxrs - - - org.codehaus.jackson - jackson-core-asl - - - javax.ws.rs - jsr311-api - provided - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.ops4j.pax.logging - pax-logging-api - provided - - - org.json.wso2 - json - - - commons-codec.wso2 - commons-codec - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.core - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.common - provided - - - io.swagger - swagger-annotations - - - io.swagger - swagger-core - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - io.swagger - swagger-jaxrs - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - javax.servlet - javax.servlet-api - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.apimgt.annotations - provided - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.addons - - - commons-io.wso2 - commons-io - - - \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java deleted file mode 100644 index 019e2b9721..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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.application.mgt.api; - -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.swagger.annotations.*; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * APIs to handle application management related tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Application Management Artifact Download Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ApplicationManagementArtifactDownloadService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/artifact"), - }) - } - ) -) -@Path("/artifact") -@Api(value = "ApplicationDTO Management Artifact Downloading Service") -@Produces(MediaType.APPLICATION_JSON) -public interface ArtifactDownloadAPI { - - @GET - @Path("/{tenantId}/{appHashValue}/{folderName}/{fileName}") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation( - produces = MediaType.APPLICATION_OCTET_STREAM, - httpMethod = "GET", - value = "get application management UI configuration", - notes = "This will get all UI configuration of application management" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got UI config.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an defined UI config." + - "query."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the UI config.", - response = ErrorResponse.class) - }) - Response getArtifact( - @ApiParam( - name = "tenantId", - value = "Tenant Id of the application artifact belongs.", - required = true) - @PathParam("tenantId") int tenantId, - @ApiParam( - name = "appHashValue", - value = "Hash value of the application release.", - required = true) - @PathParam("appHashValue") String uuid, - @ApiParam( - name = "folderName", - value = "Name of the folder where the artifact store.", - required = true) - @PathParam("folderName") String folderName, - @ApiParam( - name = "fileName", - value = "Name of the artifact", - required = true) - @PathParam("fileName") String fileName); - - @GET - @Path("/plist/{uuid}") - @Produces(MediaType.TEXT_XML) - @ApiOperation( - produces = MediaType.TEXT_XML, - httpMethod = "GET", - value = "Get plist artifact content of an application", - notes = "Get plist artifact content of an application" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved plist artifact content.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. Plist artifact content not found for the application."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while retrieving plist artifact content.", - response = ErrorResponse.class) - }) - Response getPlistArtifact( - @ApiParam( - name = "uuid", - value = "UUID of the application release.", - required = true) - @PathParam("uuid") String uuid); - - @GET - @Path("/{deviceType}/agent") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation( - produces = MediaType.APPLICATION_OCTET_STREAM, - httpMethod = "GET", - value = "get the agent of a device type", - notes = "This will download an agent depending on the device type" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got the agent.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an defined agent for the resource." + - "query."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the agent.", - response = ErrorResponse.class) - }) - Response getDeviceTypeAgent( - @ApiParam( - name = "deviceType", - value = "Device type of the agent.", - example = "android", - required = true) - @PathParam("deviceType") String deviceType, - @ApiParam( - name = "tenantDomain", - value = "Tenant Domain of the application artifact belongs.", - defaultValue = "carbon.super") - @QueryParam("tenantDomain") String tenantDomain); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java deleted file mode 100644 index 3395cf5643..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.application.mgt.api.impl; - -import io.entgra.device.mgt.core.application.mgt.api.ArtifactDownloadAPI; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.AppmDataHandler; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Implementation of ApplicationDTO Management related APIs. - */ -@Produces({"application/json"}) -@Path("/artifact") -public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI { - - private static final Log log = LogFactory.getLog(ArtifactDownloadAPIImpl.class); - - @GET - @Override - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Path("/{tenantId}/{appHashValue}/{folderName}/{fileName}") - public Response getArtifact( - @PathParam("tenantId") int tenantId, - @PathParam("appHashValue") String appHashValue, - @PathParam("folderName") String folderName, - @PathParam("fileName") String fileName) { - AppmDataHandler dataHandler = APIUtil.getDataHandler(); - try (InputStream fileInputStream = dataHandler - .getArtifactStream(tenantId, appHashValue, folderName, fileName)) { - byte[] content = IOUtils.toByteArray(fileInputStream); - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - Response.ResponseBuilder response = Response - .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); - response.status(Response.Status.OK); - response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); - response.header("Content-Length", content.length); - return response.build(); - } catch (IOException e) { - String msg = "Error occurred while creating input stream from buffer array. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (NotFoundException e) { - String msg = "Couldn't find an application release for app hash value: " + appHashValue - + " and file name: " + fileName; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid data is used with the request to get input stream of the application release. UUID: " - + appHashValue + " and file name: " + fileName; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting the application release artifact file. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (IOException e) { - String msg = "Error occurred while getting the byte array of application release artifact file. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Override - @Produces(MediaType.TEXT_XML) - @Path("/plist/{uuid}") - public Response getPlistArtifact(@PathParam("uuid") String uuid) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - String plistContent = applicationManager.getPlistArtifact(uuid); - return Response.status(Response.Status.OK).entity(plistContent).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting the application plist artifact file."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Override - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Path("/{deviceType}/agent") - public Response getDeviceTypeAgent(@PathParam("deviceType") String deviceType, - @DefaultValue("carbon.super") - @QueryParam("tenantDomain") String tenantDomain) { - AppmDataHandler dataHandler = APIUtil.getDataHandler(); - try (InputStream fileInputStream = dataHandler.getAgentStream(tenantDomain, deviceType)) { - byte[] content = IOUtils.toByteArray(fileInputStream); - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - Response.ResponseBuilder response = Response - .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); - response.status(Response.Status.OK); - String fileName = Constants.AGENT_FILE_NAMES.get(deviceType); - response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); - response.header("Content-Length", content.length); - return response.build(); - } catch (IOException e) { - String msg = "Error occurred while creating input stream from buffer array. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (NotFoundException e) { - String msg = "Requesting device type agent for unsupported device type " + deviceType; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e){ - String msg = "Couldn't find the device type agent in the system."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting the device type agent. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (IOException e) { - String msg = "Error occurred while getting the byte array of application release artifact file. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/META-INF/permissions.xml deleted file mode 100644 index d6c746eb35..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/META-INF/permissions.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml deleted file mode 100644 index 705c89edc9..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - false - - - CXF3,Carbon - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml deleted file mode 100644 index 2db1ba9a48..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 49cecdcfd4..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - Application Management Webapp - - JAX-WS/JAX-RS Application Management Endpoint - JAX-WS/JAX-RS Servlet - CXFServlet - - org.apache.cxf.transport.servlet.CXFServlet - - - - swagger.security.filter - ApiAuthorizationFilterImpl - - 1 - - - CXFServlet - /* - - - 60 - - - doAuthentication - true - - - - - - - - - - - - - - - - - managed-api-enabled - true - - - managed-api-owner - admin - - - isSharedWithAllTenants - true - - - - ApiOriginFilter - io.entgra.device.mgt.core.application.mgt.addons.ApiOriginFilter - - - - HttpHeaderSecurityFilter - org.apache.catalina.filters.HttpHeaderSecurityFilter - - hstsEnabled - false - - - - - ContentTypeBasedCachePreventionFilter - org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter - - patterns - text/html" ,application/json" ,text/plain - - - filterAction - enforce - - - httpHeaders - Cache-Control: no-store, no-cache, must-revalidate, private - - - - - HttpHeaderSecurityFilter - /* - - - - ContentTypeBasedCachePreventionFilter - /* - - - - ApiOriginFilter - /* - - - - nonSecuredEndPoints - - /api/application-mgt/v1.0/artifact/.*, - /api/application-mgt/v1.0/config/.* - - - - \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml deleted file mode 100644 index 47bf5b79b2..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - application-mgt - io.entgra.device.mgt.core - 5.0.26-SNAPSHOT - ../pom.xml - - - 4.0.0 - io.entgra.device.mgt.core.application.mgt.publisher.api - war - Entgra - Application Management Publisher API - Entgra - Application Management Publisher API - https://entgra.io - - - - - maven-war-plugin - - WEB-INF/lib/*cxf*.jar - api#application-mgt-publisher#v1.0 - - - - - - - - deploy - - compile - - - org.apache.maven.plugins - maven-antrun-plugin - - - compile - - run - - - - - - - - - - - - - - - - - - client - - test - - - org.codehaus.mojo - exec-maven-plugin - - - test - - java - - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - junit - junit - test - - - org.codehaus.jackson - jackson-jaxrs - - - org.codehaus.jackson - jackson-core-asl - - - javax.ws.rs - jsr311-api - provided - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.ops4j.pax.logging - pax-logging-api - provided - - - org.json.wso2 - json - - - commons-codec.wso2 - commons-codec - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.core - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.common - provided - - - io.swagger - swagger-annotations - - - io.swagger - swagger-core - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - io.swagger - swagger-jaxrs - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - javax.servlet - javax.servlet-api - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.apimgt.annotations - provided - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.addons - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.device.mgt.common - - - \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java deleted file mode 100644 index a308359b0d..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java +++ /dev/null @@ -1,1369 +0,0 @@ -/* - * 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.application.mgt.publisher.api; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import io.swagger.annotations.*; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * APIs to handle application management related tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Application Management Publisher Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ApplicationManagementPublisherService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-publisher/v1.0/applications"), - }) - } - ), - tags = { - @Tag(name = "application_management, device_management", description = "App publisher related APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "Get ApplicationDTO Details", - description = "Get application details", - key = "perm:app:publisher:view", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/application/view"} - ), - @Scope( - name = "Update an ApplicationDTO", - description = "Update an application", - key = "perm:app:publisher:update", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/application/update"} - ) - } -) -@Path("/applications") -@Api(value = "ApplicationDTO Management") -@Produces(MediaType.APPLICATION_JSON) -public interface ApplicationManagementPublisherAPI { - - String SCOPE = "scope"; - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get all applications", - notes = "This will get all applications", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got application list.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Application retrieving request payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the application list.", - response = ErrorResponse.class) - }) Response getApplications( - @ApiParam( - name = "Filter", - value = "Get application filter", - required = true) - @Valid Filter filter); - - @GET - @Path("/{appId}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get the application of requesting application id and state", - notes = "This will get the application identified by the application id and state, if exists", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved relevant application.", - response = ApplicationDTO.class), - @ApiResponse( - code = 403, - message = "Forbidden. \n Don't have permission to access the application"), - @ApiResponse( - code = 404, - message = "Not Found. \n Application not found"), - @ApiResponse( - code = 409, - message = "Conflict. \n Couldn't find an active application"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting relevant application.", - response = ErrorResponse.class) - }) - Response getApplication( - @ApiParam( - name = "appId", - value = "application Id", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "state", - value = "state") - @QueryParam("state") String state - ); - - @GET - @Path("/release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get the application release of requesting application UUID and state", - notes = "This will get the application release identified by the application release uuid and state.", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved relevant application release.", - response = ApplicationDTO.class), - @ApiResponse( - code = 403, - message = "Forbidden. \n Don't have permission to access the application release"), - @ApiResponse( - code = 404, - message = "Not Found. \n Application release not found"), - @ApiResponse( - code = 409, - message = "Conflict. \n Application release is in the end state of lifecycle flow"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting relevant application release.", - response = ErrorResponse.class) - }) - Response getApplicationByUUID( - @ApiParam( - name = "uuid", - value = "application release uuid", - required = true) - @PathParam("uuid") String uuid - ); - - @PUT - @Path("/{appId}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Edit an application", - notes = "This will edit the new application", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully edited the application.", - response = ApplicationDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO updating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while editing the application.", - response = ErrorResponse.class) - }) - Response updateApplication( - @ApiParam( - name = "appId", - value = "application Id", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "application", - value = "Application data that need to be edited.", - required = true) - @Valid ApplicationUpdateWrapper applicationUpdateWrapper - ); - - @POST - @Path("/ent-app") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an application", - notes = "This will create a new application", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application.", - response = ApplicationDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the application.", - response = ErrorResponse.class) - }) - Response createEntApp( - @ApiParam( - name = "application", - value = "The application that need to be created.", - required = true) - ApplicationWrapper application, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished); - - @POST - @Path("/web-app") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an web app", - notes = "This will create a new web app", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created a web application.", - response = ApplicationDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Web app creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the web app.", - response = ErrorResponse.class) - }) - Response createWebApp( - @ApiParam( - name = "webapp", - value = "The web app that need to be created.", - required = true) - WebAppWrapper webAppWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @POST - @Path("/public-app") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an public app", - notes = "This will create a new public app", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created a public app.", - response = ApplicationDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "public app creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the public app.", - response = ErrorResponse.class) - }) - Response createPubApp( - @ApiParam( - name = "public-app", - value = "The public app that need to be created.", - required = true) - PublicAppWrapper publicAppWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @POST - @Path("/custom-app") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an custom application", - notes = "This will create a new custom application", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - }, - nickname = "createCustomAppByAppWrapper" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application.", - response = ApplicationDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the application.", - response = ErrorResponse.class) - }) - Response createCustomApp( - @ApiParam( - name = "application", - value = "The application that need to be created.", - required = true) - CustomAppWrapper customAppWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{deviceType}/ent-app/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an application", - notes = "This will create a new application", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application.", - response = ApplicationRelease.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the application.", - response = ErrorResponse.class) - }) - Response createEntAppRelease( - @ApiParam( - name = "deviceType", - value = "Device type that application is compatible with.", - required = true) - @PathParam("deviceType") String deviceType, - @ApiParam( - name = "appId", - value = "Id of the application.", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "applicationRelease", - value = "The application release that need to be created.", - required = true) - EntAppReleaseWrapper entAppReleaseWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{deviceType}/public-app/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an application", - notes = "This will create a new public application release", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application.", - response = ApplicationRelease.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the application.", - response = ErrorResponse.class) - }) - Response createPubAppRelease( - @ApiParam( - name = "deviceType", - value = "Device type that application is compatible with.", - required = true) - @PathParam("deviceType") String deviceType, - @ApiParam( - name = "appId", - value = "Id of the application.", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "applicationRelease", - value = "The application release that need to be created.", - required = true) - PublicAppReleaseWrapper publicAppReleaseWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @Path("/web-app/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an application", - notes = "This will create a new web application release", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application.", - response = ApplicationRelease.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the application.", - response = ErrorResponse.class) - }) - Response createWebAppRelease( - @ApiParam( - name = "appId", - value = "Id of the application.", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "applicationRelease", - value = "The application release that need to be created.", - required = true) - WebAppReleaseWrapper webAppReleaseWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{deviceType}/custom-app/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create an application", - notes = "This will create a new custom application release", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application.", - response = ApplicationRelease.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO creating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while creating the application.", - response = ErrorResponse.class) - }) - Response createCustomAppRelease( - @ApiParam( - name = "deviceType", - value = "Device type that application is compatible with.", - required = true) - @PathParam("deviceType") String deviceType, - @ApiParam( - name = "appId", - value = "Id of the application.", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "applicationRelease", - value = "The application release that need to be created.", - required = true) - CustomAppReleaseWrapper customAppReleaseWrapper, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished - ); - - @PUT - @Path("/image-artifacts/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Upload artifacts", - notes = "This will create a new application", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated artifacts."), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Error occurred while updating the application."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the application list.", - response = ErrorResponse.class) - }) - Response updateApplicationImageArtifacts( - @ApiParam( - name = "uuid", - value = "UUID of the application", - required = true) - @PathParam("uuid") String applicationUUID, - @ApiParam( - name = "icon", - value = "Icon of the uploading application") - Base64File iconFile, - @ApiParam( - name = "banner", - value = "Banner of the uploading application") - Base64File bannerFile, - @ApiParam( - name = "screenshot1", - value = "Screen Shots of the uploading application") - List screenshots - ); - - @GET - @Path("/device-type/{deviceType}/app-name") - @ApiOperation( - httpMethod = "GET", - value = "Check the application existence", - notes = "This API is responsible to check whether application exist or not for the given device type and " - + "application name.", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Application doesn't exists."), - @ApiResponse( - code = 409, - message = "CONFLICT. \n Application exists"), - @ApiResponse( - code = 400, - message = "Bad Request. \n Found invalid device type with the request."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while checking the application existence" - + " for given application name and device type name the application list.", - response = ErrorResponse.class) - }) - Response isExistingApplication( - @ApiParam( - name = "deviceType", - value = "Application compatible device type name", - required = true) - @PathParam("deviceType") String deviceType, - @ApiParam( - name = "appName", - value = "Application name", - required = true) - @QueryParam("appName") String appName - ); - - @PUT - @Path("/ent-app-artifact/{deviceType}/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Upload artifacts", - notes = "This will create a new application", - tags = "ApplicationDTO Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - }, - nickname = "updateApplicationArtifactByDeviceTypeAndUUID" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully uploaded artifacts."), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO artifact updating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Couldn't found application/application release to update " - + "application release artifact."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the application list.", - response = ErrorResponse.class) - }) - Response updateApplicationArtifact( - @ApiParam( - name = "deviceType", - value = "Type of the device i.e Android, IOS etc", - required = true) - @PathParam("deviceType") String deviceType, - @ApiParam( - name = "uuid", - value = "UUID of the application", - required = true) - @PathParam("uuid") String applicationUUID, - Base64File binaryFile - ); - - @PUT - @Path("/ent-app-release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.MULTIPART_FORM_DATA, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Update an application release", - notes = "This will update a new application release", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application release.", - response = ApplicationReleaseDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO release updating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while releasing the application.", - response = ErrorResponse.class) - }) - Response updateEntAppRelease( - @ApiParam( - name = "uuid", - value = "Unique identifier of the ApplicationDTO Release", - required = true) - @PathParam("uuid") String applicationUUID, - @ApiParam( - name = "entAppReleaseWrapper", - value = "Application release wrapper which is going to update.", - required = true) - EntAppReleaseWrapper entAppReleaseWrapper); - - @PUT - @Path("/public-app-release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.MULTIPART_FORM_DATA, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Update an public app release", - notes = "This will update the public app release", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully update an app release.", - response = ApplicationReleaseDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Public app release updating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while releasing the application.", - response = ErrorResponse.class) - }) - Response updatePubAppRelease( - @ApiParam( - name = "uuid", - value = "Unique identifier of the ApplicationDTO Release", - required = true) - @PathParam("uuid") String applicationUUID, - @ApiParam( - name = "pubAppReleaseWrapper", - value = "Application release wrapper which is going to update.", - required = true) - PublicAppReleaseWrapper publicAppReleaseWrapper); - - @PUT - @Path("/web-app-release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.MULTIPART_FORM_DATA, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Update an public app release", - notes = "This will update the public app release", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully update an app release.", - response = ApplicationReleaseDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Public app release updating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while releasing the application.", - response = ErrorResponse.class) - }) - Response updateWebAppRelease( - @ApiParam( - name = "uuid", - value = "Unique identifier of the ApplicationDTO Release", - required = true) - @PathParam("uuid") String applicationUUID, - @ApiParam( - name = "pubAppReleaseWrapper", - value = "Application release wrapper which is going to update.", - required = true) - WebAppReleaseWrapper webAppReleaseWrapper - ); - - @PUT - @Path("/custom-app-release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.MULTIPART_FORM_DATA, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Update an custom application release", - notes = "This will update a custom app release", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully created an application release.", - response = ApplicationReleaseDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "ApplicationDTO release updating payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while releasing the application.", - response = ErrorResponse.class) - }) - Response updateCustomAppRelease( - @ApiParam( - name = "uuid", - value = "Unique identifier of the ApplicationDTO Release", - required = true) - @PathParam("uuid") String applicationUUID, - @ApiParam( - name = "entAppReleaseWrapper", - value = "Application release wrapper which is going to update.", - required = true) - CustomAppReleaseWrapper customAppReleaseWrapper); - - @GET - @Path("/life-cycle/state-changes/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get lifecycle states", - notes = "Get all lifecycle states", - tags = "Lifecycle Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved lifecycle states.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Couldn't found an application release for application release UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the lifecycle list.", - response = ErrorResponse.class) - }) - Response getLifecycleStates( - @ApiParam( - name = "uuid", - value = "UUID of the application release.") - @PathParam("uuid") String applicationUuid); - - @POST - @Path("/life-cycle/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add a lifecycle state", - notes = "This will add a new lifecycle state", - tags = "Lifecycle Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully add a lifecycle state.", - response = ApplicationDTO.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Lifecycle State changing request contains unacceptable or vulnerable data"), - @ApiResponse( - code = 403, - message = "Don't have permission to move the lifecycle state of a given application release" - + " to the given lifecycle state."), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Error occurred while adding new lifecycle state.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred adding a lifecycle state.", - response = ErrorResponse.class) - }) - Response addLifecycleState( - @ApiParam( - name = "uuid", - value = "UUID of the ApplicationDTO Release", - required = true) - @PathParam("uuid") String applicationUuid, - @ApiParam( - name = "LifecycleChanger", - value = "Lifecycle Changer which contains the action and the reason for the lifecycle change.", - required = true) - @Valid LifecycleChanger lifecycleChanger - ); - - @GET - @Path("/lifecycle-config") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get application management UI configuration", - notes = "This will get all UI configuration of application management", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got Lifecycle Config.", - response = ApplicationList.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the lifecycle config.", - response = ErrorResponse.class) - }) - Response getLifecycleConfig(); - - @GET - @Path("/tags") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get registered application tags", - notes = "This will get registered application tags", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got Application tags.", - response = ApplicationList.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting application tags.", - response = ErrorResponse.class) - }) - Response getTags(); - - @DELETE - @Path("/{appId}/tags/{tagName}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get registered application tags", - notes = "This will get registered application tags", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete Application tags.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Given tag is not an associated tag for the given application."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting application tags.", - response = ErrorResponse.class) - }) - Response deleteApplicationTag( - @ApiParam( - name = "appId", - value = "ID of the Application", - required = true) - @PathParam("appId") int applicationId, - @ApiParam( - name = "tagName", - value = "Tag Name", - required = true) - @PathParam("tagName") String tagName - ); - - @DELETE - @Path("/tags/{tagName}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Delete application tag", - notes = "This will delete application tag", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete registered tag.", - response = ApplicationList.class), - @ApiResponse( - code = 403, - message = "Don't have permission to delete the application tag."), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Couldn't found a tag for the given tag name.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting registered tag.", - response = ErrorResponse.class) - }) - Response deleteUnusedTag( - @ApiParam( - name = "tagName", - value = "Tag Name", - required = true) - @PathParam("tagName") String tagName - ); - - @PUT - @Path("/tags/rename") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "update an application tag", - notes = "This will update application tag", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully update the registered tag.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Request contains unaccepted values for query parameters."), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Couldn't found a tag for the given tag name.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while updating registered tag.", - response = ErrorResponse.class) - }) - Response modifyTagName( - @ApiParam( - name = "oldTagName", - value = "Existing Tag Name", - required = true) - @QueryParam("from") String oldTagName, - @ApiParam( - name = "newTagName", - value = "Modifying Tag Name", - required = true) - @QueryParam("to") String newTagName - ); - - @POST - @Path("/tags") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add new tags.", - notes = "This will add new tags for the system", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully add tags.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Tag adding request contains unacceptable payload."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while adding new tags.", - response = ErrorResponse.class) - }) - Response addTags( - @ApiParam( - name = "oldTagName", - value = "Existing Tag Name", - required = true) - List tagNames - ); - - @POST - @Path("/{appId}/tags") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add new application tags", - notes = "This will add new application tags", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully add application tags.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Application tag adding request contains unacceptable payload."), - @ApiResponse( - code = 404, - message = "NOT FOUND. \n Couldn't found an application for the given application id.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while adding new application tags.", - response = ErrorResponse.class) - }) - Response addApplicationTags( - @ApiParam( - name = "appId", - value = "Existing Tag Name", - required = true) - @PathParam("appId") int appId, - @ApiParam( - name = "appId", - value = "application Id", - required = true) - List tagNames - ); - - @GET - @Path("/categories") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get registered application categories", - notes = "This will get registered application categories.", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got application categories.", - response = ApplicationList.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting application categories.", - response = ErrorResponse.class) - }) - Response getCategories(); - -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java deleted file mode 100644 index 2ec172dbd1..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * 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.application.mgt.publisher.api; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; -import io.swagger.annotations.*; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Service Provider Application Management Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "SPApplicationService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-publisher/v1.0/identity-server-applications"), - }) - } - ), - tags = { - @Tag(name = "application_management, device_management", description = "App publisher related APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "view a service provider applications", - description = "Get service provider application details", - key = "perm:app:publisher:service-provider:view", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/service-provider/application/view"} - ), - @Scope( - name = "Create new identity server", - description = "Connect to new identity server", - key = "perm:app:publisher:service-provider:connect", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/service-provider/application/connect"} - ), - @Scope( - name = "Create a service provider application", - description = "Create an application and attach (map) to service provider", - key = "perm:app:publisher:service-provider:create", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/service-provider/application/create"} - ), - @Scope( - name = "Attach a service provider application", - description = "Map an application to service provider", - key = "perm:app:publisher:service-provider:attach", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/service-provider/application/attach"} - ), - @Scope( - name = "Detach a service provider application", - description = "Remove an application from service provider", - key = "perm:app:publisher:service-provider:detach", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/publisher/service-provider/application/detach"} - ) - } -) -@Path("/identity-server-applications") -@Api(value = "SPApplication Management") -@Produces(MediaType.APPLICATION_JSON) -public interface SPApplicationService { - - String SCOPE = "scope"; - - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("/identity-servers/identity-service-providers") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get available identity service providers", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:view") - }) - } - ) - Response getIdentityServiceProviders(); - - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("/identity-servers") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get all identity servers", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:view") - }) - } - ) - Response getIdentityServers(); - - @Path("/identity-servers/{id}") - @DELETE - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "get identity server by id", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:connect") - }) - } - ) - Response deleteIdentityServer(@PathParam("id") int id); - - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("/identity-servers/{id}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get identity server by id", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:view") - }) - } - ) - Response getIdentityServer(@PathParam("id") int id); - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Path("/identity-servers") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "create new identity server", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:connect") - }) - } - ) - Response createIdentityServer(IdentityServerDTO identityServerDTO); - - @PUT - @Produces(MediaType.APPLICATION_JSON) - @Path("/identity-servers/{id}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "edit existing identity server", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:connect") - }) - } - ) - Response updateIdentityServer(IdentityServerDTO identityServerDTO, @PathParam("id") int id); - - @GET - @Path("/identity-servers/identity-server-name") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Check if identity server name is already exists", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:view") - }) - } - ) - Response isIdentityServerNameExists( - @QueryParam("identityServerName") String identityServerName); - - @GET - @Path("/identity-servers/identity-server-url") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Check if identity server url is already exists", - tags = "Identity Server Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:view") - }) - } - ) - Response isIdentityServerUrlExists( - @QueryParam("identityServerUrl") String identityServerUrl); - - /** - * This method is used to register an APIM application for tenant domain. - */ - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("{identity-server-id}/service-providers") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get service providers by identity server id", - notes = "This will get service providers with the existing applications", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:view") - }) - } - ) - Response getServiceProviders(@QueryParam("limit") Integer limit, @QueryParam("offset") Integer offset, - @PathParam("identity-server-id") int identityServerId); - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/attach") - @POST - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "map application to service provider", - notes = "This will map a given list application ids with the given service provider id", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:attach") - }) - } - ) - Response attachApps(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, List appIds); - - /** - * This method is used to register an APIM application for tenant domain. - */ - @Path("/{identity-server-id}/service-provider/{service-provider-id}/detach") - @POST - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Remove mapping with service provider of the given application ids", - notes = "This will remove applications from service provider", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:detach") - }) - } - ) - Response detachApps(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, List appIds); - - /** - * This method is used to register an APIM application for tenant domain. - */ - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/ent-app") - @POST - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create enterprise application and attach to service provider", - notes = "This will get create an enterprise application and map with service provider", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:create") - }) - }, - nickname = "createEntAppForSP" - ) - Response createEntApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished); - - /** - * This method is used to register an APIM application for tenant domain. - */ - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/public-app") - @POST - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create public application and attach to service provider", - notes = "This will get create a public application and map with service provider", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:create") - }) - }, - nickname = "createPubAppForSP" - ) - Response createPubApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished); - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app") - @POST - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create web application and attach to service provider", - notes = "This will get create a web application and map with service provider", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:create") - }) - }, - nickname = "createWebAppForSP" - ) - Response createWebApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished); - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app") - @POST - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Create custom application and attach to service provider", - notes = "This will get create an custom application and map with service provider", - tags = "Service Provider Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:service-provider:create") - }) - } - ) - Response createCustomApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app, - @ApiParam( - name = "isPublished", - value = "Published state of the application" - ) - @QueryParam("is-published") boolean isPublished); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java deleted file mode 100644 index 91e17bef71..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * 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.application.mgt.publisher.api.admin; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.swagger.annotations.*; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * APIs to handle application management related tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "ApplicationDTO Management Publisher Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ApplicationManagementPublisherAdminService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-publisher/v1.0/admin/applications"), - }) - } - ), - tags = { - @Tag(name = "application_management, device_management", description = "App publisher related Admin APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "Delete Application Release", - description = "Delete Application Release", - key = "perm:admin:app:publisher:update", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/app-mgt/publisher/admin/application/update"} - ) - } -) -@Path("/admin/applications") -@Api(value = "ApplicationDTO Management") -@Produces(MediaType.APPLICATION_JSON) -public interface ApplicationManagementPublisherAdminAPI { - - String SCOPE = "scope"; - - @DELETE - @Path("/release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Delete application release.", - notes = "This will delete application release for given UUID", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete application release.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an application release for UUID" + - "query."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting application release.", - response = ErrorResponse.class) - }) Response deleteApplicationRelease( - @ApiParam( - name = "uuid", - value = "application release UUID", - required = true) - @PathParam("uuid") String releaseUuid); - - @DELETE - @Path("/{appId}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Delete application release.", - notes = "This will delete application release for given UUID", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete application release.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an application release for UUID" + - "query."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting application release.", - response = ErrorResponse.class) - }) Response deleteApplication( - @ApiParam( - name = "appId", - value = "application ID", - required = true) - @PathParam("appId") int applicatioId); - - @DELETE - @Path("/tags") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Delete application tag", - notes = "This will delete application tag", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete registered tag.", - response = ApplicationList.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting registered tag.", - response = ErrorResponse.class) - }) - Response deleteTag( - @ApiParam( - name = "tag-name", - value = "Tag Name", - required = true) - @QueryParam("tag-name") String tagName - ); - - @POST - @Path("/categories") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add new application categories.", - notes = "This will add new application categories", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete registered tag.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Category list is either empty or null"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting registered tag.", - response = ErrorResponse.class) - }) - Response addCategories( - @ApiParam( - name = "tagName", - value = "Tag Name", - required = true) List categorynames - ); - - @PUT - @Path("/categories/rename") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Update application category", - notes = "This will update application category.", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully delete registered category.", - response = ApplicationList.class), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an category for given category name.."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting registered category.", - response = ErrorResponse.class) - }) - Response renameCategory( - @ApiParam( - name = "oldCategoryName", - value = "Existing Category Name", - required = true) - @QueryParam("from") String oldCategoryName, - @ApiParam( - name = "newCategoryName", - value = "Modifying Category Name", - required = true) - @QueryParam("to") String newCategoryName - ); - - @DELETE - @Path("/categories") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Delete application category", - notes = "This will delete application category.", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully deleted registered category.", - response = ApplicationList.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting registered category.", - response = ErrorResponse.class) - }) - Response deleteCategory( - @ApiParam( - name = "category-name", - value = "Category Name", - required = true) - @QueryParam("category-name") String categoryName - ); - - @PUT - @Consumes("application/json") - @Path("/retire/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Retire the application with the given app Id", - notes = "This will retire the application with the given app Id", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:publisher:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully deleted the application identified by app Id.", - response = List.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting the application.", - response = ErrorResponse.class), - @ApiResponse( - code = 403, - message = "Don't have permission to delete the application"), - @ApiResponse( - code = 404, - message = "Application not found"), - }) - Response retireApplication( - @ApiParam( - name = "appId", - value = "Application Id", - required = true) - @PathParam("appId") int applicationId - ); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java deleted file mode 100644 index e984ea9f5e..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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.application.mgt.publisher.api.admin; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; -import io.swagger.annotations.*; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** -* APIs to handle admin review management related tasks in publisher. -*/ - -@SwaggerDefinition( -info = @Info( - version = "1.0.0", - title = "Publisher Review Management Admin Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "PublisherReviewManagementAdminService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-publisher/v1.0/admin/reviews"), - }) - } -), -tags = { - @Tag(name = "review_management", description = "Publisher Review Management related Admin APIs") -} -) -@Scopes( -scopes = { - @Scope( - name = "Update a Review", - description = "Update a Review of application.", - key = "perm:admin:app:review:update", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/app-mgt/publisher/admin/review/update"} - ), - @Scope( - name = "Get Review Details", - description = "Get review details of application.", - key = "perm:admin:app:review:view", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/app-mgt/publisher/admin/review/view"} - ) -} -) - -@Path("/admin/reviews") -@Api(value = "Publisher Review Management Admin API") -@Produces(MediaType.APPLICATION_JSON) -public interface ReviewManagementPublisherAdminAPI { -String SCOPE = "scope"; - - @GET - @Path("/release/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app release reviews", - notes = "Get all app release reviews", - tags = "Review Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved app release reviews.", - response = PaginationResult.class, - responseContainer = "PaginationResult"), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release for requested UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the review list.", - response = ErrorResponse.class) - }) - - Response getAllReleaseReviews( - @ApiParam( - name = "uuid", - value = "uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name = "offset", - value = "Starting review number.", - defaultValue = "0") - @QueryParam("offSet") int offSet, - @ApiParam( - name = "limit", - value = "Limit of paginated reviews", - defaultValue = "20") - @QueryParam("limit") int limit); - - @GET - @Path("/{uuid}/release-rating") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get ratings", - notes = "Get all ratings", - tags = "Review Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved ratings.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application release found for application release UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting ratings", - response = ErrorResponse.class) - }) - - Response getAppReleaseRating( - @ApiParam( - name = "uuid", - value = "uuid of the application release", - required = true) - @PathParam("uuid") String uuid); - - @GET - @Path("/{uuid}/app-rating") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app ratings", - notes = "Get all app ratings", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved ratings.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting ratings", - response = ErrorResponse.class) - }) - - Response getAppRating( - @ApiParam( - name = "uuid", - value = "uuid of the application release", - required = true) - @PathParam("uuid") - String uuid); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java deleted file mode 100644 index 606e66fd0a..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java +++ /dev/null @@ -1,895 +0,0 @@ -/* - * 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.application.mgt.publisher.api.impl; - -import io.entgra.device.mgt.core.application.mgt.common.*; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; -import io.entgra.device.mgt.core.application.mgt.common.response.Application; -import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; -import io.entgra.device.mgt.core.application.mgt.common.response.Category; -import io.entgra.device.mgt.core.application.mgt.common.response.Tag; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.AppmDataHandler; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; -import io.entgra.device.mgt.core.application.mgt.publisher.api.ApplicationManagementPublisherAPI; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Implementation of Application Management related APIs. - */ -@Produces({"application/json"}) -@Path("/applications") -public class ApplicationManagementPublisherAPIImpl implements ApplicationManagementPublisherAPI { - - private static final Log log = LogFactory.getLog(ApplicationManagementPublisherAPIImpl.class); - - @POST - @Override - @Consumes("application/json") - public Response getApplications( - @Valid Filter filter) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - if (filter == null) { - String msg = "Request Payload is null"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - ApplicationList applications = applicationManager.getApplications(filter); - return Response.status(Response.Status.OK).entity(applications).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (UnexpectedServerErrorException e) { - String msg = "Error occurred when getting supported device types by Entgra IoTS"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting the application list for publisher "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Consumes("application/json") - @Path("/{appId}") - public Response getApplication( - @PathParam("appId") int appId, - @QueryParam("state") String state) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - Application application = applicationManager.getApplicationById(appId, state); - if (application == null){ - String msg = "Could not found an active application which has Id: " + appId; - log.error(msg); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } - return Response.status(Response.Status.OK).entity(application).build(); - } catch (NotFoundException e) { - String msg = "ApplicationDTO with application id: " + appId + " not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch(ForbiddenException e){ - String msg = "You don't have permission to access the application. application id: " + appId; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } - catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application with the id " + appId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Consumes("application/json") - @Path("/release/{uuid}") - public Response getApplicationByUUID( - @PathParam("uuid") String uuid) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - Application application = applicationManager.getApplicationByUuid(uuid); - if (application == null){ - String msg = "Application release is in the end state of the application lifecycle flow."; - log.error(msg); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } - return Response.status(Response.Status.OK).entity(application).build(); - } catch (NotFoundException e) { - String msg = "Application Release with UUID: " + uuid + " is not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch(ForbiddenException e){ - String msg = "You don't have permission to access the application release. application release UUID: : " - + uuid; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } - catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/ent-app") - public Response createEntApp( - ApplicationWrapper applicationWrapper, @QueryParam("is-published") boolean isPublished) { - try { - return createApplication(applicationWrapper, isPublished); - } catch (BadRequestException e) { - String msg = "Found incompatible payload with ent. app creating request. Please try with valid request payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating the ent. application"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = "Couldn't find the required artifacts to create new ent. application with the request"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/web-app") - public Response createWebApp( - WebAppWrapper webAppWrapper, @QueryParam("is-published") boolean isPublished) { - try { - return createApplication(webAppWrapper, isPublished); - } catch (BadRequestException e) { - String msg = "Found incompatible payload with web app creating request. Please try with valid request payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating the web application"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = "Couldn't find the required artifacts to create new web application with the request"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/public-app") - public Response createPubApp( - PublicAppWrapper publicAppWrapper, @QueryParam("is-published") boolean isPublished) { - try { - return createApplication(publicAppWrapper, isPublished); - } catch (BadRequestException e) { - String msg = "Found incompatible payload with pub app creating request. Please try with valid request payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating the public app."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = "Couldn't find the required artifacts to create new public application with the request"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/custom-app") - public Response createCustomApp( - CustomAppWrapper customAppWrapper, @QueryParam("is-published") boolean isPublished) { - try { - return createApplication(customAppWrapper, isPublished); - } catch (BadRequestException e) { - String msg = "Found incompatible payload with custom app creating request. Please try with valid request payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating a custom application"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = "Couldn't find the required artifacts to create new custom application with the request"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{deviceType}/ent-app/{appId}") - public Response createEntAppRelease( - @PathParam("deviceType") String deviceTypeName, - @PathParam("appId") int appId, - EntAppReleaseWrapper entAppReleaseWrapper, - @QueryParam("is-published") boolean isPublished) { - try { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.validateEntAppReleaseCreatingRequest(entAppReleaseWrapper, deviceTypeName); - ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper, isPublished); - return Response.status(Response.Status.CREATED).entity(release).build(); - } catch (RequestValidatingException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (BadRequestException e){ - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating application release for the application with the id " + appId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{deviceType}/public-app/{appId}") - @Override - public Response createPubAppRelease( - @PathParam("deviceType") String deviceTypeName, - @PathParam("appId") int appId, - PublicAppReleaseWrapper publicAppReleaseWrapper, @QueryParam("is-published") boolean isPublished) { - - try { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.validatePublicAppReleaseCreatingRequest(publicAppReleaseWrapper, deviceTypeName); - ApplicationRelease applicationRelease = applicationManager.createPubAppRelease(appId, publicAppReleaseWrapper, isPublished); - return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating application release for the application with the id " + appId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ResourceManagementException e) { - String msg = "Error occurred while uploading application release artifacts"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/web-app/{appId}") - @Override - public Response createWebAppRelease( - @PathParam("appId") int appId, - WebAppReleaseWrapper webAppReleaseWrapper, @QueryParam("is-published") boolean isPublished) { - try { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper); - ApplicationRelease applicationRelease= applicationManager.createWebAppRelease(appId, webAppReleaseWrapper, isPublished); - return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ResourceManagementException e) { - String msg = "Error occurred while uploading application release artifacts"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating application release for the application with the id " + appId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{deviceType}/custom-app/{appId}") - @Override - public Response createCustomAppRelease( - @PathParam("deviceType") String deviceTypeName, - @PathParam("appId") int appId, - CustomAppReleaseWrapper customAppReleaseWrapper, @QueryParam("is-published") boolean isPublished) { - try { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName); - ApplicationRelease release = applicationManager.createCustomAppRelease(appId, customAppReleaseWrapper, isPublished); - return Response.status(Response.Status.CREATED).entity(release).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ResourceManagementException e) { - String msg = "Error occurred while uploading application release artifacts"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while creating application release for the application with the id " + appId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @GET - @Path("/device-type/{deviceType}/app-name") - public Response isExistingApplication( - @PathParam("deviceType") String deviceType, - @QueryParam("appName") String appName){ - try { - if (appName == null) { - String msg = "Invalid app name, appName query param cannot be empty/null."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - if (appName.length() > 20) { - String msg = "Invalid app name, maximum length of the application name should be 20 characters."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - if (applicationManager.isExistingAppName(appName, deviceType)) { - String msg = "Invalid app name, app name already exists."; - log.error(msg); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } - return Response.status(Response.Status.OK).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Internal Error occurred while checking the application existence."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/image-artifacts/{uuid}") - public Response updateApplicationImageArtifacts( - @PathParam("uuid") String applicationReleaseUuid, - Base64File iconFile, - Base64File bannerFile, - List screenshots) { - try { - ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(iconFile, screenshots, - null, bannerFile); - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.updateApplicationImageArtifact(applicationReleaseUuid, - artifact); - return Response.status(Response.Status.OK) - .entity("Successfully uploaded artifacts for the application " + applicationReleaseUuid).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found an application release which has application release UUID " - + applicationReleaseUuid + ". Hence please verify the application release UUID again and execute " - + "the operation"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while updating the application image artifacts for application release uuid: " - + applicationReleaseUuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Path("/ent-app-artifact/{deviceType}/{uuid}") - public Response updateApplicationArtifact( - @PathParam("deviceType") String deviceType, - @PathParam("uuid") String applicationReleaseUuid, - Base64File binaryFile) { - - try { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.validateBinaryArtifact(binaryFile); - applicationManager.updateApplicationArtifact(deviceType, applicationReleaseUuid, - ApplicationManagementUtil.constructApplicationArtifact(null, null, - binaryFile, null)); - return Response.status(Response.Status.OK) - .entity("Successfully uploaded artifacts for the application release. UUID is " - + applicationReleaseUuid).build(); - } catch (RequestValidatingException e) { - String msg = - "Couldn't find the binary file with the request. Hence invoke the API with updating application" - + " artifact"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application which has application release UUID: " + applicationReleaseUuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Found an invalid device type: " + deviceType + " with the request"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while updating the image artifacts of the application with the uuid " - + applicationReleaseUuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @PUT - @Consumes("application/json") - @Path("/{appId}") - public Response updateApplication( - @PathParam("appId") int applicationId, - @Valid ApplicationUpdateWrapper applicationUpdateWrapper) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - Application application = applicationManager.updateApplication(applicationId, applicationUpdateWrapper); - return Response.status(Response.Status.OK).entity(application).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application for application id: " + applicationId; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Internal Error occurred while modifying the application."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Path("/ent-app-release/{uuid}") - public Response updateEntAppRelease( - @PathParam("uuid") String applicationUUID, - EntAppReleaseWrapper entAppReleaseWrapper) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(entAppReleaseWrapper.getIcon(), - entAppReleaseWrapper.getScreenshots(), entAppReleaseWrapper.getBinaryFile(), entAppReleaseWrapper.getBanner()); - ApplicationRelease applicationRelease = applicationManager - .updateEntAppRelease(applicationUUID, entAppReleaseWrapper, artifact); - if (applicationRelease == null) { - String msg ="Ent app release updating is failed. Please contact the administrator. Application release " - + "UUID: " + applicationUUID; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - String oldPackageName = applicationManager.getApplicationByUuid(applicationUUID).getPackageName(); - applicationManager.updateAppIconInfo(applicationRelease, oldPackageName); - return Response.status(Response.Status.OK).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = - "Couldn't found an ent app or ent app release for application release UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to update the ent app release which has UUID " - + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while updating the ent app release which has UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Path("/public-app-release/{uuid}") - public Response updatePubAppRelease( - @PathParam("uuid") String applicationUUID, - PublicAppReleaseWrapper publicAppReleaseWrapper) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(publicAppReleaseWrapper.getIcon(), - publicAppReleaseWrapper.getScreenshots(), null, publicAppReleaseWrapper.getBanner()); - ApplicationRelease applicationRelease = applicationManager - .updatePubAppRelease(applicationUUID, publicAppReleaseWrapper, artifact); - if (applicationRelease == null) { - String msg ="Public app release updating is failed. Please contact the administrator. " - + "Application release UUID: " + applicationUUID + ", Supported device type:"; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - String oldPackageName = applicationManager.getApplicationByUuid(applicationUUID).getPackageName(); - applicationManager.updateAppIconInfo(applicationRelease, oldPackageName); - return Response.status(Response.Status.OK).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found public app or public app release for application release UUID " - + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to update the public app release which has UUID " - + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while updating the public app release which has UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Path("/web-app-release/{uuid}") - public Response updateWebAppRelease( - @PathParam("uuid") String applicationUUID, - WebAppReleaseWrapper webAppReleaseWrapper) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(webAppReleaseWrapper.getIcon(), - webAppReleaseWrapper.getScreenshots(), null, webAppReleaseWrapper.getBanner()); - ApplicationRelease applicationRelease = applicationManager - .updateWebAppRelease(applicationUUID, webAppReleaseWrapper, artifact); - if (applicationRelease == null) { - String msg ="web app release updating is failed. Please contact the administrator. Application " - + "release UUID: " + applicationUUID; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - return Response.status(Response.Status.OK).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found web app or web app release for application release UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to update the web app release which has UUID " - + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while updating the web app release which has UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Path("/custom-app-release/{uuid}") - public Response updateCustomAppRelease( - @PathParam("uuid") String applicationUUID, - CustomAppReleaseWrapper customAppReleaseWrapper) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(customAppReleaseWrapper.getIcon(), - customAppReleaseWrapper.getScreenshots(), customAppReleaseWrapper.getBinaryFile(), customAppReleaseWrapper.getBanner()); - ApplicationRelease applicationRelease = applicationManager - .updateCustomAppRelease(applicationUUID, customAppReleaseWrapper, artifact); - if (applicationRelease == null) { - String msg ="Custom app release updating is failed. Please contact the administrator. Application " - + "release UUID: " + applicationUUID; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - return Response.status(Response.Status.OK).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = - "Couldn't found an ent app or ent app release for application release UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to update the ent app release which has UUID " - + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while updating the ent app release which has UUID " + applicationUUID; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Path("/life-cycle/state-changes/{uuid}") - public Response getLifecycleStates( - @PathParam("uuid") String releaseUuid) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - List lifecycleStates = applicationManager.getLifecycleStateChangeFlow(releaseUuid); - return Response.status(Response.Status.OK).entity(lifecycleStates).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + releaseUuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting lifecycle states for application release UUID: " + releaseUuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - } - - @POST - @Path("/life-cycle/{uuid}") - public Response addLifecycleState( - @PathParam("uuid") String applicationUuid, - @Valid LifecycleChanger lifecycleChanger) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - ApplicationRelease applicationRelease = applicationManager - .changeLifecycleState(applicationUuid, lifecycleChanger); - return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).build(); - } catch (ForbiddenException e) { - String msg = "You are trying to move the application release into incompatible state for application " - + "which has application ID: " + applicationUuid; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).build(); - } catch (NotFoundException e) { - String msg = "Could,t find application release for application release uuid: " + applicationUuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while adding lifecycle state."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - } - - @GET - @Override - @Consumes("application/json") - @Path("/lifecycle-config") - public Response getLifecycleConfig() { - AppmDataHandler dataHandler = APIUtil.getDataHandler(); - try { - return Response.status(Response.Status.OK).entity(dataHandler.getLifecycleConfiguration()).build(); - } catch (LifecycleManagementException e) { - String msg = "Error Occurred while accessing lifecycle manager."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Override - @Consumes("application/json") - @Path("/tags") - public Response getTags() { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - List tags = applicationManager.getRegisteredTags(); - return Response.status(Response.Status.OK).entity(tags).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while getting registered tags."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @DELETE - @Override - @Consumes(MediaType.WILDCARD) - @Path("/{appId}/tags/{tagName}") - public Response deleteApplicationTag( - @PathParam("appId") int appId, - @PathParam("tagName") String tagName) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.deleteApplicationTag(appId, tagName); - String msg = "Tag " + tagName + " is deleted successfully."; - return Response.status(Response.Status.OK).entity(msg).build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while deleting registered tag."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @DELETE - @Override - @Consumes(MediaType.WILDCARD) - @Path("/tags/{tagName}") - public Response deleteUnusedTag( - @PathParam("tagName") String tagName) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.deleteUnusedTag(tagName); - String msg = "Tag " + tagName + " is deleted successfully."; - return Response.status(Response.Status.OK).entity(msg).build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while deleting unused tag."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @PUT - @Override - @Consumes("application/json") - @Path("/tags/rename") - public Response modifyTagName( - @QueryParam("from") String oldTagName, - @QueryParam("to") String newTagName) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.updateTag(oldTagName, newTagName); - String msg = "Tag " + oldTagName + " is updated to " + newTagName + " successfully."; - return Response.status(Response.Status.OK).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while updating registered tag."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Override - @Consumes("application/json") - @Path("/tags") - public Response addTags( - List tagNames) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - List tags = applicationManager.addTags(tagNames); - return Response.status(Response.Status.OK).entity(tags).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while adding new tag."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Override - @Consumes("application/json") - @Path("/{appId}/tags") - public Response addApplicationTags( - @PathParam("appId") int appId, - List tagNames) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - List applicationTags = applicationManager.addApplicationTags(appId, tagNames); - return Response.status(Response.Status.OK).entity(applicationTags).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while adding new tags for application which has application ID: " + appId + "."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Override - @Consumes("application/json") - @Path("/categories") - public Response getCategories() { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - List categories = applicationManager.getRegisteredCategories(); - return Response.status(Response.Status.OK).entity(categories).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while getting registered categories."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - public Response createApplication(T appWrapper, boolean isPublished) throws ApplicationManagementException, RequestValidatingException { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - applicationManager.validateAppCreatingRequest(appWrapper); - Application application = applicationManager.createApplication(appWrapper, isPublished); - if (application != null) { - return Response.status(Response.Status.CREATED).entity(application).build(); - } else { - String msg = "Application creation is failed"; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java deleted file mode 100644 index a1f127080c..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * 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.application.mgt.publisher.api.impl; - -import io.entgra.device.mgt.core.application.mgt.common.IdentityServerResponse; -import io.entgra.device.mgt.core.application.mgt.common.SPApplicationListResponse; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServiceProviderDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; -import io.entgra.device.mgt.core.application.mgt.common.response.Application; -import io.entgra.device.mgt.core.application.mgt.common.services.SPApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.publisher.api.SPApplicationService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -@Produces(MediaType.APPLICATION_JSON) -@Path("/identity-server-applications") -public class SPApplicationServiceImpl implements SPApplicationService { - - private static final Log log = LogFactory.getLog(SPApplicationServiceImpl.class); - - @Path("/identity-servers/identity-service-providers") - @GET - @Override - public Response getIdentityServiceProviders() { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - try { - List identityServiceProviders = spAppManager.getIdentityServiceProviders(); - return Response.status(Response.Status.OK).entity(identityServiceProviders).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting identity service providers"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Path("/identity-servers") - @GET - @Override - public Response getIdentityServers() { - try { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - List identityServers = spAppManager.getIdentityServers(); - return Response.status(Response.Status.OK).entity(identityServers).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @Path("/identity-servers/{id}") - @DELETE - @Override - public Response deleteIdentityServer(@PathParam("id") int id) { - try { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - spAppManager.deleteIdentityServer(id); - return Response.status(Response.Status.OK).entity("Successfully deleted identity server").build(); - } catch (NotFoundException e) { - String msg = "Identity server with the id " + id + " does not exist."; - log.error(msg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @Path("/identity-servers/{id}") - @GET - @Override - public Response getIdentityServer(@PathParam("id") int id) { - try { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - IdentityServerResponse identityServer = spAppManager.getIdentityServerResponse(id); - return Response.status(Response.Status.OK).entity(identityServer).build(); - } catch (NotFoundException e) { - String msg = "Identity server with the id " + id + " does not exist."; - log.error(msg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @Path("/identity-servers/{id}") - @PUT - @Override - public Response updateIdentityServer(IdentityServerDTO identityServerDTO, @PathParam("id") int id) { - try { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - IdentityServerResponse identityServerResponse = spAppManager.updateIdentityServer(identityServerDTO, id); - return Response.status(Response.Status.OK).entity(identityServerResponse).build(); - } catch (NotFoundException e) { - String msg = "Identity server with the id " + id + " does not exist."; - log.error(msg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (BadRequestException e) { - String errMsg = e.getMessage(); - log.error(errMsg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - - @Path("/identity-servers") - @POST - @Override - public Response createIdentityServer(IdentityServerDTO identityServerDTO) { - try { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - IdentityServerResponse identityServer = spAppManager.createIdentityServer(identityServerDTO); - return Response.status(Response.Status.CREATED).entity(identityServer).build(); - } catch (BadRequestException e) { - String errMsg = e.getMessage(); - log.error(errMsg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @GET - @Path("/identity-servers/identity-server-name") - @Override - public Response isIdentityServerNameExists( - @QueryParam("identityServerName") String identityServerName) { - try { - if (identityServerName == null) { - String msg = "Invalid identity server name, identityServerName query param cannot be empty/null."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - if (spAppManager.isIdentityServerNameExist(identityServerName)) { - return Response.status(Response.Status.CONFLICT).build(); - } - return Response.status(Response.Status.OK).build(); - } catch (BadRequestException e) { - String errMsg = "Identity server request payload is invalid"; - log.error(errMsg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @GET - @Path("/identity-servers/identity-server-url") - @Override - public Response isIdentityServerUrlExists( - @QueryParam("identityServerUrl") String identityServerUrl) { - try { - if (identityServerUrl == null) { - String msg = "Invalid identity server url, identityServerName query param cannot be empty/null."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - if (spAppManager.isIdentityServerUrlExist(identityServerUrl)) { - return Response.status(Response.Status.CONFLICT).build(); - } - return Response.status(Response.Status.OK).build(); - } catch (BadRequestException e) { - String errMsg = "Identity server request payload is invalid"; - log.error(errMsg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @Path("/{identity-server-id}/service-providers") - @GET - @Override - public Response getServiceProviders(@DefaultValue("30") @QueryParam("limit") Integer limit,@DefaultValue("0") @QueryParam("offset") Integer offset, - @PathParam("identity-server-id") int identityServerId) { - try { - SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); - SPApplicationListResponse applications = spAppManager.retrieveSPApplicationFromIdentityServer(identityServerId, limit, offset); - return Response.status(Response.Status.OK).entity(applications).build(); - } catch (NotFoundException e) { - String errMsg = "No Identity server exist with the id: " + identityServerId; - log.error(errMsg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); - } catch (ApplicationManagementException e) { - String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; - log.error(errMsg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); - } - } - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/attach") - @POST - @Override - public Response attachApps(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, List appIds) { - SPApplicationManager spApplicationManager = APIUtil.getSPApplicationManager(); - try { - spApplicationManager.validateAttachAppsRequest(identityServerId, serviceProviderId, appIds); - spApplicationManager.attachSPApplications(identityServerId, serviceProviderId, appIds); - } catch (NotFoundException e) { - String msg = "No identity server exist with the id " + identityServerId; - log.error(msg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid appIds provided"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while attaching apps to service provider with the id" + serviceProviderId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - return Response.status(Response.Status.OK).build(); - } - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/detach") - @POST - @Override - public Response detachApps(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, List appIds) { - SPApplicationManager spApplicationManager = APIUtil.getSPApplicationManager(); - try { - spApplicationManager.validateDetachAppsRequest(identityServerId, serviceProviderId, appIds); - spApplicationManager.detachSPApplications(identityServerId, serviceProviderId, appIds); - } catch (NotFoundException e) { - String msg = "No identity server exist with the id " + identityServerId; - log.error(msg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid appIds provided"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while attaching apps to service provider with the id" + serviceProviderId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - return Response.status(Response.Status.OK).build(); - } - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/ent-app") - @POST - @Override - public Response createEntApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app, - @QueryParam("is-published") boolean isPublished) { - return createSPApplication(identityServerId, serviceProviderId, app, isPublished); - } - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/public-app") - @POST - @Override - public Response createPubApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app, - @QueryParam("is-published") boolean isPublished) { - return createSPApplication(identityServerId, serviceProviderId, app, isPublished); - } - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app") - @POST - @Override - public Response createWebApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app, - @QueryParam("is-published") boolean isPublished) { - return createSPApplication(identityServerId, serviceProviderId, app, isPublished); - } - - @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app") - @POST - @Override - public Response createCustomApp(@PathParam("identity-server-id") int identityServerId, - @PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app, - @QueryParam("is-published") boolean isPublished) { - return createSPApplication(identityServerId, serviceProviderId, app, isPublished); - } - - /** - * Validates and creates service provider application - * - * @param identityServerId id of the identity server - * @param spUID uid of the service provider - * @param appWrapper application wrapper - * @param application wrapper class - * @return Response - */ - private Response createSPApplication(int identityServerId, String spUID, T appWrapper, boolean isPublished) { - try { - SPApplicationManager spApplicationManager = APIUtil.getSPApplicationManager(); - Application createdApp = spApplicationManager.createSPApplication(appWrapper, identityServerId, spUID, isPublished); - return Response.status(Response.Status.CREATED).entity(createdApp).build(); - } catch (NotFoundException e) { - String msg = "No identity server exist with the id " + identityServerId; - log.error(msg, e); - // TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Found incompatible payload with create service provider app request."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (RequestValidatingException e) { - String msg = "Found invalid release payload with create service provider app request."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - catch (ApplicationManagementException e) { - String msg = "Error occurred while creating service provider app"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - -} \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java deleted file mode 100644 index c6df8587fb..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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.application.mgt.publisher.api.impl.admin; - -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.publisher.api.admin.ApplicationManagementPublisherAdminAPI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Implementation of Application Management related APIs. - */ -@Produces({"application/json"}) -@Path("/admin/applications") -public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationManagementPublisherAdminAPI { - - private static final Log log = LogFactory.getLog(ApplicationManagementPublisherAdminAPIImpl.class); - - @DELETE - @Consumes(MediaType.WILDCARD) - @Path("/release/{uuid}") - public Response deleteApplicationRelease( - @PathParam("uuid") String releaseUuid) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.deleteApplicationRelease(releaseUuid); - return Response.status(Response.Status.OK) - .entity("Successfully deleted the application release for uuid: " + releaseUuid).build(); - } catch (NotFoundException e) { - String msg = - "Couldn't found application release which is having application release UUID:" + releaseUuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to delete the application release which has UUID " - + releaseUuid; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while deleting the application release for application release UUID:: " - + releaseUuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @DELETE - @Consumes(MediaType.WILDCARD) - @Path("/{appId}") - public Response deleteApplication( - @PathParam("appId") int applicationId) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.deleteApplication(applicationId); - return Response.status(Response.Status.OK) - .entity("Successfully deleted the application which has ID: " + applicationId).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found application release which is having the ID:" + applicationId; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to delete the application which has ID: " + applicationId; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while deleting the application which has application ID:: " + applicationId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @DELETE - @Override - @Consumes(MediaType.WILDCARD) - @Path("/tags") - public Response deleteTag( - @QueryParam("tag-name") String tagName) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.deleteTag(tagName); - return Response.status(Response.Status.OK).entity("Tag " + tagName + " is deleted successfully.").build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while deleting registered tag."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Override - @Consumes("application/json") - @Path("/categories") - public Response addCategories( - List categoryNames) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - List categories = applicationManager.addCategories(categoryNames); - return Response.status(Response.Status.OK).entity(categories).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while adding new categories."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @PUT - @Override - @Consumes("application/json") - @Path("/categories/rename") - public Response renameCategory( - @QueryParam("from") String oldCategoryName, - @QueryParam("to") String newCategoryName) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.updateCategory(oldCategoryName, newCategoryName); - return Response.status(Response.Status.OK) - .entity("Category is updated from " + oldCategoryName + " to " + newCategoryName).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while rename registered category."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @DELETE - @Override - @Consumes(MediaType.WILDCARD) - @Path("/categories") - public Response deleteCategory( - @QueryParam("category-name") String categoryName) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.deleteCategory(categoryName); - return Response.status(Response.Status.OK).entity("Category " + categoryName + " is deleted successfully.") - .build(); - } catch (NotFoundException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error Occurred while deleting registered category."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @PUT - @Path("/retire/{appId}") - public Response retireApplication( - @PathParam("appId") int applicationId) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.retireApplication(applicationId); - return Response.status(Response.Status.OK) - .entity("Successfully retired the application which has application ID: " + applicationId).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found application for application id: " + applicationId + " to delete the " - + "application"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have require permission to delete the application which has ID " + applicationId; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while deleting the application: " + applicationId; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java deleted file mode 100644 index d35092e0dd..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.application.mgt.publisher.api.impl.admin; - -import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.application.mgt.common.Rating; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.publisher.api.admin.ReviewManagementPublisherAdminAPI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -/** - * Review Management related jax-rs APIs. - */ -@Path("/admin/reviews") -public class ReviewManagementPublisherAdminAPIImpl implements ReviewManagementPublisherAdminAPI { - - private static final Log log = LogFactory.getLog(ReviewManagementPublisherAdminAPIImpl.class); - - @Override - @GET - @Path("/release/{uuid}") - public Response getAllReleaseReviews( - @PathParam("uuid") String uuid, - @DefaultValue("0") @QueryParam("offset") int offSet, - @DefaultValue("20") @QueryParam("limit") int limit) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - PaginationRequest request = new PaginationRequest(offSet, limit); - try { - PaginationResult paginationResult = reviewManager.getAllReleaseReviews(request, uuid); - return Response.status(Response.Status.OK).entity(paginationResult).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while retrieving reviews for application UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while retrieving application release details for application UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @GET - @Path("/{uuid}/release-rating") - public Response getAppReleaseRating( - @PathParam("uuid") String uuid) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - Rating rating; - try { - rating = reviewManager.getAppReleaseRating(uuid); - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException | ApplicationManagementException e) { - String msg = "Error occured while getting review data for application release UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - return Response.status(Response.Status.OK).entity(rating).build(); - } - - @Override - @GET - @Path("/{uuid}/app-rating") - public Response getAppRating( - @PathParam("uuid") String uuid) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - Rating rating; - try { - rating = reviewManager.getAppRating(uuid); - } catch (NotFoundException e) { - String msg = "Couldn't found an application for application release UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException | ApplicationManagementException e) { - String msg = "Error occured while getting review data for application release UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - return Response.status(Response.Status.OK).entity(rating).build(); - } -} \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml deleted file mode 100644 index a5c121b7eb..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - Get Application Details - /device-mgt/application/get - /application-mgt/applications - GET - - - Create an Application - /device-mgt/application/create - /application-mgt/applications - POST - - - Update an Application - /device-mgt/application/update - /application-mgt/applications - PUT - - - Login to Application Management - /device-mgt/application-mgt/login - /application-mgt/applications - PUT - - - Delete an Application - device-mgt/application/delete - /application-mgt/applications/* - DELETE - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml deleted file mode 100644 index 705c89edc9..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - false - - - CXF3,Carbon - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml deleted file mode 100644 index d768a91afa..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/WEB-INF/web.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 630d1c7448..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - Application Management Webapp - - JAX-WS/JAX-RS Application Management Endpoint - JAX-WS/JAX-RS Servlet - CXFServlet - - org.apache.cxf.transport.servlet.CXFServlet - - - - swagger.security.filter - ApiAuthorizationFilterImpl - - 1 - - - CXFServlet - /* - - - 60 - - - doAuthentication - true - - - - - - ApplicationMgt-Admin - /* - - - CONFIDENTIAL - - - - - - managed-api-enabled - true - - - managed-api-owner - admin - - - isSharedWithAllTenants - true - - - - ApiOriginFilter - io.entgra.device.mgt.core.application.mgt.addons.ApiOriginFilter - - - - HttpHeaderSecurityFilter - org.apache.catalina.filters.HttpHeaderSecurityFilter - - hstsEnabled - false - - - - - ContentTypeBasedCachePreventionFilter - org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter - - patterns - text/html" ,application/json" ,text/plain - - - filterAction - enforce - - - httpHeaders - Cache-Control: no-store, no-cache, must-revalidate, private - - - - - HttpHeaderSecurityFilter - /* - - - - ContentTypeBasedCachePreventionFilter - /* - - - - ApiOriginFilter - /* - - - \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml deleted file mode 100644 index d5e113727a..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - application-mgt - io.entgra.device.mgt.core - 5.0.26-SNAPSHOT - ../pom.xml - - - 4.0.0 - io.entgra.device.mgt.core.application.mgt.store.api - war - Entgra - Application Management Store API - Entgra - Application Management Store API - https://entgra.io - - - - - maven-war-plugin - - WEB-INF/lib/*cxf*.jar - api#application-mgt-store#v1.0 - - - - - - - - deploy - - compile - - - org.apache.maven.plugins - maven-antrun-plugin - - - compile - - run - - - - - - - - - - - - - - - - - - client - - test - - - org.codehaus.mojo - exec-maven-plugin - - - test - - java - - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - junit - junit - test - - - org.codehaus.jackson - jackson-jaxrs - - - org.codehaus.jackson - jackson-core-asl - - - javax.ws.rs - jsr311-api - provided - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.ops4j.pax.logging - pax-logging-api - provided - - - org.json.wso2 - json - - - commons-codec.wso2 - commons-codec - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.core - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.common - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.addons - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.device.mgt.common - provided - - - io.swagger - swagger-annotations - - - io.swagger - swagger-core - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - io.swagger - swagger-jaxrs - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - javax.servlet - javax.servlet-api - provided - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.apimgt.annotations - provided - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - javax.ws.rs - javax.ws.rs-api - - - org.powermock - powermock-module-testng - test - - - org.powermock - powermock-api-mockito - test - - - \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/beans/SubscriptionStatusBean.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/beans/SubscriptionStatusBean.java deleted file mode 100644 index 88408780fe..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/beans/SubscriptionStatusBean.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.application.mgt.store.api.beans; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -/** - * This is used to map the status of subscription. - */ -@ApiModel( - value = "SubscriptionStatusBean", - description = "This class carries all information related map statuses of the subscription." -) -public class SubscriptionStatusBean { - @ApiModelProperty( - name = "sub id", - value = "Subscription Id.", - required = true - ) - private int subId; - - @ApiModelProperty( - name = "status", - value = "Status of the subscription.", - required = true - ) - private String status; - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public int getSubId() { - return subId; - } - - public void setSubId(int subId) { - this.subId = subId; - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java deleted file mode 100644 index ad46cd70a3..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * 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.application.mgt.store.api.services; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.swagger.annotations.*; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * APIs to handle application storage management related tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Application Storage Management Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ApplicationStorageManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/applications"), - }) - } - ), - tags = { - @Tag(name = "application_management, device_management", description = "ApplicationDTO Storage Management " - + "related APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "Get Application Details", - description = "Get application details", - key = "perm:app:store:view", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/store/application/view"} - ), - @Scope( - name = "Modify Application", - description = "Modify application state", - key = "perm:app:store:modify", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/store/application/modify"} - ) - } -) -@Path("/applications") -@Api(value = "Application Management", description = "This API carries all app store management related operations such" - + " as get all the applications etc.") -@Produces(MediaType.APPLICATION_JSON) -public interface ApplicationManagementAPI { - - String SCOPE = "scope"; - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/favourite/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "add application to favourites", - notes = "This will add application to favourites", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:store:modify") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully added application to favourites.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while adding the application to favourites.", - response = ErrorResponse.class) - }) - Response addAppToFavourite( - @ApiParam( - name = "appId", - value = "id of the application", - required = true) - @PathParam("appId") int appId); - - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/favourite/{appId}") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "remove application from favourites", - notes = "This will removing an application from favourites", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:store:modify") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully removed application from favourites.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while removing the application from favourites.", - response = ErrorResponse.class) - }) - Response removeAppFromFavourite( - @ApiParam( - name = "appId", - value = "id of the application", - required = true) - @PathParam("appId") int appId); - - @POST - @Path("/favourite") - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get all favourite applications", - notes = "This will get all favourite applications", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:store:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got application list.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Application retrieving request payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the application list.", - response = ErrorResponse.class) - }) - Response getFavouriteApplications( - @ApiParam( - name = "filter", - value = "Application filtering data", - required = true) - @Valid Filter filter); - - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get all applications", - notes = "This will get all applications", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:store:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got application list.", - response = ApplicationList.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n " + - "Application retrieving request payload contains unacceptable or vulnerable data"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the application list.", - response = ErrorResponse.class) - }) - Response getApplications( - @ApiParam( - name = "filter", - value = "Application filtering data", - required = true) - @Valid Filter filter - ); - - @GET - @Path("/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get the application of requesting application type", - notes = "This will get the application identified by the application type and name, if exists", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:store:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved relevant application.", - response = ApplicationDTO.class), - @ApiResponse( - code = 404, - message = "Application not found"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting relevant application.", - response = ErrorResponse.class) - }) - Response getApplication( - @ApiParam( - name = "uuid", - value = "Type of the application", - required = true) - @PathParam("uuid") String uuid - ); - - -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java deleted file mode 100644 index 685871f738..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * 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.application.mgt.store.api.services; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.application.mgt.common.response.Review; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ReviewWrapper; -import io.swagger.annotations.*; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** -* APIs to handle review management related tasks. -*/ - -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Review Management Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ReviewManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/reviews"), - }) - } - ), - tags = { - @Tag(name = "review_management", description = "Review Management related APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "Get Review Details", - description = "Get review details from application store.", - key = "perm:app:review:view", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/store/review/view"} - ), - @Scope( - name = "Update a Review", - description = "Update a Review from the application store.", - key = "perm:app:review:update", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/store/review/update"} - ), - } -) - -@Path("/reviews") -@Api(value = "Review Management API") -@Produces(MediaType.APPLICATION_JSON) -public interface ReviewManagementAPI { - String SCOPE = "scope"; - - @GET - @Path("/app/user/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app reviews", - notes = "Get all app reviews", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved app reviews.", - response = PaginationResult.class, - responseContainer = "PaginationResult"), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release associated with requested " - + "UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the review list.", - response = ErrorResponse.class) - }) - - Response getUserReviews( - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="offset", - value="Starting review number.", - defaultValue = "0") - @QueryParam("offSet") int offSet, - @ApiParam( - name="limit", - value = "Limit of paginated reviews", - defaultValue = "20") - @QueryParam("limit") int limit); - - @GET - @Path("/app/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app reviews", - notes = "Get all app reviews", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved app reviews.", - response = PaginationResult.class, - responseContainer = "PaginationResult"), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release associated with requested " - + "UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the review list.", - response = ErrorResponse.class) - }) - - Response getAllAppReviews( - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="offset", - value="Starting review number.", - defaultValue = "0") - @QueryParam("offSet") int offSet, - @ApiParam( - name="limit", - value = "Limit of paginated reviews", - defaultValue = "20") - @QueryParam("limit") int limit); - - @POST - @Path("/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add a review", - notes = "This will add a new review for application release.", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully add a reviewTmp.", - response = Review.class), - @ApiResponse( - code = 400, - message = - "Bad Request. \n Found invalid payload with the request."), - @ApiResponse( - code = 403, - message = "Don't have permission to add a review."), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release for requested UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred adding a reviewTmp.", - response = ErrorResponse.class) - }) - - Response addReview( - @ApiParam( - name = "reviewTmp", - value = "Review details", - required = true) ReviewWrapper reviewWrapper, - @ApiParam( - name="uuid", - value="uuid of the application release.", - required=true) - @PathParam("uuid") String uuid); - - @POST - @Path("/{uuid}/{parentReviewId}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add a reply comment", - notes = "This will add a reply comment for a comment or review.", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully add a reviewTmp.", - response = Review.class), - @ApiResponse( - code = 400, - message = - "Bad Request. \n Found invalid payload with the request."), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release for requested UUID."), - - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred adding a reviewTmp.", - response = ErrorResponse.class) - }) - - Response addReplyComment( - @ApiParam( - name = "review", - value = "Reply comment details", - required = true) ReviewWrapper reviewWrapper, - @ApiParam( - name="uuid", - value="uuid of the application release.", - required=true) - @PathParam("uuid") String uuid, - @ApiParam( - name="parentReviewId", - value="uuid of the application release.", - required=true) - @PathParam("parentReviewId") int parentReviewId); - - @PUT - @Path("/{uuid}/{reviewId}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Edit a reviewTmp", - notes = "This will edit the reviewTmp", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated reviewTmp.", - response = Review.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while updating the new reviewTmp.", - response = ErrorResponse.class) - }) - Response updateReview( - @ApiParam( - name = "reviewTmp", - value = "The reviewTmp that need to be updated.", - required = true) - @Valid ReviewWrapper updatingReview, - @ApiParam( - name="uuid", - value = "uuid of the application release", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="reviewId", - value = "reviewTmp id of the updating reviewTmp.", - required = true) - @PathParam("reviewId") int reviewId); - - @DELETE - @Path("/{uuid}/{reviewId}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Remove comment", - notes = "Remove comment", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") - }) - }, - nickname = "deleteReviewComment" - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully deleted the review"), - @ApiResponse( - code = 403, - message = "Don't have permission to delete the review."), - @ApiResponse( - code = 404, - message = "Not Found. \n No activity found with the given ID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting the review.", - response = ErrorResponse.class) - }) - - Response deleteReview( - @ApiParam( - name="uuid", - value="UUID of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="reviewId", - value="Id of the review.", - required = true) - @PathParam("reviewId") int reviewId); - - @GET - @Path("/{uuid}/app-rating") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app ratings", - notes = "Get all app ratings", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved ratings.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting ratings", - response = ErrorResponse.class) - }) - - Response getAppRating( - @ApiParam( - name = "uuid", - value = "uuid of the application release", - required = true) - @PathParam("uuid") - String uuid); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java deleted file mode 100644 index 0ff0e711c0..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java +++ /dev/null @@ -1,556 +0,0 @@ -/* - * 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.application.mgt.store.api.services; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.swagger.annotations.*; - -import javax.validation.Valid; -import javax.validation.constraints.Size; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * API to handle subscription management related tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Subscription Management Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "SubscriptionManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/subscription"), - }) - } - ), - tags = { - @Tag(name = "subscription_management, device_management", description = "Subscription Management " - + "related APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "Install an ApplicationDTO", - description = "Install an application", - key = "perm:app:subscription:install", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/store/subscription/install"} - ), - @Scope( - name = "Uninstall an Application", - description = "Uninstall an application", - key = "perm:app:subscription:uninstall", - roles = {"Internal/devicemgt-user"}, - permissions = {"/app-mgt/store/subscription/uninstall"} - ) - } -) -@Path("/subscription") -@Api(value = "Subscription Management") -@Produces(MediaType.APPLICATION_JSON) -public interface SubscriptionManagementAPI { - - String SCOPE = "scope"; - - @POST - @Path("/{uuid}/devices/{action}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Install an application for devices", - notes = "This will install an application to a given list of devices", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:install") - }) - } - ) - @ApiResponses( - value = { - - }) - Response performAppOperationForDevices( - @ApiParam( - name = "uuid", - value = "The application ID and list of devices/users/roles", - required = true - ) - @PathParam("uuid") String uuid, - @ApiParam( - name = "action", - value = "Performing action.", - required = true - ) - @PathParam("action") String action, - @ApiParam( - name = "deviceIdentifiers", - value = "The list of device identifiers", - required = true - ) - @Valid List deviceIdentifiers, - @ApiParam( - name = "timestamp", - value = "Timestamp of scheduled install/uninstall operation" - ) - @QueryParam("timestamp") long timestamp, - @ApiParam( - name = "block-uninstall", - value = "App removal status of the install operation" - ) - @QueryParam("block-uninstall") Boolean isUninstallBlocked - ); - - @POST - @Path("/{uuid}/{subType}/{action}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Install an application for subscription type.", - notes = "This will install an application to a given subscription type and this is bulk app installation.", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:install") - }) - } - ) - @ApiResponses( - value = { - - }) - Response performBulkAppOperation( - @ApiParam( - name = "uuid", - value = "The application release UUID", - required = true - ) - @PathParam("uuid") String uuid, - @ApiParam( - name = "subType", - value = "Subscription type of the app installing operation.", - required = true - ) - @PathParam("subType") String subType, - @ApiParam( - name = "action", - value = "Performing action.", - required = true - ) - @PathParam("action") String action, - @ApiParam( - name = "subscribers", - value = "Subscriber list of the application release.", - required = true - ) - @Valid List subscribers, - @ApiParam( - name = "timestamp", - value = "Timestamp of scheduled install/uninstall operation" - ) - @QueryParam("timestamp") long timestamp, - @ApiParam( - name = "block-uninstall", - value = "App removal status of the install operation" - ) - @QueryParam("block-uninstall") Boolean isUninstallBlocked, - @ApiParam( - name = "disable-operation-re-executing", - value = "Disable Operation re-executing" - ) - @QueryParam("disable-operation-re-executing") boolean isOperationReExecutingDisabled - ); - - @POST - @Path("/{uuid}/devices/ent-app-install/{action}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Install an application for devices via google enterprise app installing service", - notes = "This will install an application to a given list of devices", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:install") - }) - } - ) - @ApiResponses( - value = { - - }) - Response performEntAppSubscriptionOnDevices( - @ApiParam( - name = "uuid", - value = "The application UUID", - required = true - ) - @PathParam("uuid") String uuid, - @ApiParam( - name = "action", - value = "Performing action.", - required = true - ) - @PathParam("action") String action, - @ApiParam( - name = "deviceIdentifiers", - value = "The list of device identifiers", - required = true - ) - @Valid List deviceIdentifiers, - @ApiParam( - name = "timestamp", - value = "Timestamp of scheduled ent. install operation" - ) - @QueryParam("timestamp") long timestamp, - @ApiParam( - name = "requiresUpdatingExternal", - value = "Should external system such as Google EMM APIs need to be updated." - ) - @QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal - ); - - @POST - @Path("/{uuid}/{subType}/ent-app-install/{action}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Install an application for subscription type via google enterprise install.", - notes = "This will install an application to a given subscription type and this is bulk app installation.", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:install") - }) - } - ) - @ApiResponses( - value = { - - }) - Response performBulkEntAppSubscription( - @ApiParam( - name = "uuid", - value = "The application release UUID", - required = true - ) - @PathParam("uuid") String uuid, - @ApiParam( - name = "subType", - value = "Subscription type of the app installing operation.", - required = true - ) - @PathParam("subType") String subType, - @ApiParam( - name = "action", - value = "Performing action.", - required = true - ) - @PathParam("action") String action, - @ApiParam( - name = "subscribers", - value = "Subscriber list of the application release.", - required = true - ) - @Valid List subscribers, - @ApiParam( - name = "timestamp", - value = "Timestamp of scheduled ent app install operation" - ) - @QueryParam("timestamp") long timestamp, - @ApiParam( - name = "requiresUpdatingExternal", - value = "Should external system such as Google EMM APIs need to be updated." - ) - @QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal - ); - - @GET - @Path("/{uuid}/devices") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Get device details that have a given application install", - notes = "This will get the device details that have a given application install, if exists", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:uninstall") - }) - }, - nickname = "getAppInstalledDevicesByUUID" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved device details.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Found invalid payload with the request.", - response = List.class), - @ApiResponse( - code = 403, - message = "Forbidden. \n Don't have permission to get the details.", - response = List.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting data", - response = ErrorResponse.class) - }) - Response getAppInstalledDevices( - @ApiParam( - name = "name", - value = "The device name. For example, Nexus devices can have names, suhc as shamu, bullhead or angler.", - required = false) - @Size(max = 45) - String name, - @ApiParam( - name = "user", - value = "The username of the owner of the device.", - required = false) - @QueryParam("user") - String user, - @ApiParam( - name = "ownership", - allowableValues = "BYOD, COPE", - value = "Provide the ownership status of the device. The following values can be assigned:\n" + - "- BYOD: Bring Your Own Device\n" + - "- COPE: Corporate-Owned, Personally-Enabled", - required = false) - @QueryParam("ownership") - @Size(max = 45) - String ownership, - @ApiParam( - name = "serialNumber", - value = "The serial number of the device.", - required = false) - @QueryParam("serialNumber") - String serialNumber, - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name = "offset", - value = "The starting pagination index for the complete list of qualified items.", - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Provide how many device details you require from the starting pagination index/offset.", - defaultValue = "5") - @QueryParam("limit") int limit, - @ApiParam( - name = "status", - value = "Provide the device status details, such as active or inactive.") - @QueryParam("status") List status - ); - - @GET - @Path("/{uuid}/{subType}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Get category details that have a given application install", - notes = "This will get the category details that have a given application install, if exists", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:uninstall") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved categories details.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application " + - "release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Found invalid payload with the request.", - response = List.class), - @ApiResponse( - code = 403, - message = "Forbidden. \n Don't have permission to get the details.", - response = List.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting data", - response = ErrorResponse.class) - }) - Response getAppInstalledCategories( - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="subType", - value="Subscription type of the application release.", - required = true) - @PathParam("subType") String subType, - @ApiParam( - name = "offset", - value = "The starting pagination index for the complete list of qualified items.", - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Provide how many device details you require from the starting " + - "pagination index/offset.", - defaultValue = "5") - @QueryParam("limit") int limit - ); - - @GET - @Path("/{uuid}/{subType}/{subTypeName}/devices") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Get device details in categories that have a given application install", - notes = "This will get the category's device details that have a given application install, if exists", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:subscription:uninstall") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved device details.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Devices found which has application " + - "release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Found invalid payload with the request.", - response = List.class), - @ApiResponse( - code = 403, - message = "Forbidden. \n Don't have permission to get the details.", - response = List.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting data", - response = ErrorResponse.class) - }) - Response getAppInstalledDevicesOnCategories( - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="subType", - value="Subscription type of the application release.", - required = true) - @PathParam("subType") String subType, - @ApiParam( - name="subTypeName", - value="Subscription type name of the application release.", - required = true) - @PathParam("subTypeName") String subTypeName, - @ApiParam( - name = "offset", - value = "The starting pagination index for the complete list of qualified items.", - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Provide how many device details you require from the starting " + - "pagination index/offset.", - defaultValue = "5") - @QueryParam("limit") int limit, - @ApiParam( - name = "name", - value = "The device name. For example, Nexus devices can have names, such as shamu, bullhead or angler.", - required = false) - @Size(max = 45) - String name, - @ApiParam( - name = "user", - value = "The username of the owner of the device.", - required = false) - @QueryParam("user") - String user, - @ApiParam( - name = "ownership", - allowableValues = "BYOD, COPE", - value = "Provide the ownership status of the device. The following values can be assigned:\n" + - "- BYOD: Bring Your Own Device\n" + - "- COPE: Corporate-Owned, Personally-Enabled", - required = false) - @QueryParam("ownership") - @Size(max = 45) - String ownership, - @ApiParam( - name = "status", - value = "Provide the device status details, such as active or inactive.") - @QueryParam("status") List status - ); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java deleted file mode 100644 index 8a7840fb68..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.application.mgt.store.api.services.admin; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.swagger.annotations.*; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** -* APIs to handle admin review management related tasks in store. -*/ - -@SwaggerDefinition( -info = @Info( - version = "1.0.0", - title = "Store Review Management Admin Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "StoreReviewManagementAdminService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/admin/reviews"), - }) - } -), -tags = { - @Tag(name = "review_management", description = "Store Review Management related Admin APIs") -} -) -@Scopes( -scopes = { - @Scope( - name = "Update a Review", - description = "Update a Review of applications.", - key = "perm:admin:app:review:update", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/app-mgt/store/admin/review/update"} - ) -} -) - -@Path("/admin/reviews") -@Api(value = "Store Review Management Admin API") -public interface ReviewManagementStoreAdminAPI { -String SCOPE = "scope"; - - @DELETE - @Path("/{uuid}/{reviewId}") - @Produces(MediaType.WILDCARD) - @Consumes(MediaType.WILDCARD) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Remove review", - notes = "Remove review", - tags = "Review Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:update") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully deleted the review"), - @ApiResponse( - code = 404, - message = "Not Found. \n No activity found with the given ID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting the review.", - response = ErrorResponse.class) - }) - - Response deleteReview( - @ApiParam( - name = "uuid", - value = "UUID of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name = "reviewId", - value = "Id of the review.", - required = true) - @PathParam("reviewId") int reviewId); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java deleted file mode 100644 index 1fe7c0255e..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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.application.mgt.store.api.services.admin; - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.store.api.beans.SubscriptionStatusBean; -import io.swagger.annotations.*; - -import javax.validation.constraints.Size; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * API to handle subscription management related admin tasks. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Subscription Management Admin Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "SubscriptionManagementAdminService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/admin/subscription"), - }) - } - ), - tags = { - @Tag(name = "subscription_management, device_management", description = "Subscription Management " - + "related Admin APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "View Application Subscriptions", - description = "View Application Subscriptions.", - key = "perm:admin:app:subscription:view", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/app-mgt/store/admin/subscription/view"} - ), - @Scope( - name = "View Application Subscriptions", - description = "View Application Subscriptions.", - key = "perm:admin:app:subscription:modify", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/app-mgt/store/admin/subscription/modify"} - ) - } -) -@Path("/admin/subscription") -@Api(value = "Subscription Management Admin API") -@Produces(MediaType.APPLICATION_JSON) -public interface SubscriptionManagementAdminAPI { - - String SCOPE = "scope"; - - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Path("/device/{deviceId}/status") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Update subscription status", - notes = "This will update the subscription status that belongs to the given device id", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:subscription:modify") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated subscription status.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while updating subscription status", - response = ErrorResponse.class) - }) - Response updateSubscription( - @ApiParam( - name = "deviceId", - value = "Id of the device", - required = true) - @PathParam("deviceId") int deviceId, - @ApiParam( - name = "subscription status change bean", - value = "this bean contains the information related to status change", - required = true) - SubscriptionStatusBean subscriptionStatusBean - ); - - @GET - @Path("/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Get subscription details of specific application.", - notes = "This will get the subscription details of specific application", - tags = "Subscription Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:subscription:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved subscription details.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting data", - response = ErrorResponse.class) - }) - Response getAppInstalledDevices( - @ApiParam( - name = "name", - value = "The device name. For example, Nexus devices can have names, suhc as shamu, bullhead or angler.", - required = false) - @Size(max = 45) - String name, - @ApiParam( - name = "user", - value = "The username of the owner of the device.", - required = false) - @QueryParam("user") - String user, - @ApiParam( - name = "action", - value = "The action, subscribed or unsubscribed.", - required = false) - @Size(max = 45) - @QueryParam("action") String action, - @ApiParam( - name = "actionStatus", - value = "Provide the action status details") - @QueryParam("actionStatus") String actionStatus, - @ApiParam( - name = "status", - value = "Provide the device status details, such as active or inactive.") - @QueryParam("status") List status, - @ApiParam( - name = "installedVersion", - value = "Provide the installed version of the application.") - @QueryParam("installedVersion") String installedVersion, - @ApiParam( - name = "uuid", - value = "uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name = "offset", - value = "The starting pagination index for the complete list of qualified items.", - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Provide how many device details you require from the starting pagination index/offset.", - defaultValue = "5") - @QueryParam("limit") int limit - ); -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java deleted file mode 100644 index 9d9a6588dd..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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.application.mgt.store.api.services.impl; - -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.response.Application; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.store.api.services.ApplicationManagementAPI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * Implementation of Application Management STORE APIs. - */ -@Produces({ "application/json" }) -@Path("/applications") -public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { - - private static final Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class); - - @POST - @Path("/favourite/{appId}") - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Response addAppToFavourite(@PathParam("appId") int appId) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.addAppToFavourites(appId); - return Response.status(Response.Status.OK).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while adding application to favourites"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @DELETE - @Path("/favourite/{appId}") - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Response removeAppFromFavourite(@PathParam("appId") int appId) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - applicationManager.removeAppFromFavourites(appId); - return Response.status(Response.Status.OK).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while removing application from favourites"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Path("/favourite") - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Response getFavouriteApplications(@Valid Filter filter) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - validateFilter(filter); - ApplicationList applications = applicationManager.getFavouriteApplications(filter); - return Response.status(Response.Status.OK).entity(applications).build(); - } catch (BadRequestException e) { - String msg = "Invalid filter payload found in the request. Hence verify the filter payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while retrieving favourite applications"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @POST - @Override - @Consumes("application/json") - public Response getApplications(@Valid Filter filter) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - validateFilter(filter); - filter.setAppReleaseState(applicationManager.getInstallableLifecycleState()); - ApplicationList applications = applicationManager.getApplications(filter); - return Response.status(Response.Status.OK).entity(applications).build(); - } catch (BadRequestException e) { - String msg = "Invalid request payload found in the request. Hence verify the payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (UnexpectedServerErrorException e) { - String msg = "Unexpected Error occurred while retrieving applications"; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while retrieving applications"; - log.error(msg); - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Consumes("application/json") - @Path("/{uuid}") - public Response getApplication(@PathParam("uuid") String uuid) { - ApplicationManager applicationManager = APIUtil.getApplicationManager(); - try { - Application application = applicationManager - .getApplicationByUuid(uuid, applicationManager.getInstallableLifecycleState()); - if (application == null) { - String msg = "Could not found an application release which is in " + applicationManager - .getInstallableLifecycleState() + " state."; - log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - return Response.status(Response.Status.OK).entity(application).build(); - } catch (NotFoundException e) { - String msg = "Application with application release UUID: " + uuid + " is not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application with the application release uuid: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - /** - * This method can be used to check & validate if {@link Filter} object exist. - * - * @param filter {@link Filter} - * @throws BadRequestException if filter object doesn't exist - */ - private void validateFilter(Filter filter) throws BadRequestException { - if (filter == null) { - String msg = "Request Payload is null"; - log.error(msg); - throw new BadRequestException(msg); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java deleted file mode 100644 index 0e338115c8..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * 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.application.mgt.store.api.services.impl; - -import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.application.mgt.common.Rating; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; -import io.entgra.device.mgt.core.application.mgt.common.response.Review; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ReviewWrapper; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.store.api.services.ReviewManagementAPI; -import io.swagger.annotations.ApiParam; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -/** - * Review Management related jax-rs APIs. - */ -@Path("/reviews") -public class ReviewManagementAPIImpl implements ReviewManagementAPI { - - private static final Log log = LogFactory.getLog(ReviewManagementAPIImpl.class); - - @Override - @GET - @Path("/app/user/{uuid}") - public Response getUserReviews( - @PathParam("uuid") String uuid, - @DefaultValue("0") @QueryParam("offset") int offSet, - @DefaultValue("20") @QueryParam("limit") int limit) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - PaginationRequest request = new PaginationRequest(offSet, limit); - try { - PaginationResult paginationResult = reviewManager.getAllAppReviewsOfUser(request, uuid); - return Response.status(Response.Status.OK).entity(paginationResult).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application which has application release of UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while retrieving reviews for application which has application release for " - + "UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while retrieving application release details for application UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @GET - @Path("/app/{uuid}") - public Response getAllAppReviews( - @PathParam("uuid") String uuid, - @DefaultValue("0") @QueryParam("offset") int offSet, - @DefaultValue("20") @QueryParam("limit") int limit) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - PaginationRequest request = new PaginationRequest(offSet, limit); - try { - PaginationResult paginationResult = reviewManager.getAllAppReviews(request, uuid); - return Response.status(Response.Status.OK).entity(paginationResult).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application which has application release of UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while retrieving reviews for application which has application release for " - + "UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while retrieving application release details for application UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @POST - @Consumes("application/json") - @Path("/{uuid}") - public Response addReview( - @ApiParam ReviewWrapper reviewWrapper, - @PathParam("uuid") String uuid) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - try { - Review review = reviewManager.addReview(reviewWrapper, uuid, false); - if (review != null) { - return Response.status(Response.Status.CREATED).entity(reviewWrapper).build(); - } else { - String msg = "Review adding is failed. Please contact the administrator."; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (NotFoundException e) { - String msg = "Couldn't find an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You have already reviewed the application. Hence you are not permitted to review the " - + "application again."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while creating the reviewTmp"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while accessing application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @POST - @Consumes("application/json") - @Path("/{uuid}/{parentReviewId}") - public Response addReplyComment( - @ApiParam ReviewWrapper reviewWrapper, - @PathParam("uuid") String uuid, - @PathParam("parentReviewId") int parentReviewId) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - try { - boolean isRepliedForReview = reviewManager.addReplyComment(reviewWrapper, uuid, parentReviewId); - if (isRepliedForReview) { - return Response.status(Response.Status.CREATED).entity(reviewWrapper).build(); - } else { - String msg = "Error occurred when adding reply comment for the review. Please contact the administrator.."; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (NotFoundException e) { - String msg = "Couldn't find an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid payload data found with the requested add reply comment. Hence, please verify the " - + "request payload."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - }catch (ReviewManagementException e) { - String msg = "Error occurred while creating the reviewTmp"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while accessing application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @PUT - @Consumes("application/json") - @Path("/{uuid}/{reviewId}") - public Response updateReview( - @ApiParam ReviewWrapper updatingReview, - @PathParam("uuid") String uuid, - @PathParam("reviewId") int reviewId) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - try { - Review updatedReview = reviewManager.updateReview(updatingReview, reviewId, uuid, false); - if (updatedReview != null) { - return Response.status(Response.Status.OK).entity(updatedReview).build(); - } else { - String msg = "Review updating failed. Please contact the administrator"; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (ReviewManagementException e) { - String msg = "Error occurred while retrieving comments."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (NotFoundException e) { - String msg = "Couldn't found application release data for UUID " + uuid + " or Review for review ID: " + reviewId; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid payload data found with the request. Hence, please verify the request payload."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You don't have permission to update application release review."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred when getting application release data for application release UUID:." + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } - } - - @Override - @DELETE - @Path("/{uuid}/{reviewId}") - public Response deleteReview( - @PathParam("uuid") String uuid, - @PathParam("reviewId") int reviewId) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - try { - reviewManager.deleteReview(uuid, reviewId, false); - return Response.status(Response.Status.OK).entity("Review is deleted successfully.").build(); - } catch (NotFoundException e) { - String msg = "Couldn't found an application review to delete which match with the request."; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "You are not permitted to delete the review."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while deleting the comment."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application release data."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @GET - @Path("/{uuid}/app-rating") - public Response getAppRating( - @PathParam("uuid") String uuid) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - Rating rating; - try { - rating = reviewManager.getAppRating(uuid); - } catch (NotFoundException e) { - String msg = "Couldn't found an application for application release UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException | ApplicationManagementException e) { - String msg = "Error occurred while getting review data for application release UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - return Response.status(Response.Status.OK).entity(rating).build(); - } - -} \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java deleted file mode 100644 index 6a12bffc52..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - * 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.application.mgt.store.api.services.impl; - -import io.entgra.device.mgt.core.application.mgt.common.*; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationOperationTaskException; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.task.ScheduledAppSubscriptionTaskManager; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.store.api.services.SubscriptionManagementAPI; -import io.entgra.device.mgt.core.application.mgt.store.api.services.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.*; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import java.util.List; -import java.util.Properties; - -/** - * Implementation of Subscription Management related APIs. - */ -@Produces({"application/json"}) -@Path("/subscription") -public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ - - private static final Log log = LogFactory.getLog(SubscriptionManagementAPIImpl.class); - - @Override - @POST - @Path("/{uuid}/devices/{action}") - public Response performAppOperationForDevices( - @PathParam("uuid") String uuid, - @PathParam("action") String action, - @Valid List deviceIdentifiers, - @QueryParam("timestamp") long timestamp, - @QueryParam("block-uninstall") Boolean isUninstallBlocked - ) { - Properties properties = new Properties(); - if(isUninstallBlocked != null) { - properties.put(MDMAppConstants.AndroidConstants.IS_BLOCK_UNINSTALL, isUninstallBlocked); - } - try { - if (0 == timestamp) { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - ApplicationInstallResponse response = subscriptionManager - .performBulkAppOperation(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(), action, properties); - return Response.status(Response.Status.OK).entity(response).build(); - } else { - return scheduleApplicationOperationTask(uuid, deviceIdentifiers, SubscriptionType.DEVICE, - SubAction.valueOf(action.toUpperCase()), timestamp, properties); - } - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "Application release is not in the installable state. Hence you are not permitted to perform " - + "the action on the application."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = - "Error occurred while installing the application release which has UUID: " + uuid + " for devices"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @POST - @Path("/{uuid}/{subType}/{action}") - public Response performBulkAppOperation( - @PathParam("uuid") String uuid, - @PathParam("subType") String subType, - @PathParam("action") String action, - @Valid List subscribers, - @QueryParam("timestamp") long timestamp, - @QueryParam("block-uninstall") Boolean isUninstallBlocked, - @QueryParam("disable-operation-re-executing") boolean isOperationReExecutingDisabled - ) { - Properties properties = new Properties(); - if (isUninstallBlocked != null) { - properties.put(MDMAppConstants.AndroidConstants.IS_BLOCK_UNINSTALL, isUninstallBlocked); - } - try { - if (0 == timestamp) { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - ApplicationInstallResponse response = - subscriptionManager.performBulkAppOperation(uuid, subscribers, subType, action, properties, - isOperationReExecutingDisabled); - return Response.status(Response.Status.OK).entity(response).build(); - } else { - return scheduleApplicationOperationTask(uuid, subscribers, - SubscriptionType.valueOf(subType.toUpperCase()), SubAction.valueOf(action.toUpperCase()), - timestamp, properties, isOperationReExecutingDisabled); - } - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + uuid + ". Hence, verify the payload"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "Application release is not in the installable state. Hence you are not permitted to perform " - + "the action on the application."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while installing the application release which has UUID: " + uuid - + " for user devices"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @POST - @Path("/{uuid}/devices/ent-app-install/{action}") - public Response performEntAppSubscriptionOnDevices( - @PathParam("uuid") String uuid, - @PathParam("action") String action, - @Valid List deviceIdentifiers, - @QueryParam("timestamp") long timestamp, - @QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) { - try { - if (0 == timestamp) { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - subscriptionManager - .performEntAppSubscription(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(), - action, requiresUpdatingExternal); - String msg = "Application release which has UUID " + uuid + " is installed to given valid device " - + "identifiers."; - return Response.status(Response.Status.OK).entity(msg).build(); - } else { - return scheduleApplicationOperationTask(uuid, deviceIdentifiers, SubscriptionType.DEVICE, - SubAction.valueOf(SubAction.INSTALL.toString().toUpperCase()), timestamp, null); - } - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + uuid + " to perform ent app installation " - + "on subscriber's devices"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "Application release is not in the installable state. Hence you are not permitted to install " - + "the application."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = - "Error occurred while performing ent app installation on the application release which has UUID: " - + uuid + " for devices"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @Override - @POST - @Path("/{uuid}/{subType}/ent-app-install/{action}") - public Response performBulkEntAppSubscription( - @PathParam("uuid") String uuid, - @PathParam("subType") String subType, - @PathParam("action") String action, - @Valid List subscribers, - @QueryParam("timestamp") long timestamp, - @QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) { - try { - if (0 == timestamp) { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - subscriptionManager.performEntAppSubscription(uuid, subscribers, subType, action, requiresUpdatingExternal); - String msg = "Application release which has UUID " + uuid + " is installed to subscriber's valid device" - + " identifiers."; - return Response.status(Response.Status.OK).entity(msg).build(); - } else { - return scheduleApplicationOperationTask(uuid, subscribers, - SubscriptionType.valueOf(subType.toUpperCase()), - SubAction.valueOf(SubAction.INSTALL.toString().toUpperCase()), timestamp, null); - } - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + uuid + ". Hence, verify the payload"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "Application release is not in the installable state. Hence you are not permitted to install " - + "the application."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while performing ent app installation on the application release which has " - + "UUID: " + uuid + " for user devices"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - /** - * Schedule the application subscription for the given timestamp - * - * @param applicationUUID UUID of the application to install - * @param subscribers list of subscribers. This list can be of - * either {@link io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier} if {@param subType} is - * equal to DEVICE or {@link String} if {@param subType} is USER, ROLE or GROUP - * @param subType subscription type. E.g. DEVICE, USER, ROLE, GROUP - * {@see {@link io.entgra.device.mgt.core.application.mgt.common.SubscriptionType}} - * @param subAction action subscription action. E.g. INSTALL/UNINSTALL - * {@see {@link io.entgra.device.mgt.core.application.mgt.common.SubAction}} - * @param payload Properties sending to the device via operation - * @param timestamp timestamp to schedule the application subscription - * @return {@link Response} of the operation - */ - private Response scheduleApplicationOperationTask(String applicationUUID, List subscribers, - SubscriptionType subType, SubAction subAction, long timestamp, - Properties payload) { - return scheduleApplicationOperationTask(applicationUUID, subscribers, subType, subAction, timestamp, payload, - false); - } - - /** - * Schedule the application subscription for the given timestamp - * - * @param applicationUUID UUID of the application to install - * @param subscribers list of subscribers. This list can be of - * either {@link io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier} if {@param subType} is - * equal to DEVICE or {@link String} if {@param subType} is USER, ROLE or GROUP - * @param subType subscription type. E.g. DEVICE, USER, ROLE, GROUP - * {@see {@link io.entgra.device.mgt.core.application.mgt.common.SubscriptionType}} - * @param subAction action subscription action. E.g. INSTALL/UNINSTALL - * {@see {@link io.entgra.device.mgt.core.application.mgt.common.SubAction}} - * @param timestamp timestamp to schedule the application subscription - * @param payload Properties sending to the device via operation - * @param isOperationReExecutingDisabled To prevent adding the application subscribing operation to devices that are - * already subscribed application successfully. - * @return {@link Response} of the operation - */ - private Response scheduleApplicationOperationTask(String applicationUUID, List subscribers, - SubscriptionType subType, SubAction subAction, long timestamp, - Properties payload, boolean isOperationReExecutingDisabled) { - try { - ScheduledAppSubscriptionTaskManager subscriptionTaskManager = new ScheduledAppSubscriptionTaskManager(); - subscriptionTaskManager.scheduleAppSubscriptionTask(applicationUUID, subscribers, subType, subAction, - timestamp, payload, isOperationReExecutingDisabled); - } catch (ApplicationOperationTaskException e) { - String msg = "Error occurred while scheduling the application install operation"; - log.error(msg, e); - ErrorResponse errorResponse = new ErrorResponse(msg); - errorResponse.setDescription(e.getMessage()); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); - } - return Response.status(Response.Status.CREATED).build(); - } - - @GET - @Consumes("application/json") - @Produces("application/json") - @Path("/{uuid}/devices") - public Response getAppInstalledDevices( - @QueryParam("name") String name, - @QueryParam("user") String user, - @QueryParam("ownership") String ownership, - @QueryParam("serialNumber") String serialNumber, - @PathParam("uuid") String uuid, - @DefaultValue("0") - @QueryParam("offset") int offset, - @DefaultValue("5") - @QueryParam("limit") int limit, - @QueryParam("status") List status) { - try { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - PaginationRequest request = new PaginationRequest(offset, limit); - if (name != null && !name.isEmpty()) { - request.setDeviceName(name); - } - if (user != null && !user.isEmpty()) { - request.setOwner(user); - } - if (ownership != null && !ownership.isEmpty()) { - RequestValidationUtil.validateOwnershipType(ownership); - request.setOwnership(ownership); - } - if (StringUtils.isNotBlank(serialNumber)) { - request.setSerialNumber(serialNumber); - } - if (status != null && !status.isEmpty()) { - boolean isStatusEmpty = true; - for (String statusString : status) { - if (StringUtils.isNotBlank(statusString)) { - isStatusEmpty = false; - break; - } - } - if (!isStatusEmpty) { - RequestValidationUtil.validateStatus(status); - request.setStatusList(status); - } - } - PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid); - DeviceList devices = new DeviceList(); - devices.setList((List) subscribedDeviceDetails.getData()); - devices.setCount(subscribedDeviceDetails.getRecordsTotal()); - return Response.status(Response.Status.OK).entity(devices).build(); - } catch (NotFoundException e) { - String msg = "Application with application release UUID: " + uuid + " is not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "User requested details are not valid. Please verify the payload of the request."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "Application release is not in the installable state." - + "Hence you are not permitted to get the devices details."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application with the application release uuid: " - + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Consumes("application/json") - @Produces("application/json") - @Path("/{uuid}/{subType}") - public Response getAppInstalledCategories( - @PathParam("uuid") String uuid, - @PathParam("subType") String subType, - @DefaultValue("0") - @QueryParam("offset") int offset, - @DefaultValue("5") - @QueryParam("limit") int limit) { - try { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - - PaginationResult subscribedCategoryDetails = subscriptionManager - .getAppInstalledSubscribers(offset, limit, uuid, subType); - - if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) { - BasicUserInfoList users = new BasicUserInfoList(); - - users.setList((List) subscribedCategoryDetails.getData()); - users.setCount(subscribedCategoryDetails.getRecordsTotal()); - - return Response.status(Response.Status.OK).entity(users).build(); - } else if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) { - RoleList roles = new RoleList(); - - roles.setList(subscribedCategoryDetails.getData()); - roles.setCount(subscribedCategoryDetails.getRecordsTotal()); - - return Response.status(Response.Status.OK).entity(roles).build(); - } else if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) { - DeviceGroupList groups = new DeviceGroupList(); - - groups.setList(subscribedCategoryDetails.getData()); - groups.setCount(subscribedCategoryDetails.getRecordsTotal()); - - return Response.status(Response.Status.OK).entity(groups).build(); - } else { - String msg = "Found invalid sub type "; - log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - } catch (NotFoundException e) { - String msg = "Application with application release UUID: " + uuid + " is not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid payload found when getting application. Hence verify the payload"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ForbiddenException e) { - String msg = "Application release is not in the installable state." - + "Hence you are not permitted to get the devices details."; - log.error(msg, e); - return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application with the application " + - "release uuid: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Consumes("application/json") - @Produces("application/json") - @Path("/{uuid}/{subType}/{subTypeName}/devices") - public Response getAppInstalledDevicesOnCategories( - @PathParam("uuid") String uuid, - @PathParam("subType") String subType, - @PathParam("subTypeName") String subTypeName, - @DefaultValue("0") - @QueryParam("offset") int offset, - @DefaultValue("5") - @QueryParam("limit") int limit, - @QueryParam("name") String name, - @QueryParam("user") String user, - @QueryParam("ownership") String ownership, - @QueryParam("status") List status) { - try { - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - PaginationRequest request = new PaginationRequest(offset, limit); - - if (StringUtils.isNotBlank(name)) { - request.setDeviceName(name); - } - if (StringUtils.isNotBlank(user)) { - request.setOwner(user); - } - if (StringUtils.isNotBlank(ownership)) { - RequestValidationUtil.validateOwnershipType(ownership); - request.setOwnership(ownership); - } - if (status != null && !status.isEmpty()) { - boolean isStatusEmpty = true; - for (String statusString : status) { - if (StringUtils.isNotBlank(statusString)) { - isStatusEmpty = false; - break; - } - } - if (!isStatusEmpty) { - RequestValidationUtil.validateStatus(status); - request.setStatusList(status); - } - } - - //todo need to update the API for other subscription types - if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) { - PaginationResult subscribedCategoryDetails = subscriptionManager - .getAppInstalledSubscribeDevices(request, uuid, subType, subTypeName); - DeviceList devices = new DeviceList(); - devices.setList((List) subscribedCategoryDetails.getData()); - devices.setCount(subscribedCategoryDetails.getRecordsTotal()); - return Response.status(Response.Status.OK).entity(devices).build(); - } else { - String msg = "Found invalid sub type: " + subType; - log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - } catch (NotFoundException e) { - String msg = "Application with application release UUID: " + uuid + " is not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "Invalid payload found with the request. Please verify the payload."; - log.error(msg,e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application with the application " + - "release uuid: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java deleted file mode 100644 index de625df362..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.application.mgt.store.api.services.impl.admin; - -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.store.api.services.admin.ReviewManagementStoreAdminAPI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * Review Management related jax-rs APIs. - */ -@Path("/admin/reviews") -public class ReviewManagementStoreAdminAPIImpl implements ReviewManagementStoreAdminAPI { - - private static final Log log = LogFactory.getLog(ReviewManagementStoreAdminAPIImpl.class); - - @Override - @DELETE - @Path("/{uuid}/{reviewId}") - @Produces(MediaType.WILDCARD) - @Consumes(MediaType.WILDCARD) - public Response deleteReview( - @PathParam("uuid") String uuid, - @PathParam("reviewId") int reviewId) { - - ReviewManager reviewManager = APIUtil.getReviewManager(); - try { - reviewManager.deleteReview(uuid, reviewId, true); - return Response.status(Response.Status.OK).entity("Review is deleted successfully.").build(); - } catch (NotFoundException e) { - String msg = "Couldn't found an application review to delete which match with the request."; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while deleting the comment."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting application release data."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } -} \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java deleted file mode 100644 index e30bf4b0ce..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.application.mgt.store.api.services.impl.admin; - -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.store.api.beans.SubscriptionStatusBean; -import io.entgra.device.mgt.core.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI; -import io.entgra.device.mgt.core.application.mgt.store.api.services.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Implementation of Subscription Management related APIs. - */ -@Produces({"application/json"}) -@Path("/admin/subscription") -public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagementAdminAPI { - - private static final Log log = LogFactory.getLog(SubscriptionManagementAdminAPIImpl.class); - - @Override - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Path("/device/{deviceId}/status") - public Response updateSubscription( - @PathParam("deviceId") int deviceId, - SubscriptionStatusBean subscriptionStatusBean - ) { - try { - RequestValidationUtil.validateSubscriptionStatus(subscriptionStatusBean.getStatus()); - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - subscriptionManager.updateSubscriptionStatus(deviceId, subscriptionStatusBean.getSubId(), - subscriptionStatusBean.getStatus()); - return Response.status(Response.Status.OK).entity("Subscription status updated successfully").build(); - } catch (BadRequestException e) { - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); - } catch (SubscriptionManagementException e) { - String msg = "Error occurred while changing subscription status of the subscription with the id " - + subscriptionStatusBean.getSubId(); - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - - @GET - @Consumes("application/json") - @Produces("application/json") - @Path("/{uuid}") - public Response getAppInstalledDevices( - @QueryParam("name") String name, - @QueryParam("user") String user, - @QueryParam("action") String action, - @QueryParam("actionStatus") String actionStatus, - @QueryParam("status") List status, - @QueryParam("installedVersion") String installedVersion, - @PathParam("uuid") String uuid, - @DefaultValue("0") - @QueryParam("offset") int offset, - @DefaultValue("5") - @QueryParam("limit") int limit) { - - try { - PaginationRequest request = new PaginationRequest(offset, limit); - if (name != null && !name.isEmpty()) { - request.setDeviceName(name); - } - if (user != null && !user.isEmpty()) { - request.setOwner(user); - } - if (action != null && !action.isEmpty()) { - RequestValidationUtil.validateAction(action); - } - if (status != null && !status.isEmpty()) { - boolean isStatusEmpty = true; - for (String statusString : status) { - if (StringUtils.isNotBlank(statusString)) { - isStatusEmpty = false; - break; - } - } - if (!isStatusEmpty) { - RequestValidationUtil.validateStatus(status); - request.setStatusList(status); - } - } - if (actionStatus != null && !actionStatus.isEmpty()) { - if (StringUtils.isNotBlank(actionStatus)) { - RequestValidationUtil.validateStatusFiltering(actionStatus); - } - } - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails - (request, uuid, actionStatus, action, installedVersion); - return Response.status(Response.Status.OK).entity(subscriptionData).build(); - } catch (NotFoundException e) { - String msg = "Application with application release UUID: " + uuid + " is not found"; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (BadRequestException e) { - String msg = "User requested details are not valid. Please verify the request payload."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while getting app installed devices which has application release UUID of: " - + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java deleted file mode 100644 index 199f3b5593..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.application.mgt.store.api.services.impl.util; - -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.store.api.util.Constants; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; -import org.apache.commons.lang3.EnumUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; - -public class RequestValidationUtil { - - private static final Log log = LogFactory.getLog(RequestValidationUtil.class); - - /** - * Checks if user requested status codes are valid. - * - * @param statusList status codes upon to filter operation logs using status - */ - public static void validateStatus(List statusList) throws BadRequestException { - for (String status : statusList) { - switch (status) { - case "ACTIVE": - case "INACTIVE": - case "UNCLAIMED": - case "UNREACHABLE": - case "SUSPENDED": - case "DISENROLLMENT_REQUESTED": - case "REMOVED": - case "BLOCKED": - case "CREATED": - case "CONFIGURED": - case "READY_TO_CONNECT": - case "RETURN_PENDING": - case "RETURNED": - case "DEFECTIVE": - case "WARRANTY_PENDING": - case "WARRANTY_SENT": - case "WARRANTY_REPLACED": - case "ASSIGNED": - break; - default: - String msg = "Invalid enrollment status type: " + status + ". \nValid status types " + - "are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + - "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED | CONFIGURED | READY_TO_CONNECT | " + - "RETURN_PENDING | RETURNED | DEFECTIVE | WARRANTY_PENDING | WARRANTY_SENT | " + - "WARRANTY_REPLACED | ASSIGNED |"; - log.error(msg); - throw new BadRequestException(msg); - } - } - } - - /** - * Checks if user requested action is valid. - * - * @param action action upon to filter devices using action - */ - public static void validateAction(String action) throws BadRequestException { - if (action.equals("SUBSCRIBED") || action.equals("UNSUBSCRIBED")) { - } else { - String msg = "Invalid action type received.Valid action types are SUBSCRIBED | UNSUBSCRIBED"; - log.error(msg); - throw new BadRequestException(msg); - } - } - - /** - * Checks if user requested ownerships are valid. - * - * @param ownership ownerships upon to filter devices using ownership - */ - public static void validateOwnershipType(String ownership) throws BadRequestException { - switch (ownership) { - case "BYOD": - case "COPE": - case "WORK_PROFILE": - case "GOOGLE_ENTERPRISE": - case "COSU": - case "FULLY_MANAGED": - case "DEDICATED_DEVICE": - break; - default: - String msg = "Invalid ownership type received.Valid ownership types are BYOD | COPE | WORK_PROFILE |" + - "GOOGLE_ENTERPRISE | COSU | FULLY_MANAGED | DEDICATED_DEVICE"; - log.error(msg); - throw new BadRequestException(msg); - } - } - - /** - * Checks if user requested Action status codes are valid. - * - * @param status status codes upon to filter operation logs using status - */ - public static void validateStatusFiltering(String status) throws BadRequestException { - if (Constants.OperationStatus.COMPLETED.toUpperCase().equals(status) - || Constants.OperationStatus.ERROR.toUpperCase().equals(status) - || Constants.OperationStatus.NOTNOW.toUpperCase().equals(status) - || Constants.OperationStatus.REPEATED.toUpperCase().equals(status) - || Constants.OperationStatus.PENDING.toUpperCase().equals(status) - || Constants.OperationStatus.IN_PROGRESS.toUpperCase().equals(status)) { - } else { - String msg = "Invalid status type: " + status + ". \nValid status types are COMPLETED | ERROR | " + - "IN_PROGRESS | NOTNOW | PENDING | REPEATED"; - log.error(msg); - throw new BadRequestException(msg); - } - } - - /** - * Checks if user requested subscription status is valid. - * - */ - public static void validateSubscriptionStatus(String status) throws BadRequestException{ - if (!EnumUtils.isValidEnum(ActivityStatus.Status.class, status)) { - List validStatuses = EnumUtils.getEnumList(ActivityStatus.Status.class); - String validStatusesString = StringUtils.join(validStatuses, " | "); - String msg = "Invalid status type: " + status + ". \nValid status types are " + validStatusesString; - log.error(msg); - throw new BadRequestException(msg); - } - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/util/Constants.java deleted file mode 100644 index 5d46ac7c56..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/util/Constants.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.application.mgt.store.api.util; - -/** - * Holds the constants used by DeviceImpl Management Admin web application. - */ -public class Constants { - - public static final String USER_CLAIM_EMAIL_ADDRESS = "http://wso2.org/claims/emailaddress"; - public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname"; - public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname"; - public static final String USER_CLAIM_CREATED = "http://wso2.org/claims/created"; - public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; - public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; - public static final String PRIMARY_USER_STORE = "PRIMARY"; - public static final String DEFAULT_STREAM_VERSION = "1.0.0"; - public static final String SCOPE = "scope"; - public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; - public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; - public static final int DEFAULT_PAGE_LIMIT = 50; - public static final String FORWARD_SLASH = "/"; - public static final String ANDROID = "android"; - public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.uem.platform.android." + - "core.polcy.AndroidPolicyPayloadValidator"; - public static final String IOS = "ios"; - public static final String WINDOWS = "windows"; - - - public final class OperationStatus { - private OperationStatus () { throw new AssertionError(); } - public static final String COMPLETED = "completed"; - public static final String ERROR = "error"; - public static final String IN_PROGRESS = "in_progress"; - public static final String PENDING = "pending"; - public static final String NOTNOW = "notnow"; - public static final String REPEATED = "repeated"; - } - public static final String DEVICES = "devices"; - public static final String ATTRIBUTE_DISPLAY_NAME = "DisplayName"; - public static final String ATTRIBUTE_DESCRIPTION = "Description"; - public static final String EXTERNAL_DEVICE_CLAIM_DISPLAY_NAME = "Devices"; - public static final String EXTERNAL_DEVICE_CLAIM_DESCRIPTION = "Device list"; - - public final class ErrorMessages { - private ErrorMessages () { throw new AssertionError(); } - - public static final String STATUS_BAD_REQUEST_MESSAGE_DEFAULT = "Bad Request"; - - } - - public final class DeviceConstants { - private DeviceConstants () { throw new AssertionError(); } - - public static final String APPLICATION_JSON = "application/json"; - public static final String HEADER_CONTENT_TYPE = "Content-Type"; - } - - public final class Permission { - private Permission() { throw new AssertionError(); } - - public static final String ADMIN = "/permission/admin"; - public static final String LOGIN = "/permission/admin/login"; - public static final String DEVICE_MGT = "/permission/admin/device-mgt"; - public static final String APP_MGT = "/permission/admin/app-mgt"; - } - -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/META-INF/permissions.xml deleted file mode 100644 index 6e82bd1fd0..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/META-INF/permissions.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - Get Application - /device-mgt/application/get - /application-mgt/applications - GET - - - Create Application - /device-mgt/application/create - /application-mgt/applications - POST - - - Edit Application - /device-mgt/application/update - /application-mgt/applications - PUT - - - Login to Application Management - /device-mgt/application-mgt/login - /application-mgt/applications - PUT - - - Login to Application Management - device-mgt/application/delete - /application-mgt/applications/* - DELETE - - - - - Get Platform - /device-mgt/platform/get - /application-mgt/platforms/* - GET - - - Add Platform - /device-mgt/platform/add - /application-mgt/platforms - POST - - - Update Platform - /device-mgt/platform/update - /application-mgt/platforms/* - PUT - - - Remove Platform - /device-mgt/platform/remove - /application-mgt/platforms/* - DELETE - - - - - Install Application - /device-mgt/subscription/install - /application-mgt/subscription - POST - - - Uninstall Application - /device-mgt/subscription/uninstall - /application-mgt/subscription - POST - - - Get Application - /device-mgt/subscription/getApplication - /application-mgt/subscription - GET - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml deleted file mode 100644 index 705c89edc9..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - false - - - CXF3,Carbon - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml deleted file mode 100644 index 39409f7aff..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/WEB-INF/web.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 39bb61acde..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - App Store Management Webapp - - JAX-WS/JAX-RS App Store Management Endpoint - JAX-WS/JAX-RS Servlet - CXFServlet - - org.apache.cxf.transport.servlet.CXFServlet - - - - swagger.security.filter - ApiAuthorizationFilterImpl - - 1 - - - CXFServlet - /* - - - 60 - - - doAuthentication - true - - - - - - ApplicationMgt-Admin - /* - - - CONFIDENTIAL - - - - - - managed-api-enabled - true - - - managed-api-owner - admin - - - isSharedWithAllTenants - true - - - - ApiOriginFilter - io.entgra.device.mgt.core.application.mgt.addons.ApiOriginFilter - - - - HttpHeaderSecurityFilter - org.apache.catalina.filters.HttpHeaderSecurityFilter - - hstsEnabled - false - - - - - ContentTypeBasedCachePreventionFilter - org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter - - patterns - text/html" ,application/json" ,text/plain - - - filterAction - enforce - - - httpHeaders - Cache-Control: no-store, no-cache, must-revalidate, private - - - - - HttpHeaderSecurityFilter - /* - - - - ContentTypeBasedCachePreventionFilter - /* - - - - ApiOriginFilter - /* - - - \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/CommentMgtTestHelper.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/CommentMgtTestHelper.java deleted file mode 100644 index 2e2cf968ff..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/CommentMgtTestHelper.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.application.mgt.store.api.services; - -import io.entgra.device.mgt.core.application.mgt.common.response.Review; - -/** - * Helper class for Review Management API test cases. - */ - -public class CommentMgtTestHelper { - - private static final String COMMENT_TEXT = "Dummy Review"; - private static final String CREATED_BY = "TEST_CREATED_BY"; - private static final String MODIFIED_BY = "TEST_MODIFIED_BY"; - private static final int PARENT_ID = 123; - private static final int COMMENT_ID = 1; - - /** - * Creates a Review with given text and given uuid. - * If the text is null, the COMMENT_TEXT will be used as the Dummy Review. - * - * @param commentText : Text of the Review - * @return Review - */ - public static Review getDummyComment(String commentText, String uuid) { - Review reviewTmp = new Review(); - reviewTmp.setId(COMMENT_ID); - reviewTmp.setUsername(CREATED_BY); - reviewTmp.setContent(commentText != null ? commentText : COMMENT_TEXT); - - return reviewTmp; - } -} - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java deleted file mode 100644 index 09964562b8..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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.application.mgt.store.api.services; - -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import junit.framework.TestCase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Ignore; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; - -@PowerMockIgnore("javax.ws.rs.*") -@SuppressStaticInitializationFor({ - "io.entgra.device.mgt.core.application.mgt.api.APIUtil" }) -@PrepareForTest({ APIUtil.class, ReviewManager.class, - ReviewManagementAPITest.class}) -@Ignore("Since comment manager logic is invalid temporarily added Ignore annotation to skip running comment management test cases") public class ReviewManagementAPITest - extends - TestCase { - private static final Log log = LogFactory.getLog(ReviewManagementAPI.class); - - private ReviewManagementAPI commentManagementAPI; - private ReviewManager reviewManager; -// -// @ObjectFactory -// public IObjectFactory getObjectFactory() { -// return new org.powermock.modules.testng.PowerMockObjectFactory(); -// } -// -// @BeforeClass -// void init() throws ReviewManagementException { -// -// log.info("Initializing ReviewManagementAPI tests"); -// initMocks(this); -// this.reviewManager = Mockito.mock(ReviewManager.class, Mockito.RETURNS_DEFAULTS); -// this.commentManagementAPI = new ReviewManagementAPIImpl(); -// } -// -// @Test -// public void testGetAllCommentsWithValidDetails() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.getAllReleaseReviews("a", 1, 2); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), -// "The response status should be 200."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testGetAllCommentsInternalError() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Mockito.doThrow(new ReviewManagementException()).when(this.reviewManager) -// .getAllReleaseReviews(Mockito.any(), Mockito.anyString()); -// Response response = this.commentManagementAPI.getAllReleaseReviews("a", 1, 4); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), -// "The response status should be 500."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testGetAllCommentsNotFoundError() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.getAllReleaseReviews(null, 1, 3); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode(), -// "The response status should be 404."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testAddComments() throws Exception { -// Review review = CommentMgtTestHelper.getDummyComment("a", "a"); -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.addReview(review, "a"); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(), -// "The response status should be 201."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testAddNullComment() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.addReview(null, "a"); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), -// "The response status should be 400."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testAddCommentsInternalError() throws Exception { -// Review review = CommentMgtTestHelper.getDummyComment("a", "a"); -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Mockito.when(this.commentManagementAPI.addReview(Mockito.any(), Mockito.anyString())) -// .thenThrow(new ReviewManagementException()); -// Response response = this.commentManagementAPI.addReview(review, null); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), -// "The response status should be 500."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testUpdateComment() throws Exception { -// Review review = CommentMgtTestHelper.getDummyComment("a", "a"); -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.updateReview(review, 1); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), -// "The response status should be 200."); -// } -// -// @Test -// public void testUpdateNullComment() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.updateReview(null, 1); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), -// "The response status should be 400."); -// } -// -// @Test -// public void testUpdateCommentWhenNullCommentId() throws Exception { -// Review review = CommentMgtTestHelper.getDummyComment("a", "a"); -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.updateReview(review, 0); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode(), -// "The response status should be 404."); -// } -// -// @Test -// public void testUpdateCommentInternalServerError() throws Exception { -// Review review = CommentMgtTestHelper.getDummyComment("a", "a"); -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Mockito.doThrow(new ReviewManagementException()).when(this.reviewManager).updateReview(review, 9, true); -// Response response = this.commentManagementAPI.updateReview(review, 9); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), -// "The response status should be 500."); -// } -// -// @Test -// public void testDeleteComment() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.deleteReview(1,""); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), -// "The response status should be 200."); -// } -// -// @Test -// public void testDeleteCommentInternalError() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Mockito.when(this.commentManagementAPI.deleteReview(1,"")).thenThrow(new ReviewManagementException()); -// Response response = this.commentManagementAPI.deleteReview(1,""); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), -// "The response status should be 500."); -// } -// -// @Test -// public void testDeleteCommentNotFoundError() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.deleteReview(0,""); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode(), -// "The response status should be 404."); -// } -// -// @Test -// public void testGetStars() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Response response = this.commentManagementAPI.getAppReleaseRating("a"); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), -// "The response status should be 200."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testGetStarsCommentError() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Mockito.when(this.commentManagementAPI.getAppReleaseRating(Mockito.anyString())) -// .thenThrow(new ReviewManagementException()); -// Response response = this.commentManagementAPI.getAppReleaseRating("a"); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), -// "The response status should be 500."); -// Mockito.reset(reviewManager); -// } -// -// @Test -// public void testGetStarsApplicationError() throws Exception { -// PowerMockito.stub(PowerMockito.method(APIUtil.class, "getReviewManager")).toReturn(this.reviewManager); -// Mockito.when(this.commentManagementAPI.getAppReleaseRating(Mockito.anyString())) -// .thenThrow(new ApplicationManagementException()); -// Response response = this.commentManagementAPI.getAppReleaseRating("a"); -// Assert.assertNotNull(response, "The response object is null."); -// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), -// "The response status should be 500."); -// Mockito.reset(reviewManager); -// } -} \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/resources/log4j.properties b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/resources/log4j.properties deleted file mode 100644 index e60ffec510..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/resources/log4j.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# 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. -# -log4j.rootLogger=DEBUG, STD_OUT -# Redirect log messages to console -log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender -log4j.appender.STD_OUT.Target=System.out -log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout -log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/resources/testng.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/resources/testng.xml deleted file mode 100644 index 03a7b01331..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/resources/testng.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index a7c00b4e3a..512aef9700 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -36,10 +36,6 @@ io.entgra.device.mgt.core.application.mgt.common io.entgra.device.mgt.core.application.mgt.core - io.entgra.device.mgt.core.application.mgt.addons - io.entgra.device.mgt.core.application.mgt.publisher.api - io.entgra.device.mgt.core.application.mgt.store.api - io.entgra.device.mgt.core.application.mgt.api diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index ae8e99a83d..521ff65c5c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -512,13 +512,6 @@ org.wso2.orbit.javax.xml.bind jaxb-api - 2.3.1.wso2v1 - compile - - - org.wso2.orbit.javax.xml.bind - jaxb-api - 2.3.1.wso2v1 compile diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index d5679e796e..4515dc8734 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1313,7 +1313,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } //Add the query for owner if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; + sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } else if (ownerPattern != null && !ownerPattern.isEmpty()) { sql = sql + " AND e.OWNER LIKE ?"; @@ -1341,7 +1341,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setString(paramIdx++, request.getOwnership()); } if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); + stmt.setString(paramIdx++, "%" + owner + "%"); } else if (isOwnerPatternProvided) { stmt.setString(paramIdx++, ownerPattern + "%"); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 3021b2f955..27a3bd1ecc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -118,7 +118,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } //Add the query for owner if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; + sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } else if (ownerPattern != null && !ownerPattern.isEmpty()) { sql = sql + " AND e.OWNER LIKE ?"; @@ -150,7 +150,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, ownership); } if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); + stmt.setString(paramIdx++, "%" + owner + "%"); } else if (isOwnerPatternProvided) { stmt.setString(paramIdx++, ownerPattern + "%"); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java index 672ecb6af1..4dc7fb1931 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java @@ -78,6 +78,8 @@ public interface DeviceInformationManager { void addDeviceLocation(Device device, DeviceLocation deviceLocation) throws DeviceDetailsMgtException; + void deleteDeviceLocation(Device device) throws DeviceDetailsMgtException; + void addDeviceLocations(Device device, List deviceLocations) throws DeviceDetailsMgtException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index 84f2ce0975..c7f56174e5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -48,7 +48,11 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserStoreException; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class DeviceInformationManagerImpl implements DeviceInformationManager { @@ -412,6 +416,35 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } } + @Override + public void deleteDeviceLocation(Device device) throws DeviceDetailsMgtException { + try { + if (log.isDebugEnabled()) { + log.debug("Deleting device location for device: " + device.getId()); + } + DeviceManagementDAOFactory.beginTransaction(); + DeviceLocation deviceLocation = deviceDetailsDAO.getDeviceLocation(device.getId(), + device.getEnrolmentInfo().getId()); + if (deviceLocation != null) { + deviceDetailsDAO.deleteDeviceLocation(device.getId(), device.getEnrolmentInfo().getId()); + } else { + log.error("Device location not found for device: " + device.getId()); + throw new DeviceDetailsMgtException("Device location not found for device: " + device.getId()); + } + DeviceManagementDAOFactory.commitTransaction(); + } catch (TransactionManagementException e) { + log.error("Transactional error occurred while deleting the device location information. Device ID: " + device.getId(), e); + throw new DeviceDetailsMgtException("Transactional error occurred while deleting the device location " + + "information.", e); + } catch (DeviceDetailsMgtDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + log.error("Error occurred while deleting the device location information. Device ID: " + device.getId(), e); + throw new DeviceDetailsMgtException("Error occurred while deleting the device location information.", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + @Override public void addDeviceLocations(Device device, List deviceLocations) throws DeviceDetailsMgtException { try { diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/pom.xml deleted file mode 100644 index 03b466f377..0000000000 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/pom.xml +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - io.entgra.device.mgt.core - application-mgt-feature - 5.0.26-SNAPSHOT - ../pom.xml - - - 4.0.0 - io.entgra.device.mgt.core.application.mgt.api.feature - pom - Entgra - Application Management API Feature - https://entgra.io - This feature contains the APIs required for Application Management console UI - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - publisher-copy - package - - copy - - - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.publisher.api - - ${project.version} - war - true - - ${project.build.directory}/maven-shared-archive-resources/webapps - - api#application-mgt-publisher#v1.0.war - - - - - - store-copy - package - - copy - - - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.store.api - - ${project.version} - war - true - - ${project.build.directory}/maven-shared-archive-resources/webapps - - api#application-mgt-store#v1.0.war - - - - - - app-mgt-copy - package - - copy - - - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.api - - ${project.version} - war - true - - ${project.build.directory}/maven-shared-archive-resources/webapps - - api#application-mgt#v1.0.war - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - - - copy-resources - generate-resources - - copy-resources - - - src/main/resources - - - resources - - build.properties - p2.inf - - - - - - - - - org.wso2.maven - carbon-p2-plugin - - - p2-feature-generation - package - - p2-feature-gen - - - io.entgra.device.mgt.core.application.mgt.api - ../../../features/etc/feature.properties - - - - org.wso2.carbon.p2.category.type:server - - org.eclipse.equinox.p2.type.group:false - - - - - - - - - - - diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/src/main/resources/build.properties b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/src/main/resources/build.properties deleted file mode 100644 index 89aee3ff76..0000000000 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/src/main/resources/build.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. -# - -custom = true diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/src/main/resources/p2.inf b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/src/main/resources/p2.inf deleted file mode 100644 index cc66149599..0000000000 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.api.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,5 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.application.mgt.api_${feature.version}/webapps/api#application-mgt-publisher#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#application-mgt-publisher#v1.0.war,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.application.mgt.api_${feature.version}/webapps/api#application-mgt-store#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#application-mgt-store#v1.0.war,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.application.mgt.api_${feature.version}/webapps/api#application-mgt#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#application-mgt#v1.0.war,overwrite:true);\ diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index d4e07c31d4..4877de4bbe 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -33,7 +33,6 @@ https://entgra.io - io.entgra.device.mgt.core.application.mgt.api.feature io.entgra.device.mgt.core.application.mgt.server.feature diff --git a/pom.xml b/pom.xml index 2c025ae108..dd387b813a 100644 --- a/pom.xml +++ b/pom.xml @@ -186,11 +186,6 @@ io.entgra.device.mgt.core.certificate.mgt.core ${io.entgra.device.mgt.core.version} - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.addons - ${io.entgra.device.mgt.core.version} - io.entgra.device.mgt.core io.entgra.device.mgt.core.application.mgt.core @@ -201,16 +196,6 @@ io.entgra.device.mgt.core.application.mgt.common ${io.entgra.device.mgt.core.version} - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.publisher.api - ${io.entgra.device.mgt.core.version} - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.application.mgt.store.api - ${io.entgra.device.mgt.core.version} - io.entgra.device.mgt.core io.entgra.device.mgt.core.policy.mgt.common