Fix build
This commit is contained in:
parent
7d4729451a
commit
d70ce27253
@ -33,7 +33,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.util.ImageUtils;
|
||||
import org.thingsboard.server.common.data.widget.WidgetTypeDetails;
|
||||
import org.thingsboard.server.common.data.widget.WidgetsBundle;
|
||||
import org.thingsboard.server.dao.resource.ResourceService;
|
||||
import org.thingsboard.server.dao.resource.ImageService;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -47,7 +47,7 @@ import java.util.Optional;
|
||||
@RequiredArgsConstructor
|
||||
public class ImagesUpdater {
|
||||
|
||||
private final ResourceService resourceService;
|
||||
private final ImageService imageService;
|
||||
|
||||
private static final String IMAGE_NAME_SUFFIX = " - image";
|
||||
private static final String BACKGROUND_IMAGE_NAME_SUFFIX = " - background image";
|
||||
@ -201,19 +201,19 @@ public class ImagesUpdater {
|
||||
|
||||
private String saveImage(TenantId tenantId, String name, String key, byte[] imageData, String mediaType,
|
||||
String existingImageQuery) {
|
||||
TbResourceInfo resourceInfo = resourceService.findResourceInfoByTenantIdAndKey(tenantId, ResourceType.IMAGE, key);
|
||||
TbResourceInfo resourceInfo = imageService.getImageInfoByTenantIdAndKey(tenantId, key);
|
||||
if (resourceInfo == null && !tenantId.isSysTenantId() && existingImageQuery != null) {
|
||||
// TODO: need to search among tenant images too (custom widgets)
|
||||
List<TbResourceInfo> existingSystemImages = resourceService.findByTenantIdAndDataAndKeyStartingWith(TenantId.SYS_TENANT_ID, imageData, existingImageQuery);
|
||||
if (!existingSystemImages.isEmpty()) {
|
||||
resourceInfo = existingSystemImages.get(0);
|
||||
if (existingSystemImages.size() > 1) {
|
||||
log.warn("Found more than one system image resources for key {}", existingImageQuery);
|
||||
}
|
||||
String link = resourceService.getResourceLink(resourceInfo);
|
||||
log.info("Using system image {} for {}", link, key);
|
||||
return link;
|
||||
}
|
||||
// List<TbResourceInfo> existingSystemImages = imageService.findByTenantIdAndDataAndKeyStartingWith(TenantId.SYS_TENANT_ID, imageData, existingImageQuery);
|
||||
// if (!existingSystemImages.isEmpty()) {
|
||||
// resourceInfo = existingSystemImages.get(0);
|
||||
// if (existingSystemImages.size() > 1) {
|
||||
// log.warn("Found more than one system image resources for key {}", existingImageQuery);
|
||||
// }
|
||||
// String link = imageService.getImageLink(resourceInfo);
|
||||
// log.info("Using system image {} for {}", link, key);
|
||||
// return link;
|
||||
// }
|
||||
}
|
||||
TbResource resource;
|
||||
if (resourceInfo == null) {
|
||||
@ -224,16 +224,16 @@ public class ImagesUpdater {
|
||||
} else if (tenantId.isSysTenantId()) {
|
||||
resource = new TbResource(resourceInfo);
|
||||
} else {
|
||||
return resourceService.getResourceLink(resourceInfo);
|
||||
return imageService.getImageLink(resourceInfo);
|
||||
}
|
||||
resource.setTitle(name);
|
||||
resource.setFileName(key);
|
||||
resource.setMediaType(mediaType);
|
||||
resource.setData(imageData);
|
||||
resource = resourceService.saveResource(resource);
|
||||
resource = imageService.saveImage(resource);
|
||||
log.info("[{}] {} image '{}' ({})", tenantId, resourceInfo == null ? "Created" : "Updated",
|
||||
resource.getTitle(), resource.getResourceKey());
|
||||
return resourceService.getResourceLink(resourceInfo);
|
||||
return imageService.getImageLink(resourceInfo);
|
||||
}
|
||||
|
||||
private String getText(JsonNode jsonNode, String field) {
|
||||
|
||||
@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Copyright © 2016-2023 The Thingsboard Authors
|
||||
*
|
||||
* Licensed 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.thingsboard.server.service.resource;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Copyright © 2016-2023 The Thingsboard Authors
|
||||
*
|
||||
* Licensed 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.thingsboard.server.service.resource;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Copyright © 2016-2023 The Thingsboard Authors
|
||||
*
|
||||
* Licensed 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.thingsboard.server.dao.resource;
|
||||
|
||||
import org.thingsboard.server.common.data.TbResource;
|
||||
@ -9,7 +24,7 @@ import org.thingsboard.server.common.data.page.PageLink;
|
||||
|
||||
public interface ImageService {
|
||||
|
||||
TbResourceInfo saveImage(TbResource image);
|
||||
TbResource saveImage(TbResource image);
|
||||
|
||||
TbResourceInfo saveImageInfo(TbResourceInfo imageInfo);
|
||||
|
||||
|
||||
@ -1,6 +1,20 @@
|
||||
/**
|
||||
* Copyright © 2016-2023 The Thingsboard Authors
|
||||
*
|
||||
* Licensed 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.thingsboard.server.dao.resource;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.common.data.ResourceType;
|
||||
import org.thingsboard.server.common.data.TbResource;
|
||||
@ -22,7 +36,7 @@ public class BaseImageService extends BaseResourceService implements ImageServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbResourceInfo saveImage(TbResource image) {
|
||||
public TbResource saveImage(TbResource image) {
|
||||
resourceValidator.validate(image, TbResourceInfo::getTenantId);
|
||||
if (image.getData() != null) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user