Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/6 6 ee10 upgrade #13

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public byte[] sign(InputStream content) throws IOException {
gen.addCertificates(new JcaCertStore(Arrays.asList(cmsPrivateKey.getCertificateChain())));
CMSProcessableInputStream msg = new CMSProcessableInputStream(content);
CMSSignedData signedData = gen.generate(msg, false);
// if we need imestamp validation
// if we need timestamp validation
// https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/
//
// if (tsaUrl != null && tsaUrl.length() > 0) {
Expand Down
7 changes: 1 addition & 6 deletions dookug-document/dookug-document-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>hu.icellmobilsoft.dookug</groupId>
<artifactId>dookug-document</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>dookug-document-service</artifactId>
Expand All @@ -24,11 +24,6 @@
<artifactId>dookug-common-system-jpa</artifactId>
</dependency>

<dependency>
<groupId>hu.icellmobilsoft.dookug</groupId>
<artifactId>dookug-common-cdi</artifactId>
</dependency>

<dependency>
<groupId>hu.icellmobilsoft.dookug</groupId>
<artifactId>dookug-engine-handlebars</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@
import java.util.Map;
import java.util.stream.Collectors;

import javax.enterprise.inject.Model;
import javax.enterprise.inject.spi.CDI;
import javax.inject.Inject;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.StreamingOutput;
import jakarta.enterprise.inject.Model;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.inject.Inject;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.StreamingOutput;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.config.inject.ConfigProperty;

import hu.icellmobilsoft.coffee.dto.exception.BaseException;
import hu.icellmobilsoft.coffee.dto.exception.BusinessException;
import hu.icellmobilsoft.coffee.dto.exception.InvalidParameterException;
import hu.icellmobilsoft.coffee.dto.exception.enums.CoffeeFaultType;
import hu.icellmobilsoft.coffee.tool.gson.JsonUtil;
import hu.icellmobilsoft.coffee.tool.utils.compress.GZIPUtil;
Expand Down Expand Up @@ -95,6 +96,15 @@ public class BaseDocumentGenerateAction extends BaseAction {
defaultValue = ConfigKeys.Interface.DOOKUG_SERVICE_INTERFACE_PARAMETERSDATA_GZIPPED_DEFAULT)
private boolean parametersDataGzipped;

/**
* Generate document
*
* @param generatorSetup
* the generator configuration
* @return the {@link Document}
* @throws BaseException
* on error
*/
protected Document generateDocument(BaseGeneratorSetupType generatorSetup) throws BaseException {
validateSetup(generatorSetup);

Expand Down Expand Up @@ -132,21 +142,21 @@ protected Document generateDocument(BaseGeneratorSetupType generatorSetup) throw

private void validateSetup(BaseGeneratorSetupType generatorSetup) throws BaseException {
if (generatorSetup == null) {
throw newInvalidParameterException("Generator setup is null!");
throw new InvalidParameterException("Generator setup is null!");
}
if (generatorSetup.getResponseFormat() != ResponseFormatType.STRING && generatorSetup.getGeneratorEngine() == GeneratorEngineType.NONE) {
throw newInvalidParameterException(
throw new InvalidParameterException(
MessageFormat.format("ResponseFormat [{0}] response can only be done using a generator!", generatorSetup.getResponseFormat()));
}
if (generatorSetup.getResponseFormat() != ResponseFormatType.PDF && generatorSetup.getGeneratorEngine() == GeneratorEngineType.SAXON) {
throw newInvalidParameterException(
throw new InvalidParameterException(
MessageFormat.format(
"ResponseFormat [{0}] and generatorEngine [{1}] combination is not defined!",
generatorSetup.getResponseFormat(),
generatorSetup.getGeneratorEngine()));
}
if (generatorSetup.getResponseFormat() == ResponseFormatType.STRING && generatorSetup.getGeneratorEngine() == GeneratorEngineType.PDF_BOX) {
throw newInvalidParameterException(
throw new InvalidParameterException(
MessageFormat.format(
"ResponseFormat [{0}] and generatorEngine [{1}] combination is not defined!",
generatorSetup.getResponseFormat(),
Expand Down Expand Up @@ -251,6 +261,15 @@ public void write(OutputStream output) throws IOException, WebApplicationExcepti
};
}

/**
* {@link Document} to {@link DocumentMetadataResponse} converter
*
* @param document
* document to convert
* @return the metadata
* @throws BaseException
* on error
*/
protected DocumentMetadataResponse toDocumentMetadataResponse(Document document) throws BaseException {
DocumentMetadataResponse response = documentConverter.convert(document);
handleSuccessResultType(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
*/
package hu.icellmobilsoft.dookug.document.service.action;

import javax.enterprise.inject.Model;
import javax.enterprise.inject.spi.CDI;
import javax.inject.Inject;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.enterprise.inject.Model;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.apache.commons.lang3.StringUtils;

import hu.icellmobilsoft.coffee.dto.exception.BaseException;
import hu.icellmobilsoft.coffee.dto.exception.InvalidParameterException;
import hu.icellmobilsoft.coffee.rest.utils.ResponseUtil;
import hu.icellmobilsoft.dookug.common.cdi.StorageMethodQualifier;
import hu.icellmobilsoft.dookug.common.cdi.document.Document;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class DocumentContentAction extends BaseAction {
*/
public Response getDocumentContent(String documentId) throws BaseException {
if (StringUtils.isBlank(documentId)) {
throw newInvalidParameterException("Document id cannot be blank!");
throw new InvalidParameterException("Document id cannot be blank!");
}

hu.icellmobilsoft.dookug.common.model.template.Document databaseDocument = documentService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
import java.io.InputStream;
import java.util.List;

import javax.enterprise.inject.Model;
import javax.inject.Inject;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.enterprise.inject.Model;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import hu.icellmobilsoft.coffee.dto.exception.BaseException;
import hu.icellmobilsoft.coffee.dto.exception.InvalidParameterException;
import hu.icellmobilsoft.coffee.dto.exception.TechnicalException;
import hu.icellmobilsoft.coffee.dto.exception.enums.CoffeeFaultType;
import hu.icellmobilsoft.coffee.rest.utils.ResponseUtil;
Expand Down Expand Up @@ -73,7 +74,7 @@ public class DocumentGenerateAction extends BaseDocumentGenerateAction {
*/
public Response postDocumentGenerate(DocumentGenerateMultipartForm form) throws BaseException {
if (form == null) {
throw newInvalidParameterException("form is null!");
throw new InvalidParameterException("form is null!");
}
BaseGeneratorSetupType generatorSetup = form.getRequest().getGeneratorSetup();
byte[] template = readInputStream(form.getTemplate());
Expand All @@ -95,16 +96,23 @@ public Response postDocumentGenerate(DocumentGenerateMultipartForm form) throws
*/
public Response postDocumentGenerate(DocumentGenerateWithTemplatesRequest request) throws BaseException {
if (request == null) {
throw newInvalidParameterException("request is null!");
throw new InvalidParameterException("request is null!");
}
templateData.setTemplateName(INLINE_TEMPLATE_NAME);
InlineGeneratorSetupType generatorSetup = request.getGeneratorSetup();
return documentGenerate(request.getTemplates(), generatorSetup);
}

/**
* @param form
* multipart form
* @return the document metadata
* @throws BaseException
* on error
*/
public DocumentMetadataResponse postDocumentGenerateMetadata(DocumentGenerateMultipartForm form) throws BaseException {
if (form == null) {
throw newInvalidParameterException("form is null!");
throw new InvalidParameterException("form is null!");
}
BaseGeneratorSetupType generatorSetup = form.getRequest().getGeneratorSetup();
byte[] template = readInputStream(form.getTemplate());
Expand All @@ -115,9 +123,16 @@ public DocumentMetadataResponse postDocumentGenerateMetadata(DocumentGenerateMul
generatorSetup);
}

/**
* @param request
* request object
* @return the document metadata
* @throws BaseException
* on error
*/
public DocumentMetadataResponse postDocumentGenerateMetadata(DocumentGenerateWithTemplatesRequest request) throws BaseException {
if (request == null) {
throw newInvalidParameterException("request is null!");
throw new InvalidParameterException("request is null!");
}
templateData.setTemplateName(INLINE_TEMPLATE_NAME);
InlineGeneratorSetupType generatorSetup = request.getGeneratorSetup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
*/
package hu.icellmobilsoft.dookug.document.service.action;

import javax.enterprise.inject.Model;
import javax.inject.Inject;
import jakarta.enterprise.inject.Model;
import jakarta.inject.Inject;

import hu.icellmobilsoft.coffee.dto.common.common.QueryRequestDetails;
import hu.icellmobilsoft.coffee.dto.exception.BaseException;
import hu.icellmobilsoft.coffee.dto.exception.InvalidParameterException;
import hu.icellmobilsoft.coffee.jpa.sql.paging.PagingResult;
import hu.icellmobilsoft.coffee.tool.utils.enums.EnumUtil;
import hu.icellmobilsoft.dookug.common.model.template.Document;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class DocumentMetadataQueryAction extends BaseAction {
*/
public DocumentMetadataQueryResponse postDocumentMetadataQuery(DocumentMetadataQueryRequest queryRequest) throws BaseException {
if (queryRequest == null) {
throw newInvalidParameterException("queryRequest cannot be null!");
throw new InvalidParameterException("queryRequest cannot be null!");
}

PagingResult<Document> pagingResult = documentQueryService.findByQueryParams(queryRequest.getQueryParams(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
*/
package hu.icellmobilsoft.dookug.document.service.action;

import javax.enterprise.inject.Model;
import javax.enterprise.inject.spi.CDI;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.enterprise.inject.Model;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import hu.icellmobilsoft.coffee.dto.exception.BaseException;
import hu.icellmobilsoft.coffee.dto.exception.InvalidParameterException;
import hu.icellmobilsoft.coffee.rest.utils.ResponseUtil;
import hu.icellmobilsoft.dookug.common.cdi.StorageMethodQualifier;
import hu.icellmobilsoft.dookug.common.cdi.document.Document;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class StoredTemplateDocumentGenerateAction extends BaseDocumentGenerateAc
*/
public Response postStoredTemplateDocumentGenerate(StoredTemplateDocumentGenerateRequest request) throws BaseException {
if (request == null) {
throw newInvalidParameterException("StoredTemplateDocumentGenerateRequest cannot be empty!");
throw new InvalidParameterException("StoredTemplateDocumentGenerateRequest cannot be empty!");
}

Document document = generateAndGetDocument(request.getGeneratorSetup());
Expand All @@ -72,7 +73,7 @@ public Response postStoredTemplateDocumentGenerate(StoredTemplateDocumentGenerat
*/
public DocumentMetadataResponse postStoredTemplateDocumentGenerateMetadata(StoredTemplateDocumentGenerateRequest request) throws BaseException {
if (request == null) {
throw newInvalidParameterException("StoredTemplateDocumentGenerateRequest cannot be empty!");
throw new InvalidParameterException("StoredTemplateDocumentGenerateRequest cannot be empty!");
}

Document document = generateAndGetDocument(request.getGeneratorSetup());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
import java.security.InvalidParameterException;
import java.time.Duration;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.config.inject.ConfigProperty;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import hu.icellmobilsoft.coffee.cdi.logger.AppLogger;
import hu.icellmobilsoft.coffee.cdi.logger.ThisLogger;
import hu.icellmobilsoft.dookug.api.dto.constants.ConfigKeys;

import hu.icellmobilsoft.dookug.document.service.cache.dto.TemplateCacheItem;
import hu.icellmobilsoft.dookug.common.system.rest.cache.AbstractCache;
import hu.icellmobilsoft.dookug.document.service.cache.dto.TemplateCacheItem;

/**
* Template cache functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,55 @@ public class TemplateCacheItem {

private final List<TemplatePartCacheItem> templatePartCacheItems;


/**
* default constructor
*
* @param templateId
* temaplte identifier
* @param templateName
* template name
*/
public TemplateCacheItem(String templateId, String templateName) {
this.templateId = templateId;
this.templateName = templateName;

templatePartCacheItems = new ArrayList<>();
}

/**
* add a new {@link TemplatePartCacheItem}
*
* @param templatePartCacheItem
* the item to add
*/
public void addNewPartItem(TemplatePartCacheItem templatePartCacheItem) {
templatePartCacheItems.add(templatePartCacheItem);
getTemplatePartCacheItems().add(templatePartCacheItem);
}

@Override
public String toString() {
return "TemplateCacheItem{" + "templateId='" + getTemplateId() + '\'' + ", templateName='" + getTemplateName() + '\''
+ ", templatePartCacheItems=" + getTemplatePartCacheItems() + '}';
}

/**
* @return the templateId
*/
public String getTemplateId() {
return templateId;
}

/**
* @return the templateName
*/
public String getTemplateName() {
return templateName;
}

/**
* @return the templatePartCacheItems
*/
public List<TemplatePartCacheItem> getTemplatePartCacheItems() {
return templatePartCacheItems;
}

@Override
public String toString() {
return "TemplateCacheItem{" + "templateId='" + templateId + '\'' + ", templateName='" + templateName + '\'' + ", templatePartCacheItems="
+ templatePartCacheItems + '}';
}
}
Loading
Loading