refactoring
This commit is contained in:
parent
407effbc26
commit
87786ef72d
@ -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_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_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 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. ";
|
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. ";
|
||||||
|
|||||||
@ -212,7 +212,7 @@ public class TbResourceController extends BaseController {
|
|||||||
TbResourceInfoFilter.TbResourceInfoFilterBuilder filter = TbResourceInfoFilter.builder();
|
TbResourceInfoFilter.TbResourceInfoFilterBuilder filter = TbResourceInfoFilter.builder();
|
||||||
filter.tenantId(getTenantId());
|
filter.tenantId(getTenantId());
|
||||||
if (StringUtils.isNotEmpty(resourceType)){
|
if (StringUtils.isNotEmpty(resourceType)){
|
||||||
filter.resourceType(ResourceType.getResourceByType(resourceType));
|
filter.resourceType(ResourceType.valueOf(resourceType));
|
||||||
}
|
}
|
||||||
if (Authority.SYS_ADMIN.equals(getCurrentUser().getAuthority())) {
|
if (Authority.SYS_ADMIN.equals(getCurrentUser().getAuthority())) {
|
||||||
return checkNotNull(resourceService.findTenantResourcesByTenantId(filter.build(), pageLink));
|
return checkNotNull(resourceService.findTenantResourcesByTenantId(filter.build(), pageLink));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -16,33 +16,18 @@
|
|||||||
package org.thingsboard.server.common.data;
|
package org.thingsboard.server.common.data;
|
||||||
|
|
||||||
public enum ResourceType {
|
public enum ResourceType {
|
||||||
LWM2M_MODEL("lwm2m", "application/xml"),
|
LWM2M_MODEL("application/xml"),
|
||||||
JKS("jks", "application/x-java-keystore"),
|
JKS("application/x-java-keystore"),
|
||||||
PKCS_12("pkcs12", "application/x-pkcs12"),
|
PKCS_12("application/x-pkcs12"),
|
||||||
JS_MODULE("js", "application/javascript");
|
JS_MODULE("application/javascript");
|
||||||
|
|
||||||
private final String type;
|
|
||||||
private final String mediaType;
|
private final String mediaType;
|
||||||
|
|
||||||
ResourceType(String type, String mediaType) {
|
ResourceType(String mediaType) {
|
||||||
this.type = type;
|
|
||||||
this.mediaType = 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() {
|
public String getMediaType() {
|
||||||
return mediaType;
|
return mediaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user