Skip to content

Feat/doc api#130

Open
droslbl wants to merge 16 commits intoFIWARE:mainfrom
droslbl:feat/docApi
Open

Feat/doc api#130
droslbl wants to merge 16 commits intoFIWARE:mainfrom
droslbl:feat/docApi

Conversation

@droslbl
Copy link
Copy Markdown
Contributor

@droslbl droslbl commented Mar 12, 2026

Greetings @wistefan

This is the Document API management feature. I also added the changes to add this to the all-in-one feature recently added.

Best regards


@EqualsAndHashCode(callSuper = true)
@MappingEnabled(entityType = DocumentSpecification.TYPE_DOCUMENT_SPECIFICATION)
public class DocumentSpecification extends EntityWithId {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object lacks a numer of properties defined in the api. There is no:

  • entitySpecRelationship
  • specCharacteristic
  • tragetEntitySchema
  • validFor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still incomplete, at least constraint is missing


@EqualsAndHashCode(callSuper = true)
@MappingEnabled(entityType = DocumentSpecification.TYPE_DOCUMENT_SPECIFICATION)
public class DocumentSpecification extends EntityWithId {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still incomplete, at least constraint is missing

.findFirst()
.ifPresent(att -> {
throw new TmForumException(
"Attachments with inline content are not supported when no S3 storage is configured. Provide a URL reference instead.",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change that to "when no AttachmentService is configured". This is not hard tied to S3

DocumentSpecification.TYPE_DOCUMENT_SPECIFICATION)));

docSpec.setLastUpdate(clock.instant());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please simplify that those checks. Nested ifs should be avoided and its not necessary to check the attachment service being null multiple times

*/
@PostConstruct
public void init() {
log.info("Initializing S3AttachmentService:");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a multiline log? Makes it harder to parse for log-aggregators and more expensive to store

log.info("S3 client created successfully");
} catch (Exception e) {
log.error("Failed to create S3 client: {}", e.getMessage(), e);
throw new RuntimeException("Failed to initialize S3 client", e);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a plain RuntimeException

public Mono<HttpResponse<DocumentSpecificationVO>> patchDocumentSpecification(
String id,
DocumentSpecificationUpdateVO updateVO) {
// PATCH is not implemented per requirements (only GET/POST/DELETE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is patch not required? Its part of the spec.

assertEquals(HttpStatus.CREATED, response.getStatus(), message);
assertNotNull(response.body(), message);
assertNotNull(response.body().getId(), message);
assertEquals(expectedDocSpec.getName(), response.body().getName(), message);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only validates correctness of the name. Why is this enough?

assertFalse(response.body().getAttachment().isEmpty());
// The attachment content should be S3 retrieval info, not the original content
String content = response.body().getAttachment().get(0).getContent();
assertTrue(content.startsWith("s3ref:"), "Content should be S3 retrieval info");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no S3RetrievalInfo in the code anymore. How can this test succeed?

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests look better now, but please add messages to the assertions. There shouldn´t be any asserts without messages.

<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.7</version>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please configure the version in the top-level properties. This holds the risk of deviating versions between the aaio and the dedicated module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants