Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 5062ddc6 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #164: [EDELIVERY-14014] set document name as identifier value

Merge in EDELIVERY/smp from bugfix/EDELIVERY-14014-edit-document-document-name-should-be-more-suggestive to development

* commit '7e44662d':
  [EDELIVERY-14014] set document name as identifier value
parents b085238e 7e44662d
No related branches found
No related tags found
No related merge requests found
......@@ -164,7 +164,8 @@ public class ResourceHandlerService extends AbstractResourceHandler {
if (resource.getDocument() == null) {
resource.setDocument(new DBDocument());
// set response data
resource.getDocument().setName(resolvedData.getResourceDef().getName());
// set left 255 characters of identifier value as name
resource.getDocument().setName(StringUtils.left(resource.getIdentifierValue(), 255));
resource.getDocument().setMimeType(StringUtils.getIfEmpty(responseData.getContentType(),
() -> resolvedData.getResourceDef().getMimeType()));
}
......@@ -233,7 +234,7 @@ public class ResourceHandlerService extends AbstractResourceHandler {
if (resolvedSubresource.getDocument() == null) {
resolvedSubresource.setDocument(new DBDocument());
// set response data
resolvedSubresource.getDocument().setName(resolvedData.getResourceDef().getName());
resolvedSubresource.getDocument().setName(StringUtils.left(resolvedSubresource.getIdentifierValue(), 255));
resolvedSubresource.getDocument().setMimeType(StringUtils.getIfEmpty(responseData.getContentType(),
() -> resolvedData.getResourceDef().getMimeType()));
}
......
......@@ -367,7 +367,7 @@ public class ResourceResolverService {
resource.setIdentifierValue(resourceId.getValue());
resource.setIdentifierScheme(resourceId.getScheme());
resource.setDocument(new DBDocument());
resource.getDocument().setName(resourceDef.getName());
resource.getDocument().setName(StringUtils.left(resourceId.getValue(), 255));
resource.getDocument().setMimeType(resourceDef.getMimeType());
resource.setDomainResourceDef(domainResourceDefDao.getResourceDefConfigurationForDomainAndResourceDef(domain, resourceDef)
.orElse(null));
......@@ -381,7 +381,7 @@ public class ResourceResolverService {
subresource.setResource(resource);
subresource.setSubresourceDef(subresourceDef);
subresource.setDocument(new DBDocument());
subresource.getDocument().setName(subresourceDef.getName());
subresource.getDocument().setName(StringUtils.left(resourceId.getValue(), 255));
subresource.getDocument().setMimeType(subresourceDef.getMimeType());
return subresource;
}
......
......@@ -298,8 +298,8 @@ public class UIResourceService {
DBResource resource = resourceDao.find(resourceId);
resource.setVisibility(resourceRO.getVisibility());
if (resourceRO.isReviewEnabled() != null) {
Boolean newValue = isTrue(resourceRO.isReviewEnabled());
Boolean oldValue = isTrue(resource.isReviewEnabled());
boolean newValue = isTrue(resourceRO.isReviewEnabled());
boolean oldValue = isTrue(resource.isReviewEnabled());
// update resource review enabled in case if it was null before
resource.setReviewEnabled(newValue);
// check if new status is disabled and changed
......@@ -307,7 +307,7 @@ public class UIResourceService {
// update all document versions to non review status
uiDocumentService.updateToNonReviewStatuses(resource.getDocument());
// update statuses for all subresources
resource.getSubresources().stream().forEach(subResource ->
resource.getSubresources().forEach(subResource ->
uiDocumentService.updateToNonReviewStatuses(subResource.getDocument()));
}
resource.setReviewEnabled(isTrue(resourceRO.isReviewEnabled()));
......@@ -415,7 +415,7 @@ public class UIResourceService {
DBDocument document = new DBDocument();
document.setMimeType(domainResourceDef.getMimeType());
document.setName(domainResourceDef.getName());
document.setName(StringUtils.left(resource.getIdentifierValue(), 255));
// create first version of the document
DBDocumentVersion version = documentVersionService.initializeDocumentVersionByGroupAdmin(EventSourceType.UI);
// The first version is always published.
......
......@@ -37,6 +37,7 @@ import eu.europa.ec.edelivery.smp.identifiers.Identifier;
import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.edelivery.smp.services.resource.DocumentVersionService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.convert.ConversionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -141,7 +142,7 @@ public class UISubresourceService {
DBDocument document = new DBDocument();
document.setCurrentVersion(1);
document.setMimeType(subresourceDef.getMimeType());
document.setName(subresourceDef.getName());
document.setName(StringUtils.left(subresource.getIdentifierValue(), 255));
// create first version of the document
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment