refactoring

This commit is contained in:
dashevchenko 2023-06-07 15:27:44 +03:00
parent 407effbc26
commit 87786ef72d
4 changed files with 27 additions and 44 deletions

View File

@ -140,7 +140,7 @@ public class ControllerConstants {
protected static final String RESOURCE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'substring' filter based on the resource title.";
protected static final String RESOURCE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, resourceType, tenantId";
protected static final String RESOURCE_TYPE_PROPERTY_ALLOWABLE_VALUES = "lwm2m, jks, pkcs12, js";
protected static final String RESOURCE_TYPE_PROPERTY_ALLOWABLE_VALUES = "LWM2M_MODEL, JKS, PKCS_12, JS_MODULE";
protected static final String RESOURCE_TYPE = "A string value representing the resource type.";
protected static final String LWM2M_OBJECT_DESCRIPTION = "LwM2M Object is a object that includes information about the LwM2M model which can be used in transport configuration for the LwM2M device profile. ";

View File

@ -212,7 +212,7 @@ public class TbResourceController extends BaseController {
TbResourceInfoFilter.TbResourceInfoFilterBuilder filter = TbResourceInfoFilter.builder();
filter.tenantId(getTenantId());
if (StringUtils.isNotEmpty(resourceType)){
filter.resourceType(ResourceType.getResourceByType(resourceType));
filter.resourceType(ResourceType.valueOf(resourceType));
}
if (Authority.SYS_ADMIN.equals(getCurrentUser().getAuthority())) {
return checkNotNull(resourceService.findTenantResourcesByTenantId(filter.build(), pageLink));

View File

@ -16,33 +16,18 @@
package org.thingsboard.server.common.data;
public enum ResourceType {
LWM2M_MODEL("lwm2m", "application/xml"),
JKS("jks", "application/x-java-keystore"),
PKCS_12("pkcs12", "application/x-pkcs12"),
JS_MODULE("js", "application/javascript");
LWM2M_MODEL("application/xml"),
JKS("application/x-java-keystore"),
PKCS_12("application/x-pkcs12"),
JS_MODULE("application/javascript");
private final String type;
private final String mediaType;
ResourceType(String type, String mediaType) {
this.type = type;
ResourceType(String mediaType) {
this.mediaType = mediaType;
}
public static ResourceType getResourceByType(String type) {
for(ResourceType resourceType : values()) {
if (resourceType.getType().equalsIgnoreCase(type)) {
return resourceType;
}
}
throw new IllegalArgumentException();
}
public String getMediaType() {
return mediaType;
}
public String getType() {
return type;
}
}