mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Sync with master branch
This commit is contained in:
commit
635da5c18a
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>grafana-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>grafana-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>grafana-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>analytics-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -856,7 +856,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
ApplicationArtifact applicationArtifact, int tenantId) throws ResourceManagementException {
|
||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||
|
||||
applicationReleaseDTO.setIconName(applicationArtifact.getIconName());
|
||||
applicationReleaseDTO.setIconName(ApplicationManagementUtil.sanitizeName
|
||||
(applicationArtifact.getIconName(), Constants.ICON_NAME));
|
||||
applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName());
|
||||
|
||||
Map<String, InputStream> screenshots = applicationArtifact.getScreenshots();
|
||||
@ -865,11 +866,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
int counter = 1;
|
||||
for (String scName : screenshotNames) {
|
||||
if (counter == 1) {
|
||||
applicationReleaseDTO.setScreenshotName1(scName);
|
||||
applicationReleaseDTO.setScreenshotName1(ApplicationManagementUtil.sanitizeName
|
||||
(scName, Constants.SCREENSHOT_NAME + counter));
|
||||
} else if (counter == 2) {
|
||||
applicationReleaseDTO.setScreenshotName2(scName);
|
||||
applicationReleaseDTO.setScreenshotName2(ApplicationManagementUtil.sanitizeName
|
||||
(scName, Constants.SCREENSHOT_NAME + counter));
|
||||
} else if (counter == 3) {
|
||||
applicationReleaseDTO.setScreenshotName3(scName);
|
||||
applicationReleaseDTO.setScreenshotName3(ApplicationManagementUtil.sanitizeName
|
||||
(scName, Constants.SCREENSHOT_NAME + counter));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
@ -897,7 +901,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
applicationStorageManager
|
||||
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.ICON_ARTIFACT,
|
||||
applicationReleaseDTO.getIconName(), tenantId);
|
||||
applicationReleaseDTO.setIconName(applicationArtifact.getIconName());
|
||||
applicationReleaseDTO.setIconName(ApplicationManagementUtil.sanitizeName
|
||||
(applicationArtifact.getIconName(), Constants.ICON_NAME));
|
||||
}
|
||||
if (!StringUtils.isEmpty(applicationArtifact.getBannerName())){
|
||||
applicationStorageManager
|
||||
@ -920,17 +925,20 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
applicationStorageManager
|
||||
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
|
||||
applicationReleaseDTO.getScreenshotName1(), tenantId);
|
||||
applicationReleaseDTO.setScreenshotName1(scName);
|
||||
applicationReleaseDTO.setScreenshotName1(ApplicationManagementUtil.sanitizeName
|
||||
(scName, Constants.SCREENSHOT_NAME + counter));
|
||||
} else if (counter == 2) {
|
||||
applicationStorageManager
|
||||
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
|
||||
applicationReleaseDTO.getScreenshotName2(), tenantId);
|
||||
applicationReleaseDTO.setScreenshotName2(scName);
|
||||
applicationReleaseDTO.setScreenshotName2(ApplicationManagementUtil.sanitizeName
|
||||
(scName, Constants.SCREENSHOT_NAME + counter));
|
||||
} else if (counter == 3) {
|
||||
applicationStorageManager
|
||||
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
|
||||
applicationReleaseDTO.getScreenshotName3(), tenantId);
|
||||
applicationReleaseDTO.setScreenshotName3(scName);
|
||||
applicationReleaseDTO.setScreenshotName3(ApplicationManagementUtil.sanitizeName
|
||||
(scName, Constants.SCREENSHOT_NAME + counter));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
@ -2426,7 +2434,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
}
|
||||
applicationDTO.setName(applicationUpdateWrapper.getName());
|
||||
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
|
||||
Constants.ApplicationProperties.NAME));
|
||||
}
|
||||
if (!StringUtils.isEmpty(applicationUpdateWrapper.getSubMethod()) && !applicationDTO.getSubType()
|
||||
.equals(applicationUpdateWrapper.getSubMethod())) {
|
||||
|
||||
@ -59,4 +59,5 @@ public class ScheduledAppSubscriptionCleanupTask extends RandomlyAssignedSchedul
|
||||
public String getTaskName() {
|
||||
return TASK_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -145,4 +145,5 @@ public class ScheduledAppSubscriptionTask extends RandomlyAssignedScheduleTask {
|
||||
public String getTaskName() {
|
||||
return TASK_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -302,7 +302,8 @@ public class APIUtil {
|
||||
if (param instanceof ApplicationWrapper){
|
||||
ApplicationWrapper applicationWrapper = (ApplicationWrapper) param;
|
||||
DeviceType deviceType = getDeviceTypeData(applicationWrapper.getDeviceType());
|
||||
applicationDTO.setName(applicationWrapper.getName());
|
||||
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(applicationWrapper.getName(),
|
||||
Constants.ApplicationProperties.NAME));
|
||||
applicationDTO.setDescription(applicationWrapper.getDescription());
|
||||
applicationDTO.setAppCategories(applicationWrapper.getCategories());
|
||||
applicationDTO.setType(ApplicationType.ENTERPRISE.toString());
|
||||
@ -316,7 +317,8 @@ public class APIUtil {
|
||||
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
|
||||
} else if (param instanceof WebAppWrapper){
|
||||
WebAppWrapper webAppWrapper = (WebAppWrapper) param;
|
||||
applicationDTO.setName(webAppWrapper.getName());
|
||||
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(webAppWrapper.getName(),
|
||||
Constants.ApplicationProperties.NAME));
|
||||
applicationDTO.setDescription(webAppWrapper.getDescription());
|
||||
applicationDTO.setAppCategories(webAppWrapper.getCategories());
|
||||
applicationDTO.setSubType(webAppWrapper.getSubMethod());
|
||||
@ -330,7 +332,8 @@ public class APIUtil {
|
||||
} else if (param instanceof PublicAppWrapper) {
|
||||
PublicAppWrapper publicAppWrapper = (PublicAppWrapper) param;
|
||||
DeviceType deviceType = getDeviceTypeData(publicAppWrapper.getDeviceType());
|
||||
applicationDTO.setName(publicAppWrapper.getName());
|
||||
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(publicAppWrapper.getName(),
|
||||
Constants.ApplicationProperties.NAME));
|
||||
applicationDTO.setDescription(publicAppWrapper.getDescription());
|
||||
applicationDTO.setAppCategories(publicAppWrapper.getCategories());
|
||||
applicationDTO.setType(ApplicationType.PUBLIC.toString());
|
||||
@ -345,7 +348,8 @@ public class APIUtil {
|
||||
} else if (param instanceof CustomAppWrapper){
|
||||
CustomAppWrapper customAppWrapper = (CustomAppWrapper) param;
|
||||
DeviceType deviceType = getDeviceTypeData(customAppWrapper.getDeviceType());
|
||||
applicationDTO.setName(customAppWrapper.getName());
|
||||
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(customAppWrapper.getName(),
|
||||
Constants.ApplicationProperties.NAME));
|
||||
applicationDTO.setDescription(customAppWrapper.getDescription());
|
||||
applicationDTO.setAppCategories(customAppWrapper.getCategories());
|
||||
applicationDTO.setType(ApplicationType.CUSTOM.toString());
|
||||
|
||||
@ -537,4 +537,29 @@ public class ApplicationManagementUtil {
|
||||
packageNamesOfApps.add(adamId);
|
||||
return applicationManager.getApplications(packageNamesOfApps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize app names and shorten icon/screenshot file names
|
||||
*
|
||||
* @param originalName Original name of the file which is being uploaded
|
||||
* @param type Type - Name/Artifact(Icon, Screenshot, etc.)
|
||||
* @return Sanitized and shortened file name
|
||||
*/
|
||||
public static String sanitizeName(String originalName, String type) {
|
||||
String sanitizedName = originalName.replaceAll(Constants.APP_NAME_REGEX, "");
|
||||
if (Constants.ApplicationProperties.NAME.equals(type) && sanitizedName.length() > Constants.MAX_APP_NAME_CHARACTERS) {
|
||||
sanitizedName = sanitizedName.substring(0, Constants.MAX_APP_NAME_CHARACTERS);
|
||||
return sanitizedName;
|
||||
} else if (Constants.ICON_NAME.equals(type) || Constants.SCREENSHOT_NAME.equals(type)) {
|
||||
// Shortening icon/screenshot names
|
||||
String fileExtension = "";
|
||||
int dotIndex = originalName.lastIndexOf('.');
|
||||
if (dotIndex >= 0) {
|
||||
fileExtension = originalName.substring(dotIndex);
|
||||
}
|
||||
return type + fileExtension;
|
||||
} else {
|
||||
return sanitizedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,4 +217,10 @@ public class Constants {
|
||||
public static final String ASSOCIATION_DEVICE = "ASSOCIATION_DEVICE";
|
||||
public static final String ASSOCIATION_USER = "ASSOCIATION_USER";
|
||||
}
|
||||
|
||||
/**
|
||||
* App name sanitization related constants
|
||||
*/
|
||||
public static final int MAX_APP_NAME_CHARACTERS = 350;
|
||||
public static final String APP_NAME_REGEX = "[^a-zA-Z0-9.\\s-]";
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -18,13 +18,11 @@
|
||||
~
|
||||
-->
|
||||
|
||||
<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">
|
||||
<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>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>cea-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>cea-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>cea-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>cea-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -346,14 +346,14 @@ public interface DeviceOrganizationMgtService {
|
||||
Response getDeviceOrganizationLeafs(
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "The starting pagination index for the complete list of qualified items",
|
||||
value = "leaf node offset",
|
||||
required = false,
|
||||
defaultValue = "0")
|
||||
@DefaultValue("0") @QueryParam("offset")
|
||||
int offset,
|
||||
@ApiParam(
|
||||
name = "limit",
|
||||
value = "Provide how many policy details you require from the starting pagination index/offset.",
|
||||
value = "leaf node limit",
|
||||
required = false,
|
||||
defaultValue = "5")
|
||||
@DefaultValue("20") @QueryParam("limit")
|
||||
@ -369,8 +369,8 @@ public interface DeviceOrganizationMgtService {
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Retrieve leaf Device Organizations",
|
||||
notes = "Get a list of leaf device organizations.",
|
||||
value = "Retrieve root Device Organizations",
|
||||
notes = "Get a list of root device organizations.",
|
||||
tags = "Device Organization Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ -414,19 +414,97 @@ public interface DeviceOrganizationMgtService {
|
||||
Response getDeviceOrganizationRoots(
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "The starting pagination index for the complete list of qualified items",
|
||||
value = "root node offset",
|
||||
required = false,
|
||||
defaultValue = "0")
|
||||
@DefaultValue("0") @QueryParam("offset")
|
||||
int offset,
|
||||
@ApiParam(
|
||||
name = "limit",
|
||||
value = "Provide how many policy details you require from the starting pagination index/offset.",
|
||||
value = "root node limit",
|
||||
required = false,
|
||||
defaultValue = "5")
|
||||
defaultValue = "20")
|
||||
@DefaultValue("20") @QueryParam("limit")
|
||||
int limit);
|
||||
|
||||
/**
|
||||
* Retrieves a list of root device organizations.
|
||||
*
|
||||
* @return A response containing a list of root device organizations.
|
||||
*/
|
||||
@GET
|
||||
@Path("roots/children")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Retrieve children for root Device Organizations",
|
||||
notes = "Get a list of children for root device organizations.",
|
||||
tags = "Device Organization Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = SCOPE, value = "dm:device-org:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the all devices.",
|
||||
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 = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response getDeviceOrganizationChildrenForRoots(
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "root offset",
|
||||
required = false,
|
||||
defaultValue = "0")
|
||||
@DefaultValue("0") @QueryParam("offset")
|
||||
int offset,
|
||||
@ApiParam(
|
||||
name = "limit",
|
||||
value = "root limit.",
|
||||
required = false,
|
||||
defaultValue = "20")
|
||||
@DefaultValue("20") @QueryParam("limit")
|
||||
int limit,
|
||||
@ApiParam(
|
||||
name= "maxDepth",
|
||||
value = "The maximum depth of child nodes to retrieve for each root.",
|
||||
required = true) @QueryParam("maxDepth")
|
||||
int maxDepth,
|
||||
@ApiParam(
|
||||
name= "includeDevice",
|
||||
value = "Indicates whether to include device information in the retrieved child nodes.",
|
||||
required = true) @QueryParam("includeDevice")
|
||||
boolean includeDevice);
|
||||
|
||||
/**
|
||||
* Retrieves a specific device organization by its organization ID.
|
||||
*
|
||||
|
||||
@ -24,6 +24,7 @@ import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.u
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNodeResult;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.PaginationRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.RootChildrenRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.DeviceOrganizationMgtPluginException;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.spi.DeviceOrganizationService;
|
||||
import org.apache.commons.logging.Log;
|
||||
@ -124,6 +125,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
|
||||
@DefaultValue("20") @QueryParam("limit") int limit) {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
try {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService();
|
||||
PaginationRequest request = new PaginationRequest(offset, limit);
|
||||
List<DeviceOrganization> organizations = deviceOrganizationService.getDeviceOrganizationLeafs(request);
|
||||
@ -143,6 +145,7 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
|
||||
@DefaultValue("20") @QueryParam("limit") int limit) {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
try {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService();
|
||||
PaginationRequest request = new PaginationRequest(offset, limit);
|
||||
List<DeviceOrganization> organizations = deviceOrganizationService.getDeviceOrganizationRoots(request);
|
||||
@ -154,6 +157,30 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("roots/children")
|
||||
@Override
|
||||
public Response getDeviceOrganizationChildrenForRoots(
|
||||
@DefaultValue("0") @QueryParam("offset") int offset,
|
||||
@DefaultValue("20") @QueryParam("limit") int limit,
|
||||
@QueryParam("maxDepth") int maxDepth,
|
||||
@QueryParam("includeDevice") boolean includeDevice) {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
try {
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService();
|
||||
RootChildrenRequest request = new RootChildrenRequest(offset, limit);
|
||||
request.setMaxDepth(maxDepth);
|
||||
request.setIncludeDevice(includeDevice);
|
||||
List<DeviceNodeResult> nodeResultList = deviceOrganizationService.getAllDeviceOrganizationsForRoots(request);
|
||||
return Response.status(Response.Status.OK).entity(nodeResultList).build();
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
String errorMessage = "get children for root organizations failed";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Override
|
||||
@Path("{organizationId}")
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto;
|
||||
|
||||
public class AdditionResult {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto;
|
||||
|
||||
public class RootChildrenRequest extends PaginationRequest{
|
||||
|
||||
int maxDepth;
|
||||
boolean includeDevice;
|
||||
|
||||
public RootChildrenRequest(int start, int limit) {
|
||||
super(start, limit);
|
||||
}
|
||||
|
||||
public int getMaxDepth() {
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
public void setMaxDepth(int maxDepth) {
|
||||
if (maxDepth < 0) {
|
||||
throw new IllegalArgumentException("maxDepth cannot be negative");
|
||||
}
|
||||
this.maxDepth = maxDepth;
|
||||
}
|
||||
|
||||
public boolean isIncludeDevice() {
|
||||
return includeDevice;
|
||||
}
|
||||
|
||||
public void setIncludeDevice(boolean includeDevice) {
|
||||
this.includeDevice = includeDevice;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
@ -20,10 +20,11 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.impl
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dao.DeviceOrganizationDAO;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dao.DeviceOrganizationDAOFactory;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dao.util.ConnectionManagerUtil;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.AdditionResult;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNodeResult;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.PaginationRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.RootChildrenRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.AdditionResult;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.BadRequestException;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.DBConnectionException;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.DeviceOrganizationMgtDAOException;
|
||||
@ -33,7 +34,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceOrganizationServiceImpl implements DeviceOrganizationService {
|
||||
@ -164,6 +165,34 @@ public class DeviceOrganizationServiceImpl implements DeviceOrganizationService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceNodeResult> getAllDeviceOrganizationsForRoots(RootChildrenRequest request) throws DeviceOrganizationMgtPluginException {
|
||||
List<DeviceNodeResult> allDeviceOrganizations = new ArrayList<>();
|
||||
|
||||
try {
|
||||
// Get all root device organizations
|
||||
PaginationRequest paginationRequest = new PaginationRequest(request.getOffSet(), request.getLimit());
|
||||
List<DeviceOrganization> roots = getDeviceOrganizationRoots(paginationRequest);
|
||||
|
||||
// Iterate over each root and fetch its children
|
||||
for (DeviceOrganization root : roots) {
|
||||
DeviceNodeResult childrenResult = getChildrenOfDeviceNode(root.getDeviceId(), request.getMaxDepth(), request.isIncludeDevice());
|
||||
if (childrenResult != null) {
|
||||
allDeviceOrganizations.add(childrenResult);
|
||||
}
|
||||
}
|
||||
return allDeviceOrganizations;
|
||||
} catch (DeviceOrganizationMgtPluginException e) {
|
||||
String msg = "Error occurred while retrieving all device organizations for roots.";
|
||||
log.error(msg, e);
|
||||
throw new DeviceOrganizationMgtPluginException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.spi;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNodeResult;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.PaginationRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.RootChildrenRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.DeviceOrganizationMgtPluginException;
|
||||
|
||||
import java.util.List;
|
||||
@ -71,6 +72,15 @@ public interface DeviceOrganizationService {
|
||||
*/
|
||||
List<DeviceOrganization> getAllDeviceOrganizations() throws DeviceOrganizationMgtPluginException;
|
||||
|
||||
/**
|
||||
* Retrieves a list of all device organizations for roots.
|
||||
* @param request
|
||||
* @return
|
||||
* @throws DeviceOrganizationMgtPluginException
|
||||
*/
|
||||
List<DeviceNodeResult> getAllDeviceOrganizationsForRoots(RootChildrenRequest request)
|
||||
throws DeviceOrganizationMgtPluginException;
|
||||
|
||||
/**
|
||||
* Retrieves device Organization Leafs
|
||||
*
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dao.D
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNodeResult;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceOrganization;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.PaginationRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.RootChildrenRequest;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.exception.DeviceOrganizationMgtPluginException;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.impl.DeviceOrganizationServiceImpl;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.mock.BaseDeviceOrganizationTest;
|
||||
@ -285,6 +286,21 @@ public class ServiceTest extends BaseDeviceOrganizationTest {
|
||||
Assert.assertFalse(organizations.isEmpty(), "List of organizations should not be empty");
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testAddDeviceOrganizationWithNullParent")
|
||||
public void testGetAllOrganizationsForRoots() throws DeviceOrganizationMgtPluginException {
|
||||
|
||||
int offSet = 0;
|
||||
int limit = 100;
|
||||
boolean includeDevice = true;
|
||||
int maxDepth =100;
|
||||
RootChildrenRequest request = new RootChildrenRequest(offSet, limit);
|
||||
request.setMaxDepth(maxDepth);
|
||||
request.setIncludeDevice(includeDevice);
|
||||
List<DeviceNodeResult> nodeResultList = deviceOrganizationService.getAllDeviceOrganizationsForRoots(request);
|
||||
Assert.assertNotNull(nodeResultList, "Cannot be null");
|
||||
Assert.assertFalse(nodeResultList.isEmpty(), "List of node result should not be empty");
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testAddDeviceOrganizationWithNullParent")
|
||||
public void testGetRootOrganizations() throws DeviceOrganizationMgtPluginException {
|
||||
int offset = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
* Copyright (c) 2018 - 2024, 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
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -81,12 +81,17 @@
|
||||
<Bundle-Description>Device Management Core Bundle</Bundle-Description>
|
||||
<Private-Package>io.entgra.device.mgt.core.device.mgt.core.internal</Private-Package>
|
||||
<Import-Package>
|
||||
com.fasterxml.jackson.databind;version="[2.13,3)",
|
||||
com.fasterxml.jackson.databind;version="[2.14,3)",
|
||||
com.google.common.collect;version="[31.0,32)",
|
||||
com.google.common.reflect;version="[31.0,32)",
|
||||
com.google.gson;version="[2.9,3)",
|
||||
com.google.gson.reflect;version="[2.9,3)",
|
||||
io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.util;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="[5.0,6)",
|
||||
@ -138,6 +143,7 @@
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.keymanager,
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.license,
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt,
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation,
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel,
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout,
|
||||
io.entgra.device.mgt.core.device.mgt.core.config.pagination,
|
||||
@ -197,6 +203,7 @@
|
||||
io.entgra.device.mgt.core.device.mgt.core.traccar.common.config,
|
||||
io.entgra.device.mgt.core.device.mgt.core.traccar.common.util,
|
||||
io.entgra.device.mgt.core.device.mgt.core.traccar.core.config,
|
||||
io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)",
|
||||
@ -208,9 +215,14 @@
|
||||
io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.transport.mgt.email.sender.core;version="[5.0,6)",
|
||||
io.entgra.device.mgt.core.transport.mgt.email.sender.core.service;version="[5.0,6)",
|
||||
io.swagger.annotations;version="[1.6,2)",javax.cache;version="[1.0,2)",
|
||||
javax.naming,javax.net.ssl,javax.servlet;version="[2.6,3)",
|
||||
javax.sql,javax.ws.rs,javax.xml.bind;version="[0.0,1)",
|
||||
io.swagger.annotations;version="[1.6,2)",
|
||||
javax.cache;version="[1.0,2)",
|
||||
javax.naming,
|
||||
javax.net.ssl,
|
||||
javax.servlet;version="[2.6,3)",
|
||||
javax.sql,
|
||||
javax.ws.rs,
|
||||
javax.xml.bind;version="[0.0,1)",
|
||||
javax.xml.bind.annotation;version="[0.0,1)",
|
||||
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}",
|
||||
javax.xml.stream;version="[1.0,2)",
|
||||
@ -228,7 +240,7 @@
|
||||
org.apache.commons.httpclient.protocol;version="[3.1,4)",
|
||||
org.apache.commons.io;version="[2.0,3)",
|
||||
org.apache.commons.lang;version="[2.6,3)",
|
||||
org.apache.commons.lang3;version="[3.1,4)",
|
||||
org.apache.commons.lang3;version="[3.11,4)",
|
||||
org.apache.commons.logging;version="[1.2,2)",
|
||||
org.apache.commons.validator.routines;version="[1.7,2)",
|
||||
org.apache.http;version="[4.4,5)",
|
||||
@ -242,28 +254,27 @@
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.scannotation;version="[1.0,2)",
|
||||
org.scannotation.archiveiterator;version="[1.0,2)",
|
||||
org.w3c.dom,
|
||||
org.wso2.carbon.base,
|
||||
<!-- org.wso2.carbon.base;version="[1.0,2)",-->
|
||||
<!-- org.wso2.carbon.caching.impl;version="[4.6,5)",-->
|
||||
org.w3c.dom,org.wso2.carbon.base;version="[1.0,2)",
|
||||
org.wso2.carbon.caching.impl;version="[4.6,5)",
|
||||
org.wso2.carbon.context;version="[4.8,5)",
|
||||
org.wso2.carbon.core;version="[4.8,5)",
|
||||
org.wso2.carbon.core.util;version="[4.8,5)",
|
||||
org.wso2.carbon.event.processor.stub;version="[2.3,3)",
|
||||
org.wso2.carbon.event.processor.stub.types;version="[2.3,3)",
|
||||
org.wso2.carbon.ndatasource.core;version="[4.8,5)",
|
||||
org.wso2.carbon.ntask.common,
|
||||
org.wso2.carbon.ntask.core,
|
||||
org.wso2.carbon.ntask.core.service,
|
||||
org.wso2.carbon.registry.api,
|
||||
org.wso2.carbon.registry.core,
|
||||
org.wso2.carbon.registry.core.exceptions,
|
||||
org.wso2.carbon.registry.core.service,
|
||||
org.wso2.carbon.registry.core.session,
|
||||
org.wso2.carbon.ntask.common;version="[4.9,5)",
|
||||
org.wso2.carbon.ntask.core;version="[4.9,5)",
|
||||
org.wso2.carbon.ntask.core.service;version="[4.9,5)",
|
||||
org.wso2.carbon.registry.api;version="[1.0,2)",
|
||||
org.wso2.carbon.registry.core;version="[1.0,2)",
|
||||
org.wso2.carbon.registry.core.exceptions;version="[1.0,2)",
|
||||
org.wso2.carbon.registry.core.service;version="[1.0,2)",
|
||||
org.wso2.carbon.registry.core.session;version="[1.0,2)",
|
||||
org.wso2.carbon.stratos.common.beans;version="[4.7,5)",
|
||||
org.wso2.carbon.stratos.common.util;version="[4.7,5)",
|
||||
org.wso2.carbon.tenant.mgt.services,
|
||||
org.wso2.carbon.user.api,
|
||||
org.wso2.carbon.tenant.mgt.exception;version="[4.9,5)",
|
||||
org.wso2.carbon.tenant.mgt.services;version="[4.9,5)",
|
||||
org.wso2.carbon.user.api;version="[1.0,2)",
|
||||
org.wso2.carbon.user.core.config;version="[4.8,5)",
|
||||
org.wso2.carbon.user.core.service;version="[4.8,5)",
|
||||
org.wso2.carbon.user.core.tenant;version="[4.8,5)",
|
||||
|
||||
@ -18,9 +18,6 @@
|
||||
package io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task.impl;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity;
|
||||
import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus;
|
||||
@ -29,22 +26,45 @@ import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManage
|
||||
import io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout.OperationTimeout;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.task.impl.DynamicPartitionedScheduleTask;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.task.impl.RandomlyAssignedScheduleTask;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OperationTimeoutTask extends DynamicPartitionedScheduleTask {
|
||||
public class OperationTimeoutTask extends RandomlyAssignedScheduleTask {
|
||||
|
||||
private static final Log log = LogFactory.getLog(OperationTimeoutTask.class);
|
||||
public static final String OPERATION_TIMEOUT_TASK = "OPERATION_TIMEOUT_TASK";
|
||||
private Map<String, String> properties;
|
||||
|
||||
@Override
|
||||
public final void setProperties(Map<String, String> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public final String getProperty(String name) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return properties.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeDynamicTask() {
|
||||
if (isQualifiedToExecuteTask()) { // this task will run only in one node when the deployment has multiple nodes
|
||||
public String getTaskName() {
|
||||
return OPERATION_TIMEOUT_TASK;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeRandomlyAssignedTask() {
|
||||
// this task will run only in one node when the deployment has multiple nodes
|
||||
String operationTimeoutTaskConfigStr = getProperty(
|
||||
OperationTimeoutTaskManagerServiceImpl.OPERATION_TIMEOUT_TASK_CONFIG);
|
||||
Gson gson = new Gson();
|
||||
@ -69,17 +89,18 @@ public class OperationTimeoutTask extends DynamicPartitionedScheduleTask {
|
||||
List<Activity> activities = DeviceManagementDataHolder.getInstance().getOperationManager()
|
||||
.getActivities(deviceTypes, operationTimeoutConfig.getCode(), timeMillis,
|
||||
operationTimeoutConfig.getInitialStatus());
|
||||
String operationId;
|
||||
Operation operation;
|
||||
for (Activity activity : activities) {
|
||||
operationId = activity.getActivityId().replace("ACTIVITY_", "");
|
||||
for (ActivityStatus activityStatus : activity.getActivityStatus()) {
|
||||
String operationId = activity.getActivityId().replace("ACTIVITY_", "");
|
||||
Operation operation = DeviceManagementDataHolder.getInstance().getOperationManager()
|
||||
operation = DeviceManagementDataHolder.getInstance().getOperationManager()
|
||||
.getOperation(Integer.parseInt(operationId));
|
||||
operation.setStatus(Operation.Status.valueOf(operationTimeoutConfig.getNextStatus()));
|
||||
DeviceManagementDataHolder.getInstance().getOperationManager()
|
||||
.updateOperation(activityStatus.getDeviceIdentifier(), operation);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String msg = "Error occurred while retrieving operations.";
|
||||
log.error(msg, e);
|
||||
@ -87,17 +108,3 @@ public class OperationTimeoutTask extends DynamicPartitionedScheduleTask {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isQualifiedToExecuteTask() {
|
||||
if (isDynamicTaskEligible()) {
|
||||
try {
|
||||
return DeviceManagementDataHolder.getInstance().getHeartBeatService().isQualifiedToExecuteTask();
|
||||
} catch (HeartBeatManagementException e) {
|
||||
log.error("Error while checking is qualified to execute task", e);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,21 +18,21 @@
|
||||
|
||||
package io.entgra.device.mgt.core.device.mgt.core.task.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalException;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalService;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalServiceImpl;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.ntask.core.Task;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ArchivalTask implements Task {
|
||||
public class ArchivalTask extends RandomlyAssignedScheduleTask {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ArchivalTask.class);
|
||||
private static final String TASK_NAME = "DATA_ARCHIVAL_TASK";
|
||||
|
||||
private ArchivalService archivalService;
|
||||
|
||||
@ -42,12 +42,12 @@ public class ArchivalTask implements Task {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
protected void setup() {
|
||||
this.archivalService = new ArchivalServiceImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
protected void executeRandomlyAssignedTask() {
|
||||
log.info("Executing ArchivalTask at " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
@ -60,6 +60,11 @@ public class ArchivalTask implements Task {
|
||||
log.info("ArchivalTask completed. Total execution time: " + getDurationBreakdown(difference));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return TASK_NAME;
|
||||
}
|
||||
|
||||
private String getDurationBreakdown(long millis) {
|
||||
if (millis < 0) {
|
||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
||||
@ -74,4 +79,5 @@ public class ArchivalTask implements Task {
|
||||
|
||||
return (days + " Days " + hours + " Hours " + minutes + " Minutes " + seconds + " Seconds");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,9 +29,10 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class ArchivedDataDeletionTask implements Task {
|
||||
public class ArchivedDataDeletionTask extends RandomlyAssignedScheduleTask {
|
||||
|
||||
private static Log log = LogFactory.getLog(ArchivedDataDeletionTask.class);
|
||||
private static final Log log = LogFactory.getLog(ArchivedDataDeletionTask.class);
|
||||
private static final String TASK_NAME = "ARCHIVED_DATA_CLEANUP_TASK";
|
||||
|
||||
private ArchivalService archivalService;
|
||||
|
||||
@ -41,12 +42,12 @@ public class ArchivedDataDeletionTask implements Task {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
public void setup() {
|
||||
this.archivalService = new ArchivalServiceImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
protected void executeRandomlyAssignedTask() {
|
||||
log.info("Executing DataDeletionTask at " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
|
||||
long startTime = System.nanoTime();
|
||||
try {
|
||||
@ -58,4 +59,10 @@ public class ArchivedDataDeletionTask implements Task {
|
||||
long difference = (endTime - startTime) / (1000000 * 1000);
|
||||
log.info("DataDeletionTask completed. Total execution time: " + difference + " seconds");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return TASK_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -109,4 +109,5 @@ public class DeviceDetailsRetrieverTask extends DynamicPartitionedScheduleTask {
|
||||
protected void setup() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -142,6 +142,7 @@ public abstract class DynamicPartitionedScheduleTask implements Task {
|
||||
return taskContext;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isDynamicTaskEligible() {
|
||||
return taskContext != null && taskContext.isPartitioningEnabled();
|
||||
}
|
||||
|
||||
@ -28,8 +28,6 @@ import org.wso2.carbon.ntask.core.Task;
|
||||
public abstract class RandomlyAssignedScheduleTask implements Task {
|
||||
|
||||
private static final Log log = LogFactory.getLog(RandomlyAssignedScheduleTask.class);
|
||||
|
||||
private static String taskName = "UNSPECIFIED";
|
||||
private static boolean qualifiedToExecuteTask = false;
|
||||
private static boolean dynamicTaskEnabled = false;
|
||||
|
||||
@ -40,30 +38,30 @@ public abstract class RandomlyAssignedScheduleTask implements Task {
|
||||
} catch (HeartBeatManagementException e) {
|
||||
log.error("Error Instantiating Variables necessary for Randomly Assigned Task Scheduling.", e);
|
||||
}
|
||||
//This is done so that sub class extending this abstract class is forced to specify a task name.
|
||||
taskName = getTaskName();
|
||||
setup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void execute() {
|
||||
refreshContext();
|
||||
if (isQualifiedToExecuteTask()) {
|
||||
executeRandomlyAssignedTask();
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshContext() {
|
||||
if (dynamicTaskEnabled) {
|
||||
try {
|
||||
qualifiedToExecuteTask = DeviceManagementDataHolder.getInstance().getHeartBeatService().isQualifiedToExecuteTask();
|
||||
log.info("## NODE Qualified to execute Randomly Assigned Task : " + taskName);
|
||||
DeviceManagementDataHolder.getInstance().getHeartBeatService().updateTaskExecutionAcknowledgement(taskName);
|
||||
} catch (HeartBeatManagementException e) {
|
||||
log.error("Error refreshing Variables necessary for Randomly Assigned Scheduled Task. " +
|
||||
"Dynamic Tasks will not function.", e);
|
||||
log.error("Error refreshing variables necessary for " +
|
||||
"Randomly Assigned Scheduled Task: " + getTaskName(), e);
|
||||
}
|
||||
} else {
|
||||
qualifiedToExecuteTask = true;
|
||||
}
|
||||
log.info("Node is " + (qualifiedToExecuteTask ? "" : "not")
|
||||
+ " qualified to execute Randomly Assigned Task : " + getTaskName());
|
||||
}
|
||||
|
||||
protected abstract void setup();
|
||||
@ -75,4 +73,5 @@ public abstract class RandomlyAssignedScheduleTask implements Task {
|
||||
}
|
||||
|
||||
public abstract String getTaskName();
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>heartbeat-management</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
|
||||
if (candidate != null && candidate.getServerUUID().equalsIgnoreCase(localServerUUID)) {
|
||||
isQualified = true;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Node : " + localServerUUID + " Qualified to execute randomly assigned task.");
|
||||
log.debug("Node : " + localServerUUID + " is qualified to execute randomly assigned task.");
|
||||
}
|
||||
}
|
||||
} catch (HeartBeatDAOException e) {
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>identity-extensions</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>identity-extensions</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.parent</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>io.entgra.device.mgt.core</groupId>
|
||||
<artifactId>logger</artifactId>
|
||||
<version>5.0.40-SNAPSHOT</version>
|
||||
<version>5.0.41-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>io.entgra.device.mgt.core.notification.logger</artifactId>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user