Browse Source

refactoring

pull/8562/head
dashevchenko 3 years ago
parent
commit
87786ef72d
  1. 2
      application/src/main/java/org/thingsboard/server/controller/ControllerConstants.java
  2. 2
      application/src/main/java/org/thingsboard/server/controller/TbResourceController.java
  3. 42
      application/src/test/java/org/thingsboard/server/service/resource/sql/BaseTbResourceServiceTest.java
  4. 25
      common/data/src/main/java/org/thingsboard/server/common/data/ResourceType.java

2
application/src/main/java/org/thingsboard/server/controller/ControllerConstants.java

@ -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. ";

2
application/src/main/java/org/thingsboard/server/controller/TbResourceController.java

@ -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));

42
application/src/test/java/org/thingsboard/server/service/resource/sql/BaseTbResourceServiceTest.java

File diff suppressed because one or more lines are too long

25
common/data/src/main/java/org/thingsboard/server/common/data/ResourceType.java

@ -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;
}
}

Loading…
Cancel
Save