Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I am trying to create a custom Java filter in order to intercept and modify certain publishing events. Per this help pagehttp://support.ptc.com/cs/help/windchill_hc/wc110_hc/index.jspx?id=WCCG_BusLogicCust_WCVisualization_CustPublish&action=show, I should be able to intercept all calls made to the publisher, and then do my own thing instead. Here is the relevant section:
An Advanced Technique for General Publishing
Combining the concepts in Procedure – Invoking Publishing from Custom Code/Workflow with Filtering All Publishing you can open up additional flexibility for general publishing. The technique simply requires you to insert the use of the doPublish method from the Publisher class into the filterMethod shown in the previous subsection. Since the filter method must return a Boolean, simply return Boolean.FALSE and use the doPublish method to cause Publish Jobs to be queued up for execution.
For example you want to provide specific naming information for publishes that were not made from Windchill stored data.
public static Boolean filterMethod(Persistable p, Boolean publishFromDB) {
if (publishFromDB) return Boolean.TRUE;
try {
String objRef = ObjectReference.newObjectReference(p).toString();
Publisher pub = new Publisher();
pub.doPublish(false, true, objRef, (ConfigSpec)null,
(ConfigSpec)null, true, “Not From Windchill Data”,
“”, Publisher.NONE, null, 0);
} catch (WTException wte) {
wte.printStackTrace();
}
return Boolean.FALSE;
}
The problem I having is I'm unable to determine the parameters that were fed to the job to begin with. A typical doPublish method call will include the following parameters:
In order to make an informed decision on how to process the publishing request, I need to know these things. For example, submitting a manual publish request will definitely pre-set some of these values:
How do I capture these values? PTC tech support is telling me the filterMethod is a lightweight class that doesn't have access to the publishing event request parameters. Does anyone here in the community have a workaround? Some other way that I can capture these values prior to the doPublish event actually being called?
Thanks!