Skip to content

Commit

Permalink
Add setter with storage for boolean indicating if message is in resend
Browse files Browse the repository at this point in the history
mode.
  • Loading branch information
uhurusurfa committed Oct 2, 2024
1 parent cadcac9 commit 29e1997
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
8 changes: 7 additions & 1 deletion Server/src/main/java/org/openas2/message/BaseMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public abstract class BaseMessage implements Message {
private String compressionType = ICryptoHelper.COMPRESSION_NONE;
private boolean rxdMsgWasSigned = false;
private boolean rxdMsgWasEncrypted = false;
private boolean isResending = false;
private boolean fileCleanupCompleted = false;
private Map<String, Object> options = new HashMap<String, Object>();
private String calculatedMIC = null;
Expand Down Expand Up @@ -104,7 +105,12 @@ public void setStatus(String status) {

public boolean isResend() {
// Determines if message is currently in resend phase
return Message.MSG_STATUS_MSG_RESEND.equals(getStatus());
return isResending;
}

public void setIsResend(boolean resending) {
// Sets resend phase
this.isResending = resending;
}

public Map<String, String> getCustomOuterMimeHeaders() {
Expand Down
1 change: 1 addition & 0 deletions Server/src/main/java/org/openas2/message/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public interface Message extends Serializable {

void setFileCleanupCompleted(boolean cleanupDone);

void setIsResend(boolean resending);
boolean isResend();

String getSubject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class DirectoryResenderModule extends BaseResenderModule {
/** TODO: Remove this when module config enforces setting the action so that the super method does all the work
*
*/
public String getModuleAction() {
String action = super.getModuleAction();
if (action == null) {
return ResenderModule.DO_RESEND;
}
return action;
}
public String getModuleAction() {
String action = super.getModuleAction();
if (action == null) {
return ResenderModule.DO_RESEND;
}
return action;
}

public void handle(String action, Message msg, Map<String, Object> options) throws OpenAS2Exception {
ObjectOutputStream oos = null;
Expand All @@ -67,12 +67,21 @@ public void handle(String action, Message msg, Map<String, Object> options) thro
int retries = Integer.parseInt((String)options.get(ResenderModule.OPTION_RETRIES));
oos.writeObject(method);
oos.writeObject("" + retries);
// Set the resend flag to avoid unwanted processing of the message by the builder module
msg.setIsResend(true);
oos.writeObject(msg);

logger.info("Message put in resend queue" + msg.getLogMsgID());
if (logger.isTraceEnabled()) {
try {
logger.trace("Message object in resender module for storage. Content-Disposition: " + msg.getContentDisposition() + "\n Content-Type : " + msg.getContentType() + "\n Retries : " + retries + "\n HEADERS : " + AS2Util.printHeaders(msg.getData().getAllHeaders()) + "\n Content-Disposition in MSG getData() MIMEPART: " + msg.getData().getContentType() + "\n Attributes: " + msg.getAttributes() + msg.getLogMsgID());
logger.trace("Message object in resender module for storage. Content-Disposition: " +
msg.getContentDisposition() +
"\n Content-Type : " + msg.getContentType() +
"\n Retries : " + retries +
"\n HEADERS : " + AS2Util.printHeaders(msg.getData().getAllHeaders()) +
"\n Content-Disposition in MSG getData() MIMEPART: " + msg.getData().getContentType() +
"\n Attributes: " + msg.getAttributes() + msg.getLogMsgID()
);
} catch (Exception e) {
}
}
Expand Down Expand Up @@ -174,7 +183,7 @@ protected void processFile(File file) throws OpenAS2Exception {

// Transmit the message
if (logger.isInfoEnabled()) {
logger.info("loaded message for resend." + msg.getLogMsgID());
logger.info("Loaded message for resend: " + file.getAbsolutePath() + msg.getLogMsgID());
}
if (logger.isTraceEnabled()) {
try {
Expand Down

0 comments on commit 29e1997

Please sign in to comment.