Skip to content

Commit

Permalink
Prevent non partnership pollers being refreshed (#312)
Browse files Browse the repository at this point in the history
* Make outboxdir available to parent class and subclasses to enhance
logging.

* Fix the partnerships refresh causing the config based pollers to be
stopped

* Fix invalid errordir example setting in generic poller.

* Release notes
  • Loading branch information
uhurusurfa authored Dec 27, 2022
1 parent 641eb93 commit 38561a3
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 25 deletions.
17 changes: 7 additions & 10 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# OpenAS2 Server
# Version 3.4.1
# Version 3.5.0
# RELEASE NOTES
-----
The OpenAS2 project is pleased to announce the release of OpenAS2 3.4.1
The OpenAS2 project is pleased to announce the release of OpenAS2 3.5.0

The release download file is: OpenAS2Server-3.4.1.zip
The release download file is: OpenAS2Server-3.5.0.zip

The zip file contains a PDF document (OpenAS2HowTo.pdf) providing information on installing and using the application.
## NOTE: Testing covers Java 8 to 17. The application should work for older versions down to Java 7 but they are not tested as part of the CI/CD pipeline.

Version 3.4.1 - 2022-12-04
This is an enhancement and minor bugfix release:
Version 3.5.0 - 2022-12-27
This is an enhancement and bugfix release:
**IMPORTANT NOTE**: Please review upgrade notes below if you are upgrading

1. Fix message attributes not being available to partnership config (eg attributes.filename)
2. Add defensie coding for highly questionnable file names sent by partner containing an asterisk such as ".*"
3. Further enhancements to the confog.xml extracting key values to properties to facilitate auto upgrades.
4. Enhance helper scripts to support non-prompting execution allowing invocation from other scripts.
5. Disable the WebUI module by default as it only runs with Java 11 and above.
1. Enhance the file splitter to be more flexible supporting execution as a java app or as a new thread when done inline.
2. Prevent the onfig.xml based pollers from being stopped when the partnerships are refreshed.


##Upgrade Notes
Expand Down
2 changes: 1 addition & 1 deletion Server/src/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<!--
<module classname="org.openas2.processor.receiver.AS2DirectoryPollingModule"
outboxdir="$properties.storageBaseDir$/toAny"
errordir="$properties.storageBaseDir$/toAny/error/$msg.sender.as2_id$-$msg.receiver.as2_id$"
errordir="$properties.storageBaseDir$/toAny/error"
interval="5"
delimiters="-"
mergeextratokens="true"
Expand Down
7 changes: 5 additions & 2 deletions Server/src/main/java/org/openas2/BaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void start() throws OpenAS2Exception {

@Override
public void stop() throws Exception {
destroyPartnershipPollers();
destroyPartnershipPollers(null);
for (Component component : components.values()) {
component.destroy();
}
Expand Down Expand Up @@ -151,11 +151,14 @@ public void startPartnershipPollers() throws OpenAS2Exception {
}
}

public void destroyPartnershipPollers() {
public void destroyPartnershipPollers(String configSourceFilter) {
LOGGER.trace("Destroying partnership pollers...");
List<String> stoppedPollerKeys = new ArrayList<String>();
for (Map.Entry<String, Map<String, Object>> entry : polledDirectories.entrySet()) {
Map<String, Object> meta = entry.getValue();
if (configSourceFilter != null && !meta.get("configSource").equals(configSourceFilter)) {
continue;
}
DirectoryPollingModule poller = (DirectoryPollingModule) meta.get("pollerInstance");
try {
LOGGER.trace("Destroying poller:" + meta);
Expand Down
5 changes: 4 additions & 1 deletion Server/src/main/java/org/openas2/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public interface Session {
String DEFAULT_CONTENT_TRANSFER_ENCODING = "binary";
String LOG_LEVEL_OVERRIDE_KEY = "logging.level.override";

public static final String PARTNERSHIP_POLLER = "partnership"; // Poller configured in a partnership.xml
public static final String CONFIG_POLLER = "config"; // Poller configured in a config.xml

/**
* Lifecycle control method.
*
Expand Down Expand Up @@ -108,7 +111,7 @@ public interface Session {
public void loadPartnershipPoller(Node moduleNode, String partnershipName, String configSource) throws OpenAS2Exception;

public void startPartnershipPollers() throws OpenAS2Exception;
public void destroyPartnershipPollers();
public void destroyPartnershipPollers(String configSourceFilter);

String getBaseDirectory();

Expand Down
2 changes: 1 addition & 1 deletion Server/src/main/java/org/openas2/XMLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void loadProcessorModule(Processor proc, Node moduleNode) throws OpenAS2
// Since the partnerships will not have loaded yet, just use the defaults string as the partnership name
partnershipName = defaultsNode.getNodeValue();
}
loadPartnershipPoller(moduleNode, partnershipName, "configPoller");
loadPartnershipPoller(moduleNode, partnershipName, Session.CONFIG_POLLER);
return;
}
ProcessorModule procmod = (ProcessorModule) XMLUtil.getComponent(moduleNode, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void loadPartnershipsFile() throws OpenAS2Exception {
}

void refreshConfig() throws OpenAS2Exception {
getSession().destroyPartnershipPollers();
getSession().destroyPartnershipPollers(Session.PARTNERSHIP_POLLER);
try {
Element root = getPartnershipsXml().getDocumentElement();
NodeList rootNodes = root.getChildNodes();
Expand Down Expand Up @@ -242,7 +242,7 @@ public void loadPartnership(Map<String, Object> partners, List<Partnership> part
// replace the $parnertship.* placeholders
replacePartnershipPlaceHolders(pollerDoc, partnership);
// Now launch a directory poller module for this config
getSession().loadPartnershipPoller(pollerConfigElem, name, "partnership");
getSession().loadPartnershipPoller(pollerConfigElem, name, Session.PARTNERSHIP_POLLER);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public abstract class DirectoryPollingModule extends PollingModule {
public static final String PARAM_FILE_EXTENSION_EXCLUDE_FILTER = "fileextensionexcludefilter";
public static final String PARAM_FILE_NAME_EXCLUDE_FILTER = "filenameexcluderegexfilter";
private Map<String, Long> trackedFiles;
private String outboxDir;
private String errorDir = null;
private String sentDir = null;
private List<String> allowExtensions;
Expand All @@ -41,8 +40,8 @@ public void init(Session session, Map<String, String> options) throws OpenAS2Exc
// Check all the directories are configured and actually exist on the file
// system
try {
outboxDir = getParameter(PARAM_OUTBOX_DIRECTORY, true);
IOUtil.getDirectoryFile(outboxDir);
setOutboxDir(getParameter(PARAM_OUTBOX_DIRECTORY, true));
IOUtil.getDirectoryFile(getOutboxDir());
errorDir = getParameter(PARAM_ERROR_DIRECTORY, true);
IOUtil.getDirectoryFile(errorDir);
sentDir = getParameter(PARAM_SENT_DIRECTORY, false);
Expand Down Expand Up @@ -82,9 +81,9 @@ public void init(Session session, Map<String, String> options) throws OpenAS2Exc
@Override
public boolean healthcheck(List<String> failures) {
try {
IOUtil.getDirectoryFile(outboxDir);
IOUtil.getDirectoryFile(getOutboxDir());
} catch (IOException e) {
failures.add(this.getClass().getSimpleName() + " - Polling directory is not accessible: " + outboxDir);
failures.add(this.getClass().getSimpleName() + " - Polling directory is not accessible: " + getOutboxDir());
Logger.getLogger(DirectoryPollingModule.class.getName()).log(Level.SEVERE, null, e);
return false;
} catch (InvalidParameterException ex) {
Expand All @@ -100,11 +99,11 @@ public void poll() {
updateTracking();

// scan the directory for new files
scanDirectory(outboxDir);
scanDirectory(getOutboxDir());
} catch (OpenAS2Exception oae) {
oae.log();
} catch (Exception e) {
logger.error("Unexpected error occurred polling directory for files to send: " + outboxDir, e);
logger.error("Unexpected error occurred polling directory for files to send: " + getOutboxDir(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public abstract class PollingModule extends MessageBuilderModule {
private static final String PARAM_POLLING_INTERVAL = "interval";
private Timer timer;
private boolean busy;
private String outboxDir;

public String getOutboxDir() {
return outboxDir;
}

public void setOutboxDir(String outboxDir) {
this.outboxDir = outboxDir;
}

public void init(Session session, Map<String, String> options) throws OpenAS2Exception {
super.init(session, options);
Expand Down Expand Up @@ -52,7 +61,7 @@ public void run() {
poll();
setBusy(false);
} else {
System.out.println("Miss tick");
System.out.println("Miss tick: " + getOutboxDir());
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 3.5.0 - 2022-12-27
This is an enhancement and bugfix release:
**IMPORTANT NOTE**: Please review upgrade notes in the RELEASE-NOTES.md if you are upgrading

1. Enhance the file splitter to be more flexible supporting execution as a java app or as a new thread when done inline.
2. Prevent the onfig.xml based pollers from being stopped when the partnerships are refreshed.

Version 3.4.1 - 2022-12-04
This is an enhancement and minor bugfix release:
**IMPORTANT NOTE**: Please review upgrade notes in the RELEASE-NOTES.md if you are upgrading
Expand Down

0 comments on commit 38561a3

Please sign in to comment.