Skip to content

Commit

Permalink
updated imixs-melman 2.0.0->2.0.1
Browse files Browse the repository at this point in the history
Issue #181
  • Loading branch information
rsoika committed Jun 9, 2023
1 parent 580bc6a commit 025e48f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import jakarta.ejb.LocalBean;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.imixs.archive.core.SnapshotService;
import org.imixs.melman.BasicAuthenticator;
Expand All @@ -21,6 +13,14 @@
import org.imixs.workflow.FileData;
import org.imixs.workflow.ItemCollection;

import jakarta.ejb.LocalBean;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

/**
* The ArchiveRemoteService provides a method to load a file form a remote
* cassandra archive.
Expand Down Expand Up @@ -137,8 +137,10 @@ public byte[] loadFileFromArchive(FileData fileData) throws RestAPIException {
/**
* Helper method to initalize a Melman Workflow Client based on the current
* archive configuration.
*
* @throws RestAPIException
*/
private DocumentClient initDocumentClient() {
private DocumentClient initDocumentClient() throws RestAPIException {
boolean debug = logger.isLoggable(Level.FINE);
DocumentClient documentClient = new DocumentClient(archiveServiceEndpoint.get());
// test if authentication is needed?
Expand Down
2 changes: 0 additions & 2 deletions imixs-archive-exporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
<failOnMissingWebXml>false</failOnMissingWebXml>

<org.imixs.workflow.version>6.0.2</org.imixs.workflow.version>
<org.imixs.melman.version>2.0.0</org.imixs.melman.version>
<org.imixs.jwt.version>1.0.3</org.imixs.jwt.version>
<jakarta.version>10.0.0</jakarta.version>
<microprofile.version>5.0</microprofile.version>
<microprofile-metrics.version>4.0</microprofile-metrics.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@
import java.util.Optional;
import java.util.logging.Logger;

import jakarta.ejb.Stateless;
import jakarta.inject.Inject;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.imixs.archive.service.cassandra.ClusterService;
import org.imixs.melman.BasicAuthenticator;
import org.imixs.melman.DocumentClient;
import org.imixs.melman.FormAuthenticator;
import org.imixs.melman.RestAPIException;
import org.imixs.workflow.ItemCollection;

import org.imixs.workflow.xml.XMLDataCollection;
import org.imixs.workflow.xml.XMLDocumentAdapter;

import jakarta.ejb.Stateless;
import jakarta.inject.Inject;

/**
* The RemoteService is used to access the remote API from the worklfow
* instance. All remote clients are based on the Imixs-Rest API.
Expand Down Expand Up @@ -87,12 +86,12 @@ public class RemoteAPIService {
public XMLDataCollection readSyncData(long syncPoint) throws ArchiveException {
XMLDataCollection result = null;
// load next document

DocumentClient documentClient = initWorkflowClient();
String url = SNAPSHOT_SYNCPOINT_RESOURCE + syncPoint;
logger.finest("...... read data: " + url + "....");

String url = "";
try {
DocumentClient documentClient = initWorkflowClient();
url = SNAPSHOT_SYNCPOINT_RESOURCE + syncPoint;
logger.finest("...... read data: " + url + "....");

result = documentClient.getCustomResourceXML(url);
} catch (RestAPIException e) {
String errorMessage = "...failed readSyncData at : " + url + " Error Message: " + e.getMessage();
Expand All @@ -116,12 +115,12 @@ public XMLDataCollection readSyncData(long syncPoint) throws ArchiveException {
*/
public String readSnapshotIDByUniqueID(String uniqueid) throws ArchiveException {
String result = null;
// load single document
DocumentClient documentClient = initWorkflowClient();
String url = DOCUMENTS_RESOURCE + uniqueid + "?items=$snapshotid";
logger.finest("...... read snapshotid: " + url + "....");

try {
// load single document
DocumentClient documentClient = initWorkflowClient();
String url = DOCUMENTS_RESOURCE + uniqueid + "?items=$snapshotid";
logger.finest("...... read snapshotid: " + url + "....");

XMLDataCollection xmlDocument = documentClient.getCustomResourceXML(url);
if (xmlDocument != null && xmlDocument.getDocument().length > 0) {
ItemCollection document = XMLDocumentAdapter.putDocument(xmlDocument.getDocument()[0]);
Expand All @@ -137,10 +136,10 @@ public String readSnapshotIDByUniqueID(String uniqueid) throws ArchiveException
}

public void restoreSnapshot(ItemCollection snapshot) throws ArchiveException {
DocumentClient documentClient = initWorkflowClient();
String url = SNAPSHOT_RESOURCE;
logger.finest("...... post data: " + url + "....");
try {
DocumentClient documentClient = initWorkflowClient();
String url = SNAPSHOT_RESOURCE;
logger.finest("...... post data: " + url + "....");
// documentClient.postDocument(url, snapshot);
documentClient.postXMLDocument(url, XMLDocumentAdapter.getDocument(snapshot));
} catch (RestAPIException e) {
Expand All @@ -151,10 +150,10 @@ public void restoreSnapshot(ItemCollection snapshot) throws ArchiveException {
}

public void deleteSnapshot(String id) throws ArchiveException {
DocumentClient documentClient = initWorkflowClient();
String url = SNAPSHOT_RESOURCE;
logger.finest("...... delete data: " + url + "....");
try {
DocumentClient documentClient = initWorkflowClient();
String url = SNAPSHOT_RESOURCE;
logger.finest("...... delete data: " + url + "....");
documentClient.deleteDocument(id);
} catch (RestAPIException e) {
String errorMessage = "...failed to deleteSnapshot: " + e.getMessage();
Expand All @@ -166,8 +165,10 @@ public void deleteSnapshot(String id) throws ArchiveException {
/**
* Helper method to initalize a Melman Workflow Client based on the current
* archive configuration.
*
* @throws RestAPIException
*/
DocumentClient initWorkflowClient() {
DocumentClient initWorkflowClient() throws RestAPIException {

logger.finest("...... WORKFLOW_SERVICE_ENDPOINT = " + workflowServiceEndpoint);

Expand All @@ -183,7 +184,8 @@ DocumentClient initWorkflowClient() {

} else {
// default basic authenticator
BasicAuthenticator basicAuth = new BasicAuthenticator(workflowServiceUser.get(), workflowServicePassword.get());
BasicAuthenticator basicAuth = new BasicAuthenticator(workflowServiceUser.get(),
workflowServicePassword.get());
// register the authenticator
documentClient.registerClientRequestFilter(basicAuth);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@ public class TestRestAPI {
public void simpleApiTest() {

String apiURL = "http://localhost:8081/api";
try {

DocumentClient documentClient = new DocumentClient(apiURL);
FormAuthenticator formAuth = new FormAuthenticator(apiURL, "admin", "adminadmin");
// register the authenticator
documentClient.registerClientRequestFilter(formAuth);

DocumentClient documentClient = new DocumentClient(apiURL);
FormAuthenticator formAuth = new FormAuthenticator(apiURL, "admin", "adminadmin");
// register the authenticator
documentClient.registerClientRequestFilter(formAuth);

List<ItemCollection> result = documentClient.getCustomResource(apiURL + "/snapshot/syncpoint/0");

try {
List<ItemCollection> result = documentClient.getCustomResource(apiURL+"/snapshot/syncpoint/0");

Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());

} catch (Exception e) {

e.printStackTrace();
Assert.fail();
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakarta.version>10.0.0</jakarta.version>
<org.imixs.workflow.version>6.0.3-SNAPSHOT</org.imixs.workflow.version>
<org.imixs.melman.version>2.0.0</org.imixs.melman.version>
<org.imixs.melman.version>2.0.1-SNAPSHOT</org.imixs.melman.version>
<apache.pdfbox.version>2.0.21</apache.pdfbox.version>
<microprofile.version>3.0</microprofile.version>
<microprofile-metrics.version>2.3</microprofile-metrics.version>
Expand Down

0 comments on commit 025e48f

Please sign in to comment.