forked from community/device-mgt-core
commit
6f54e5aadf
@ -0,0 +1,119 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>apimgt-extensions</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<version>5.0.22-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>io.entgra.device.mgt.core.apimgt.analytics.extension</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>Entgra - API mgt analytics extension</name>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/Abstract*</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-scr-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
|
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||||
|
<Bundle-Description>API Management Application Bundle</Bundle-Description>
|
||||||
|
<Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package>
|
||||||
|
<Import-Packages>
|
||||||
|
io.entgra.device.mgt.core.apimgt.analytics.extension.dto,
|
||||||
|
org.apache.velocity,
|
||||||
|
org.apache.velocity.app,
|
||||||
|
org.apache.velocity.context,
|
||||||
|
org.wso2.carbon.utils;version="[4.6,5)"
|
||||||
|
</Import-Packages>
|
||||||
|
<Export-Package>
|
||||||
|
io.entgra.device.mgt.core.apimgt.analytics.extension.*
|
||||||
|
</Export-Package>
|
||||||
|
<Embed-Dependency>
|
||||||
|
scribe;scope=compile|runtime;inline=false;
|
||||||
|
</Embed-Dependency>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>jacoco-initialize</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>jacoco-site</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
|
||||||
|
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,176 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.EventPublisherData;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.EventReceiverData;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.EventStreamData;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.MetaData;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventPublisherDeployerException;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventReceiverDeployerException;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventStreamDeployerException;
|
||||||
|
import org.apache.velocity.Template;
|
||||||
|
import org.apache.velocity.VelocityContext;
|
||||||
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
|
|
||||||
|
import org.apache.velocity.runtime.RuntimeConstants;
|
||||||
|
import org.wso2.carbon.utils.CarbonUtils;
|
||||||
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
public class AnalyticsArtifactsDeployer {
|
||||||
|
|
||||||
|
public static final String TEMPLATE_LOCATION = "repository" + File.separator + "resources" + File.separator + "iot-analytics-templates";
|
||||||
|
public static final String EVENT_STREAM_LOCATION = "eventstreams";
|
||||||
|
public static final String EVENT_PUBLISHER_LOCATION = "eventpublishers";
|
||||||
|
public static final String EVENT_RECEIVER_LOCATION = "eventreceivers";
|
||||||
|
public static final String EVENT_STREAM_TEMPLATE = TEMPLATE_LOCATION + File.separator + "event_stream.json.template";
|
||||||
|
public static final String EVENT_PUBLISHER_TEMPLATE = TEMPLATE_LOCATION + File.separator + "event_publisher.xml.template";
|
||||||
|
public static final String EVENT_RECEIVER_TEMPLATE = TEMPLATE_LOCATION + File.separator + "event_receiver.xml.template";
|
||||||
|
|
||||||
|
|
||||||
|
public void deployEventStream(EventStreamData eventStreamData, int tenantId) throws EventStreamDeployerException {
|
||||||
|
try {
|
||||||
|
VelocityEngine ve = new VelocityEngine();
|
||||||
|
ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome());
|
||||||
|
ve.init();
|
||||||
|
Template template = ve.getTemplate(EVENT_STREAM_TEMPLATE);
|
||||||
|
|
||||||
|
VelocityContext context = populateContextForEventStreams(eventStreamData);
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
template.merge(context, writer);
|
||||||
|
|
||||||
|
String fileName = eventStreamData.getName() + "_" + eventStreamData.getVersion() + ".json";
|
||||||
|
String fileLocation = null;
|
||||||
|
if (MultitenantConstants.SUPER_TENANT_ID == tenantId) {
|
||||||
|
fileLocation = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "deployment"
|
||||||
|
+ File.separator + "server" + File.separator + EVENT_STREAM_LOCATION + File.separator + fileName;
|
||||||
|
} else {
|
||||||
|
fileLocation = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator
|
||||||
|
+ EVENT_STREAM_LOCATION + File.separator + fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintWriter printWriter = new PrintWriter(fileLocation, "UTF-8");
|
||||||
|
printWriter.println(writer.toString());
|
||||||
|
printWriter.close();
|
||||||
|
} catch (FileNotFoundException | UnsupportedEncodingException e) {
|
||||||
|
throw new EventStreamDeployerException("Error while persisting event stream definition ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deployEventPublisher(EventPublisherData eventPublisherData, int tenantId) throws EventPublisherDeployerException {
|
||||||
|
try {
|
||||||
|
VelocityEngine ve = new VelocityEngine();
|
||||||
|
ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome());
|
||||||
|
ve.init();
|
||||||
|
Template template = ve.getTemplate(EVENT_PUBLISHER_TEMPLATE);
|
||||||
|
|
||||||
|
VelocityContext context = populateContextForEventPublisher(eventPublisherData);
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
template.merge(context, writer);
|
||||||
|
|
||||||
|
String fileName = eventPublisherData.getName() + ".xml";
|
||||||
|
String fileLocation = null;
|
||||||
|
if (MultitenantConstants.SUPER_TENANT_ID == tenantId) {
|
||||||
|
fileLocation = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "deployment"
|
||||||
|
+ File.separator + "server" + File.separator + EVENT_PUBLISHER_LOCATION + File.separator + fileName;
|
||||||
|
} else {
|
||||||
|
fileLocation = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator
|
||||||
|
+ EVENT_PUBLISHER_LOCATION + File.separator + fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintWriter printWriter = new PrintWriter(fileLocation, "UTF-8");
|
||||||
|
printWriter.println(writer.toString());
|
||||||
|
printWriter.close();
|
||||||
|
} catch (FileNotFoundException | UnsupportedEncodingException e) {
|
||||||
|
throw new EventPublisherDeployerException("Error while persisting rdbms event publisher ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deployEventReceiver(EventReceiverData eventReceiverData, int tenantId) throws EventReceiverDeployerException {
|
||||||
|
try {
|
||||||
|
VelocityEngine ve = new VelocityEngine();
|
||||||
|
ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome());
|
||||||
|
ve.init();
|
||||||
|
Template template = ve.getTemplate(EVENT_RECEIVER_TEMPLATE);
|
||||||
|
|
||||||
|
VelocityContext context = populateContextForEventReceiver(eventReceiverData);
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
template.merge(context, writer);
|
||||||
|
|
||||||
|
String fileName = eventReceiverData.getName() + ".xml";
|
||||||
|
String fileLocation = null;
|
||||||
|
if (MultitenantConstants.SUPER_TENANT_ID == tenantId) {
|
||||||
|
fileLocation = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "deployment"
|
||||||
|
+ File.separator + "server" + File.separator + EVENT_RECEIVER_LOCATION + File.separator + fileName;
|
||||||
|
} else {
|
||||||
|
fileLocation = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator
|
||||||
|
+ EVENT_RECEIVER_LOCATION + File.separator + fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintWriter printWriter = new PrintWriter(fileLocation, "UTF-8");
|
||||||
|
printWriter.println(writer.toString());
|
||||||
|
printWriter.close();
|
||||||
|
} catch (FileNotFoundException | UnsupportedEncodingException e) {
|
||||||
|
throw new EventReceiverDeployerException("Error while persisting oauth mqtt event receiver ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private VelocityContext populateContextForEventStreams(EventStreamData eventStreamData) {
|
||||||
|
VelocityContext context = new VelocityContext();
|
||||||
|
context.put("name", eventStreamData.getName());
|
||||||
|
context.put("version", eventStreamData.getVersion());
|
||||||
|
context.put("metaData",
|
||||||
|
eventStreamData.getMetaData() != null ? eventStreamData.getMetaData() : new MetaData("deviceId", "STRING"));
|
||||||
|
if (eventStreamData.getPayloadData() != null) {
|
||||||
|
context.put("properties", eventStreamData.getPayloadData());
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VelocityContext populateContextForEventPublisher(EventPublisherData eventPublisherData) {
|
||||||
|
VelocityContext context = new VelocityContext();
|
||||||
|
|
||||||
|
context.put("name", eventPublisherData.getName());
|
||||||
|
context.put("streamName", eventPublisherData.getStreamName());
|
||||||
|
context.put("streamVersion", eventPublisherData.getStreamVersion());
|
||||||
|
context.put("properties", eventPublisherData.getPropertyList());
|
||||||
|
context.put("eventAdapterType", eventPublisherData.getEventAdaptorType());
|
||||||
|
context.put("customMappingType", eventPublisherData.getCustomMappingType());
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VelocityContext populateContextForEventReceiver(EventReceiverData eventReceiverData) {
|
||||||
|
VelocityContext context = new VelocityContext();
|
||||||
|
|
||||||
|
context.put("name", eventReceiverData.getName());
|
||||||
|
context.put("streamName", eventReceiverData.getStreamName());
|
||||||
|
context.put("streamVersion", eventReceiverData.getStreamVersion());
|
||||||
|
context.put("properties", eventReceiverData.getPropertyList());
|
||||||
|
context.put("eventAdapterType", eventReceiverData.getEventAdapterType());
|
||||||
|
context.put("customMappingType", eventReceiverData.getCustomMappingType());
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EventPublisherData {
|
||||||
|
private String name;
|
||||||
|
private String streamVersion;
|
||||||
|
private String streamName;
|
||||||
|
|
||||||
|
private List<Property> propertyList;
|
||||||
|
|
||||||
|
private String eventAdaptorType;
|
||||||
|
|
||||||
|
private String customMappingType;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStreamVersion() {
|
||||||
|
return streamVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamVersion(String streamVersion) {
|
||||||
|
this.streamVersion = streamVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStreamName() {
|
||||||
|
return streamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamName(String streamName) {
|
||||||
|
this.streamName = streamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Property> getPropertyList() {
|
||||||
|
return propertyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPropertyList(List<Property> propertyList) {
|
||||||
|
this.propertyList = propertyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventAdaptorType() {
|
||||||
|
return eventAdaptorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventAdaptorType(String eventAdaptorType) {
|
||||||
|
this.eventAdaptorType = eventAdaptorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomMappingType() {
|
||||||
|
return customMappingType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomMappingType(String customMappingType) {
|
||||||
|
this.customMappingType = customMappingType;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EventReceiverData {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String streamVersion;
|
||||||
|
private String streamName;
|
||||||
|
|
||||||
|
private String eventAdapterType;
|
||||||
|
|
||||||
|
List<Property> propertyList;
|
||||||
|
|
||||||
|
private String customMappingType;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStreamVersion() {
|
||||||
|
return streamVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamVersion(String streamVersion) {
|
||||||
|
this.streamVersion = streamVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStreamName() {
|
||||||
|
return streamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamName(String streamName) {
|
||||||
|
this.streamName = streamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventAdapterType() {
|
||||||
|
return eventAdapterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventAdapterType(String eventAdapterType) {
|
||||||
|
this.eventAdapterType = eventAdapterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Property> getPropertyList() {
|
||||||
|
return propertyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPropertyList(List<Property> propertyList) {
|
||||||
|
this.propertyList = propertyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomMappingType() {
|
||||||
|
return customMappingType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomMappingType(String customMappingType) {
|
||||||
|
this.customMappingType = customMappingType;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EventStreamData {
|
||||||
|
private String name;
|
||||||
|
private String version;
|
||||||
|
private MetaData metaData;
|
||||||
|
private List<Property> payloadData;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaData getMetaData() {
|
||||||
|
return metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMetaData(MetaData metaData) {
|
||||||
|
this.metaData = metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Property> getPayloadData() {
|
||||||
|
return payloadData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayloadData(List<Property> payloadData) {
|
||||||
|
this.payloadData = payloadData;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.dto;
|
||||||
|
|
||||||
|
public class MetaData {
|
||||||
|
String name;
|
||||||
|
String type;
|
||||||
|
|
||||||
|
public MetaData(String name, String type){
|
||||||
|
this.setName(name);
|
||||||
|
this.setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.dto;
|
||||||
|
|
||||||
|
public class Property {
|
||||||
|
String name;
|
||||||
|
String value;
|
||||||
|
|
||||||
|
public Property(String name, String value){
|
||||||
|
this.setName(name);
|
||||||
|
this.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.exception;
|
||||||
|
|
||||||
|
public class EventPublisherDeployerException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3151279311929070299L;
|
||||||
|
|
||||||
|
public EventPublisherDeployerException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPublisherDeployerException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPublisherDeployerException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPublisherDeployerException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPublisherDeployerException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.exception;
|
||||||
|
|
||||||
|
public class EventReceiverDeployerException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3151279311929070299L;
|
||||||
|
|
||||||
|
public EventReceiverDeployerException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventReceiverDeployerException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventReceiverDeployerException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventReceiverDeployerException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventReceiverDeployerException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.apimgt.analytics.extension.exception;
|
||||||
|
|
||||||
|
public class EventStreamDeployerException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3151279311929070298L;
|
||||||
|
|
||||||
|
public EventStreamDeployerException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventStreamDeployerException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventStreamDeployerException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventStreamDeployerException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventStreamDeployerException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel(value = "DeviceConfig", description = "Device config")
|
||||||
|
public class DeviceConfig {
|
||||||
|
private String clientId;
|
||||||
|
private String clientSecret;
|
||||||
|
private String deviceId;
|
||||||
|
private String type;
|
||||||
|
private String accessToken;
|
||||||
|
private String refreshToken;
|
||||||
|
private String mqttGateway;
|
||||||
|
private String httpsGateway;
|
||||||
|
private String httpGateway;
|
||||||
|
private PlatformConfiguration platformConfiguration;
|
||||||
|
public String getClientId() {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientId(String clientId) {
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientSecret() {
|
||||||
|
return clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientSecret(String clientSecret) {
|
||||||
|
this.clientSecret = clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefreshToken() {
|
||||||
|
return refreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefreshToken(String refreshToken) {
|
||||||
|
this.refreshToken = refreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMqttGateway() {
|
||||||
|
return mqttGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMqttGateway(String mqttGateway) {
|
||||||
|
this.mqttGateway = mqttGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHttpsGateway() {
|
||||||
|
return httpsGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHttpsGateway(String httpsGateway) {
|
||||||
|
this.httpsGateway = httpsGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHttpGateway() {
|
||||||
|
return httpGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHttpGateway(String httpGateway) {
|
||||||
|
this.httpGateway = httpGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatformConfiguration getPlatformConfiguration() {
|
||||||
|
return platformConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlatformConfiguration(PlatformConfiguration platformConfiguration) {
|
||||||
|
this.platformConfiguration = platformConfiguration;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,324 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import io.swagger.annotations.Extension;
|
||||||
|
import io.swagger.annotations.ExtensionProperty;
|
||||||
|
import io.swagger.annotations.Info;
|
||||||
|
import io.swagger.annotations.ResponseHeader;
|
||||||
|
import io.swagger.annotations.SwaggerDefinition;
|
||||||
|
import io.swagger.annotations.Tag;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.apache.axis2.transport.http.HTTPConstants;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||||
|
import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata;
|
||||||
|
import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata related REST-API implementation.
|
||||||
|
*/
|
||||||
|
@SwaggerDefinition(
|
||||||
|
info = @Info(
|
||||||
|
version = "1.0.0",
|
||||||
|
title = "Whitelabel Service",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = "name", value = "WhiteLabelManagement"),
|
||||||
|
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/whitelabel"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
),
|
||||||
|
tags = {
|
||||||
|
@Tag(name = "device_management")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@Scopes(
|
||||||
|
scopes = {
|
||||||
|
@Scope(
|
||||||
|
name = "View Whitelabel",
|
||||||
|
description = "View whitelabel details",
|
||||||
|
key = "perm:whitelabel:view",
|
||||||
|
roles = {"Internal/devicemgt-user"},
|
||||||
|
permissions = {"/device-mgt/whitelabel/view"}
|
||||||
|
),
|
||||||
|
@Scope(
|
||||||
|
name = "Update Whitelabel",
|
||||||
|
description = "Updating whitelabel",
|
||||||
|
key = "perm:whitelabel:update",
|
||||||
|
roles = {"Internal/devicemgt-user"},
|
||||||
|
permissions = {"/device-mgt/whitelabel/update"}
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@Api(value = "Whitelabel Management")
|
||||||
|
@Path("/whitelabel")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public interface WhiteLabelService {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{tenantDomain}/favicon")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = HTTPConstants.HEADER_GET,
|
||||||
|
value = "Get whitelabel favicon",
|
||||||
|
notes = "Get whitelabel favicon for the tenant of the logged in user",
|
||||||
|
tags = "Tenant Metadata Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully retrieved white label favicon.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while getting white label artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response getWhiteLabelFavicon( @ApiParam(
|
||||||
|
name = "tenantDomain",
|
||||||
|
value = "The tenant domain.",
|
||||||
|
required = true) @PathParam("tenantDomain") String tenantDomain);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{tenantDomain}/logo")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = HTTPConstants.HEADER_GET,
|
||||||
|
value = "Get whitelabel logo",
|
||||||
|
notes = "Get whitelabel logo for the tenant of the logged in user",
|
||||||
|
tags = "Tenant Metadata Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully retrieved white label logo.",
|
||||||
|
response = Metadata.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while getting white label artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response getWhiteLabelLogo(
|
||||||
|
@ApiParam(
|
||||||
|
name = "tenantDomain",
|
||||||
|
value = "The tenant domain.",
|
||||||
|
required = true)
|
||||||
|
@PathParam("tenantDomain") String tenantDomain);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{tenantDomain}/icon")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = HTTPConstants.HEADER_GET,
|
||||||
|
value = "Get whitelabel logo icon",
|
||||||
|
notes = "Get whitelabel logo icon for the tenant of the logged in user",
|
||||||
|
tags = "Tenant Metadata Management"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully retrieved white label logo.",
|
||||||
|
response = Metadata.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while getting white label artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response getWhiteLabelLogoIcon( @ApiParam(
|
||||||
|
name = "tenantDomain",
|
||||||
|
value = "The tenant domain.",
|
||||||
|
required = true) @PathParam("tenantDomain") String tenantDomain);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = HTTPConstants.HEADER_POST,
|
||||||
|
value = "Create whitelabel for tenant",
|
||||||
|
notes = "Create whitelabel for the tenant of the logged in user",
|
||||||
|
tags = "Tenant Metadata Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:whitelabel:update")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully created white label theme.",
|
||||||
|
response = Metadata.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while creating white label theme.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response updateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = HTTPConstants.HEADER_POST,
|
||||||
|
value = "Get whitelabel for tenant",
|
||||||
|
notes = "Get whitelabel for the tenant of the logged in user",
|
||||||
|
tags = "Tenant Metadata Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:whitelabel:view")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched white label theme.",
|
||||||
|
response = Metadata.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while fetching white label theme.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response getWhiteLabelTheme();
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/reset")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = HTTPConstants.HEADER_POST,
|
||||||
|
value = "Reset whitelabel for tenant",
|
||||||
|
notes = "Reset whitelabel to default for the tenant of the logged in user",
|
||||||
|
tags = "Tenant Metadata Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:whitelabel:update")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched white label theme.",
|
||||||
|
response = Metadata.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. " +
|
||||||
|
"\n Server error occurred while deleting white label theme.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response resetWhiteLabel();
|
||||||
|
}
|
@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.FileResponse;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme;
|
||||||
|
import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.WhiteLabelService;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the service class for metadata management.
|
||||||
|
*/
|
||||||
|
@Path("/whitelabel")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class WhiteLabelServiceImpl implements WhiteLabelService {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(WhiteLabelServiceImpl.class);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Override
|
||||||
|
@Path("/{tenantDomain}/favicon")
|
||||||
|
public Response getWhiteLabelFavicon(@PathParam("tenantDomain") String tenantDomain) {
|
||||||
|
try {
|
||||||
|
FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(tenantDomain);
|
||||||
|
return sendFileStream(fileResponse);
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg = "Favicon white label image cannot be found in the system. Uploading the favicon white label image again might help solve the issue.";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (MetadataManagementException e) {
|
||||||
|
String msg = "Error occurred while getting favicon";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Override
|
||||||
|
@Path("/{tenantDomain}/logo")
|
||||||
|
public Response getWhiteLabelLogo(@PathParam("tenantDomain") String tenantDomain) {
|
||||||
|
try {
|
||||||
|
FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(tenantDomain);
|
||||||
|
return sendFileStream(fileResponse);
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg = "Logo white label image cannot be found in the system. Uploading the logo white label image again might help solve the issue.";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (MetadataManagementException e) {
|
||||||
|
String msg = "Error occurred while getting logo";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Override
|
||||||
|
@Path("/{tenantDomain}/icon")
|
||||||
|
public Response getWhiteLabelLogoIcon(@PathParam("tenantDomain") String tenantDomain) {
|
||||||
|
try {
|
||||||
|
FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogoIcon(tenantDomain);
|
||||||
|
return sendFileStream(fileResponse);
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg = "Icon white label image cannot be found in the system. Uploading the icon white label image again might help solve the issue.";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (MetadataManagementException e) {
|
||||||
|
String msg = "Error occurred while getting logo";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Override
|
||||||
|
public Response updateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) {
|
||||||
|
RequestValidationUtil.validateWhiteLabelTheme(whiteLabelThemeCreateRequest);
|
||||||
|
try {
|
||||||
|
WhiteLabelTheme createdWhiteLabelTheme = DeviceMgtAPIUtils.getWhiteLabelManagementService().updateWhiteLabelTheme(whiteLabelThemeCreateRequest);
|
||||||
|
return Response.status(Response.Status.CREATED).entity(createdWhiteLabelTheme).build();
|
||||||
|
} catch (MetadataManagementException e) {
|
||||||
|
String msg = "Error occurred while creating whitelabel for tenant";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Override
|
||||||
|
public Response getWhiteLabelTheme() {
|
||||||
|
try {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
WhiteLabelTheme whiteLabelTheme = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelTheme(tenantDomain);
|
||||||
|
return Response.status(Response.Status.CREATED).entity(whiteLabelTheme).build();
|
||||||
|
} catch (MetadataManagementException e) {
|
||||||
|
String msg = "Error occurred while deleting whitelabel for tenant";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg = "Not white label theme configured for this tenant";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while retrieving tenant details of whitelabel";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Override
|
||||||
|
@Path("/reset")
|
||||||
|
public Response resetWhiteLabel() {
|
||||||
|
try {
|
||||||
|
DeviceMgtAPIUtils.getWhiteLabelManagementService().resetToDefaultWhiteLabelTheme();
|
||||||
|
return Response.status(Response.Status.CREATED).entity("White label theme deleted successfully.").build();
|
||||||
|
} catch (MetadataManagementException e) {
|
||||||
|
String msg = "Error occurred while resetting whitelabel for tenant";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Useful to send file responses
|
||||||
|
*/
|
||||||
|
private Response sendFileStream(FileResponse fileResponse) {
|
||||||
|
try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(fileResponse.getFileContent())) {
|
||||||
|
Response.ResponseBuilder response = Response
|
||||||
|
.ok(binaryDuplicate, fileResponse.getMimeType());
|
||||||
|
response.status(Response.Status.OK);
|
||||||
|
response.header("Content-Length", fileResponse.getFileContent().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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.common;
|
||||||
|
|
||||||
|
public class FileResponse {
|
||||||
|
private static final String DEFAULT_MIME_TYPE = "application/octet-stream";
|
||||||
|
private byte[] fileContent;
|
||||||
|
private String mimeType;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public byte[] getFileContent() {
|
||||||
|
return fileContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileContent(byte[] fileContent) {
|
||||||
|
this.fileContent = fileContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeType() {
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMimeType(String mimeType) {
|
||||||
|
this.mimeType = mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ImageExtension {
|
||||||
|
SVG() {
|
||||||
|
@Override
|
||||||
|
public String mimeType() {
|
||||||
|
return "image/svg+xml";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PNG,
|
||||||
|
JPG,
|
||||||
|
JPEG,
|
||||||
|
GIF;
|
||||||
|
|
||||||
|
public String mimeType() {
|
||||||
|
return DEFAULT_MIME_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String mimeTypeOf(String extension) {
|
||||||
|
if (extension.isEmpty()) {
|
||||||
|
return DEFAULT_MIME_TYPE;
|
||||||
|
}
|
||||||
|
ImageExtension imageExtension = ImageExtension.valueOf(extension.toUpperCase());
|
||||||
|
return imageExtension.mimeType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.name().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Entgra (pvt) Ltd. (http://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 org.wso2.carbon.device.mgt.common.exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This exception will be thrown when the requested application or platform not found.
|
||||||
|
*/
|
||||||
|
public class NotFoundException extends Exception {
|
||||||
|
|
||||||
|
public NotFoundException(String message, Throwable throwable) {
|
||||||
|
super(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotFoundException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.common.metadata.mgt;
|
||||||
|
|
||||||
|
public class WhiteLabelArtifactPath {
|
||||||
|
private String faviconPath;
|
||||||
|
private String logoPath;
|
||||||
|
private String logoIconPath;
|
||||||
|
|
||||||
|
public WhiteLabelArtifactPath() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteLabelArtifactPath(String faviconPath, String logoPath, String logoIconPath) {
|
||||||
|
this.faviconPath = faviconPath;
|
||||||
|
this.logoPath = logoPath;
|
||||||
|
this.logoIconPath = logoIconPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFaviconPath() {
|
||||||
|
return faviconPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaviconPath(String faviconPath) {
|
||||||
|
this.faviconPath = faviconPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogoPath() {
|
||||||
|
return logoPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogoPath(String logoPath) {
|
||||||
|
this.logoPath = logoPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogoIconPath() {
|
||||||
|
return logoIconPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogoIconPath(String logoIconPath) {
|
||||||
|
this.logoIconPath = logoIconPath;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Entgra (pvt) Ltd. (http://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 org.wso2.carbon.device.mgt.common.metadata.mgt;
|
||||||
|
|
||||||
|
public class WhiteLabelImage {
|
||||||
|
private ImageLocationType imageLocationType;
|
||||||
|
private String imageLocation;
|
||||||
|
|
||||||
|
public ImageLocationType getImageLocationType() {
|
||||||
|
return imageLocationType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageLocationType(ImageLocationType imageLocationType) {
|
||||||
|
this.imageLocationType = imageLocationType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageLocation() {
|
||||||
|
return imageLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageLocation(String imageLocation) {
|
||||||
|
this.imageLocation = imageLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ImageName {
|
||||||
|
FAVICON,
|
||||||
|
LOGO,
|
||||||
|
LOGO_ICON;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ImageLocationType {
|
||||||
|
URL,
|
||||||
|
CUSTOM_FILE,
|
||||||
|
DEFAULT_FILE
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Entgra (pvt) Ltd. (http://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 org.wso2.carbon.device.mgt.common.metadata.mgt;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Base64File;
|
||||||
|
|
||||||
|
public class WhiteLabelImageRequestPayload {
|
||||||
|
private ImageType imageType;
|
||||||
|
private JsonElement image;
|
||||||
|
|
||||||
|
public ImageType getImageType() {
|
||||||
|
return imageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageType(ImageType imageType) {
|
||||||
|
this.imageType = imageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Base64File getImageAsBase64File() {
|
||||||
|
if (imageType != ImageType.BASE64) {
|
||||||
|
throw new IllegalStateException("Cannot convert image with Image type of " + imageType + " to base64.");
|
||||||
|
}
|
||||||
|
return new Gson().fromJson(image, Base64File.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageAsUrl() {
|
||||||
|
if (imageType != ImageType.URL) {
|
||||||
|
throw new IllegalStateException("Cannot convert image with Image type of " + imageType + " to image url string.");
|
||||||
|
}
|
||||||
|
return new Gson().fromJson(image, String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(JsonElement image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ImageType {
|
||||||
|
URL,
|
||||||
|
BASE64;
|
||||||
|
|
||||||
|
public WhiteLabelImage.ImageLocationType getDTOImageLocationType() {
|
||||||
|
if (this == URL) {
|
||||||
|
return WhiteLabelImage.ImageLocationType.URL;
|
||||||
|
}
|
||||||
|
return WhiteLabelImage.ImageLocationType.CUSTOM_FILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.common.metadata.mgt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.FileResponse;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the contract of WhiteLabelManagementService.
|
||||||
|
*/
|
||||||
|
public interface WhiteLabelManagementService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to get byte content of favicon whitelabel image
|
||||||
|
* @return byte content of favicon
|
||||||
|
* @throws MetadataManagementException if error occurred while retrieving favicon
|
||||||
|
* @throws NotFoundException if favicon is not found
|
||||||
|
*/
|
||||||
|
FileResponse getWhiteLabelFavicon(String tenantDomain) throws
|
||||||
|
MetadataManagementException, NotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to get byte content of logo whitelabel image
|
||||||
|
* @return byte content of logo
|
||||||
|
* @throws MetadataManagementException if error occurred while retrieving logo
|
||||||
|
* @throws NotFoundException if logo is not found
|
||||||
|
*/
|
||||||
|
FileResponse getWhiteLabelLogo(String tenantDomain) throws
|
||||||
|
MetadataManagementException, NotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to get byte content of logo icon whitelabel image
|
||||||
|
* @return byte content of logo icon
|
||||||
|
* @throws MetadataManagementException if error occurred while retrieving logo icon
|
||||||
|
* @throws NotFoundException if logo icon is not found
|
||||||
|
*/
|
||||||
|
FileResponse getWhiteLabelLogoIcon(String tenantDomain) throws
|
||||||
|
MetadataManagementException, NotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is useful to create & persist default white label theme for provided tenant if
|
||||||
|
* it doesn't exist already
|
||||||
|
* @throws MetadataManagementException if error while adding default white label theme
|
||||||
|
*/
|
||||||
|
void addDefaultWhiteLabelThemeIfNotExist(int tenantId) throws MetadataManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is useful to reset existing white label to default whitelabel
|
||||||
|
* @throws MetadataManagementException if error while resetting default white label theme
|
||||||
|
*/
|
||||||
|
void resetToDefaultWhiteLabelTheme() throws MetadataManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is useful to update existing white label theme
|
||||||
|
* @throws MetadataManagementException if error while updating existing white label theme
|
||||||
|
*/
|
||||||
|
WhiteLabelTheme updateWhiteLabelTheme(WhiteLabelThemeCreateRequest createWhiteLabelTheme)
|
||||||
|
throws MetadataManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is useful to get existing white label theme
|
||||||
|
* @throws MetadataManagementException if error while getting existing white label theme
|
||||||
|
*/
|
||||||
|
WhiteLabelTheme getWhiteLabelTheme(String tenantDomain) throws MetadataManagementException, NotFoundException, DeviceManagementException;
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.common.metadata.mgt;
|
||||||
|
|
||||||
|
public class WhiteLabelTheme {
|
||||||
|
private WhiteLabelImage faviconImage;
|
||||||
|
private WhiteLabelImage logoImage;
|
||||||
|
private WhiteLabelImage logoIconImage;
|
||||||
|
private String footerText;
|
||||||
|
private String appTitle;
|
||||||
|
|
||||||
|
public String getFooterText() {
|
||||||
|
return footerText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFooterText(String footerText) {
|
||||||
|
this.footerText = footerText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteLabelImage getFaviconImage() {
|
||||||
|
return faviconImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaviconImage(WhiteLabelImage faviconImage) {
|
||||||
|
this.faviconImage = faviconImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteLabelImage getLogoImage() {
|
||||||
|
return logoImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogoImage(WhiteLabelImage logoImage) {
|
||||||
|
this.logoImage = logoImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppTitle() {
|
||||||
|
return appTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppTitle(String appTitle) {
|
||||||
|
this.appTitle = appTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteLabelImage getLogoIconImage() {
|
||||||
|
return logoIconImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogoIconImage(WhiteLabelImage logoIconImage) {
|
||||||
|
this.logoIconImage = logoIconImage;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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 org.wso2.carbon.device.mgt.common.metadata.mgt;
|
||||||
|
|
||||||
|
public class WhiteLabelThemeCreateRequest {
|
||||||
|
private WhiteLabelImageRequestPayload favicon;
|
||||||
|
private WhiteLabelImageRequestPayload logo;
|
||||||
|
private WhiteLabelImageRequestPayload logoIcon;
|
||||||
|
private String footerText;
|
||||||
|
private String appTitle;
|
||||||
|
|
||||||
|
public WhiteLabelImageRequestPayload getFavicon() {
|
||||||
|
return favicon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFavicon(WhiteLabelImageRequestPayload favicon) {
|
||||||
|
this.favicon = favicon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteLabelImageRequestPayload getLogo() {
|
||||||
|
return logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogo(WhiteLabelImageRequestPayload logo) {
|
||||||
|
this.logo = logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFooterText() {
|
||||||
|
return footerText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFooterText(String footerText) {
|
||||||
|
this.footerText = footerText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppTitle() {
|
||||||
|
return appTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppTitle(String appTitle) {
|
||||||
|
this.appTitle = appTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteLabelImageRequestPayload getLogoIcon() {
|
||||||
|
return logoIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogoIcon(WhiteLabelImageRequestPayload logoIcon) {
|
||||||
|
this.logoIcon = logoIcon;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/* Copyright (c) 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 org.wso2.carbon.device.mgt.core.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the exception thrown during storing and retrieving the artifacts.
|
||||||
|
*/
|
||||||
|
public class StorageManagementException extends Exception {
|
||||||
|
public StorageManagementException(String message, Throwable ex) {
|
||||||
|
super(message, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorageManagementException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue