Hi David,
I am using v3.2.0. In order to see the exception when starting Eclipse you must have "Show Filter Pools" enabled on the RSE view (in view drop-down menu). I tried adding the .commit()'s, but nothing changed. It seems like when subSystem.getFilterPoolReferenceManager().addReferenceToSystemFilterPool(pool);
is called that it removes any reference to other pools that already exist, is it not intended that a pool reference manager have more than one pool reference? I see that old API used to be to setReferencetoSystemFilterPool, and now it is addReferenceToSystemFilterPool(), maybe there is a bug in 3.2.0 that still only allows one reference? I also tried to get the list of references from the manager, add the new reference object, and then setReferences(Reference[]) with all of them, but still only the last one is saved after a restart.
My use case is I have multiple server entries that are using the same profile, and I want "MyFilter" to be slightly different for each server, so I am creating a new Filter Pool for each server within the SFTP subsystems Filter Pool Reference Manager. See the attached screenshot for example. It has a default "My Server Profile" Pool that I want every server to have, and then an extra "My server at <IP.ADDRESS>" Pool that will be unique per server.
After I create these Pools everything seems to work fine, but as soon as I restart only the last created Pool is visible in the list in the screenshot.
Thanks, Dan On Aug 16, 2011, at 12:41 PM, David McKnight wrote: Which version of RSE are you using?
I tried to reproduce this although I had to modify the code since my version doesn't have systemRegistry.getSystemTypeById():
....
// Create with SSH to add the SFTP subsystem
IRSESystemType type = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID);
host = systemRegistry.createHost(myProfile.getName(), type, hostName, hostName, "MyProfile Description");
host.setDefaultUserId(username);
...
When I restart Eclipse, I don't hit the problems you're hitting - I still have "MyFilter". If you make the following commit calls, does filter reference get persisted properly?
ISystemFilter newFilter = pool.createSystemFilter("MyFilter", new String[] {"/path/of/super/secret/resource/"});
newFilter.commit();
// Add a reference from the SFTP subsystem to my new pool
ISystemFilterPoolReference ref = subSystem.getFilterPoolReferenceManager().addReferenceToSystemFilterPool(pool);
ref.commit();
____________________________________
David McKnight
Phone: 905-413-3902 , T/L: 969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail: D1/YFY/8200/TOR
____________________________________
<graycol.gif>Daniel Johnson ---16/08/2011 02:47:15 PM---Hi, I am trying to programmatically create Filter entries on a server, and it seems to work fine, bu
<ecblank.gif>
From: | <ecblank.gif>
Daniel Johnson <danijoh2@xxxxxxxxx> |
<ecblank.gif>
To: | <ecblank.gif>
tm-dev@xxxxxxxxxxx |
<ecblank.gif>
Date: | <ecblank.gif>
16/08/2011 02:47 PM |
<ecblank.gif>
Subject: | <ecblank.gif>
[tm-dev] Programatic Creation of Filters/Pools/References |
<ecblank.gif>
Sent by: | <ecblank.gif>
tm-dev-bounces@xxxxxxxxxxx |
Hi,
I am trying to programmatically create Filter entries on a server, and it seems to work fine, but as soon as I exit Eclipse and re-launch it seems that all of the Filters on that Server are corrupt, with a NPE being thrown in the error log.
Can anyone help explain how to do this and/or what I am doing wrong?
Here is my code:
String hostName = ... // Get host name
String username = ... // Get username
// Create MyProfile
ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
ISystemProfile myProfile = systemRegistry.getSystemProfile("MyProfile");
if (myProfile == null) {
myProfile = systemRegistry.createSystemProfile("MyProfile", true);
}
// Create the host
IHost host = systemRegistry.getHost(myProfile, hostName);
if (host == null) {
// Create with SSH to add the SFTP subsystem
host = systemRegistry.createHost(myProfile.getName(), systemRegistry.getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID), hostName, hostName, "MyProfile Description");
host.setDefaultUserId(username);
}
for (ISubSystem subSystem : host.getSubSystems()) {
// Want the SFTP subsystem
if (subSystem.getName().equals("Sftp Files")) {
ISubSystemConfiguration config = subSystem.getSubSystemConfiguration();
// Get the Pool Manager for my profile type
ISystemFilterPoolManager poolManager = config.getFilterPoolManager(myProfile);
// Create the new filter Pool for my new filter (returns null if it already exists)
ISystemFilterPool pool = poolManager.createSystemFilterPool(server.getName()+":ssh.files", true);
if (pool != null) {
// Create my new filter, this is a brand new Pool so don't worry checking if it already exists
pool.createSystemFilter("MyFilter", new String[] {"/path/of/super/secret/resource/"});
// Add a reference from the SFTP subsystem to my new pool
subSystem.getFilterPoolReferenceManager().addReferenceToSystemFilterPool(pool);
}
}
}
And here is the NPE after restarting Eclipse:
java.lang.NullPointerException
at org.eclipse.rse.internal.ui.view.SystemViewFilterPoolReferenceAdapter.getName(SystemViewFilterPoolReferenceAdapter.java:188)
at org.eclipse.rse.ui.view.AbstractSystemViewAdapter.testAttribute(AbstractSystemViewAdapter.java:1676)
at org.eclipse.ui.internal.ActionExpression$ObjectStateExpression.preciselyMatches(ActionExpression.java:530)
at org.eclipse.ui.internal.ActionExpression$ObjectStateExpression.isEnabledFor(ActionExpression.java:499)
at org.eclipse.ui.internal.ActionExpression$OrExpression.isEnabledFor(ActionExpression.java:582)
at org.eclipse.ui.internal.ActionExpression$SingleExpression.isEnabledFor(ActionExpression.java:743)
at org.eclipse.ui.internal.ActionExpression.isEnabledFor(ActionExpression.java:1053)
at org.eclipse.ui.internal.decorators.DecoratorDefinition.isEnabledFor(DecoratorDefinition.java:282)
Thanks in advance,
Daniel Johnson_______________________________________________
tm-dev mailing list
tm-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/tm-dev
_______________________________________________ tm-dev mailing list tm-dev@xxxxxxxxxxx http://dev.eclipse.org/mailman/listinfo/tm-dev
 |