Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tm-dev] Programatic Creation of Filters/Pools/References

Yeah, the package name can be confusing there but we were not able to migrate it to the rse.core plugin due to some dependencies.

I'm glad this works for you now!
____________________________________
David McKnight
Phone: 905-413-3902 , T/L: 969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail: D1/YFY/8200/TOR
____________________________________


Inactive hide details for Daniel Johnson ---17/08/2011 01:14:06 PM---That works!  I just assumed it was in org.eclipse.rse.coreDaniel Johnson ---17/08/2011 01:14:06 PM---That works! I just assumed it was in org.eclipse.rse.core :-) Here is the final block of code that


From:

Daniel Johnson <danijoh2@xxxxxxxxx>

To:

David McKnight/Toronto/IBM@IBMCA

Cc:

TM project developer discussions <tm-dev@xxxxxxxxxxx>, tm-dev-bounces@xxxxxxxxxxx

Date:

17/08/2011 01:14 PM

Subject:

Re: [tm-dev] Programatic Creation of Filters/Pools/References




That works! I just assumed it was in org.eclipse.rse.core :-) Here is the final block of code that does everything the right way:
...
for (ISubSystem subSystem : host.getSubSystems()) {
// We only care about the SFTP subsystem
if (subSystem.getName().equals("Sftp Files")) {
// Get this subsystems private Filter Pool specific to this host
ISystemFilterPool pool = ((SubSystem)subSystem).getConnectionPrivateFilterPool(true);
if (pool != null) {
// Check if the filter already exists
ISystemFilter filter = pool.getSystemFilter("MyFilter");
if (filter == null) {
// Create the filter
IRemoteFileSubSystemConfiguration config = (IRemoteFileSubSystemConfiguration) subSystem.getSubSystemConfiguration();
RemoteFileFilterString filterString = new RemoteFileFilterString(config);
filterString.setPath("/path/of/super/secret/resource");
String[] filterStrings = new String[] {filterString.toString()};
pool.createSystemFilter("MyFilter", filterStrings);
}
}
}
}
...

Thanks so much for the help David!

Cheers,
Daniel Johnson

On Aug 17, 2011, at 9:55 AM, David McKnight wrote:
      Sorry, I can't see your screen captures via this method. I think you'll have to attach them (rather than embed them) for me to see them.

      The SubSystem class has always existed. You'll need to add the
      org.eclipse.rse.ui plugin as a dependency.

      ____________________________________
      David McKnight
      Phone: 905-413-3902 , T/L: 969-3902
      Internet:
      dmcknigh@xxxxxxxxxx
      Mail: D1/YFY/8200/TOR
      ____________________________________


      <graycol.gif>
      Daniel Johnson ---17/08/2011 12:49:02 PM---It seems that SubSystem did not exist in 3.2.0v201105311250 though, as seen in my previous screensho
      <ecblank.gif>
      From:
      <ecblank.gif>
      Daniel Johnson <danijoh2@xxxxxxxxx>
      <ecblank.gif>
      To:
      <ecblank.gif>
      David McKnight/Toronto/IBM@IBMCA
      <ecblank.gif>
      Cc:
      <ecblank.gif>
      TM project developer discussions <tm-dev@xxxxxxxxxxx>, tm-dev-bounces@xxxxxxxxxxx
      <ecblank.gif>
      Date:
      <ecblank.gif>
      17/08/2011 12:49 PM
      <ecblank.gif>
      Subject:
      <ecblank.gif>
      Re: [tm-dev] Programatic Creation of Filters/Pools/References




      It seems that SubSystem did not exist in 3.2.0v201105311250 though, as seen in my previous screenshot. I tried to cast to RemoteFileSubSystem, but then had compile errors with:
      - The type org.eclipse.rse.core.subsystems.SubSystem cannot be resolved. It is indirectly referenced from required .class
      files


      My knowledge about class path compile errors is pretty weak, so if you have any ideas I will try them, otherwise I will work towards using version 3.3.


      Thanks,
      Dan


      On Aug 17, 2011, at 9:30 AM, David McKnight wrote:
              I did this using RSE 3.2.x. The trick is you have to cast the ISubSystem to a SubSystem. I'm not sure why we didn't put getConnectionPrivateFilterPool() in the ISubSystem interface.
              ____________________________________
              David McKnight
              Phone: 905-413-3902 , T/L: 969-3902
              Internet:
              dmcknigh@xxxxxxxxxx
              Mail: D1/YFY/8200/TOR
              ____________________________________


              <graycol.gif>
              Daniel Johnson ---17/08/2011 12:25:49 PM---Unfortunately that seems to be a 3.3 class (see screenshot). Does 3.3 work with Eclipse 3.6? I will
              <ecblank.gif>
              From:
              <ecblank.gif>
              Daniel Johnson <
              danijoh2@xxxxxxxxx>
              <ecblank.gif>
              To:
              <ecblank.gif>
              David McKnight/Toronto/IBM@IBMCA
              <ecblank.gif>
              Cc:
              <ecblank.gif>
              TM project developer discussions <
              tm-dev@xxxxxxxxxxx>, tm-dev-bounces@xxxxxxxxxxx
              <ecblank.gif>
              Date:
              <ecblank.gif>
              17/08/2011 12:25 PM
              <ecblank.gif>
              Subject:
              <ecblank.gif>
              Re: [tm-dev] Programatic Creation of Filters/Pools/References




              Unfortunately that seems to be a 3.3 class (see screenshot). Does 3.3 work with Eclipse 3.6? I will try to work towards getting 3.3 and trying it instead of wasting more time on 3.2.
              Thanks,
              Dan

              On Aug 17, 2011, at 9:09 AM, David McKnight wrote:
                              Hi Daniel,

                              What if you do the following?


                              // 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 =
                              ((SubSystem)subSystem).getConnectionPrivateFilterPool(true);
                              if
                              (pool != null) {
                              poolManager.createSystemFilter(pool,
                              "MyFilter", new String[] {"/path/of/super/secret/resource/"});
                              }


                              ____________________________________
                              David McKnight
                              Phone: 905-413-3902 , T/L: 969-3902
                              Internet:
                              dmcknigh@xxxxxxxxxx
                              Mail: D1/YFY/8200/TOR
                              ____________________________________


                              <graycol.gif>
                              Daniel Johnson ---17/08/2011 12:01:04 PM---Hey David, That would work if my filter path was the same for each server, but that is not the case.
                              <ecblank.gif>
                              From:
                              <ecblank.gif>
                              Daniel Johnson <
                              danijoh2@xxxxxxxxx>
                              <ecblank.gif>
                              To:
                              <ecblank.gif>
                              David McKnight/Toronto/IBM@IBMCA
                              <ecblank.gif>
                              Cc:
                              <ecblank.gif>
                              TM project developer discussions <
                              tm-dev@xxxxxxxxxxx>, tm-dev-bounces@xxxxxxxxxxx
                              <ecblank.gif>
                              Date:
                              <ecblank.gif>
                              17/08/2011 12:01 PM
                              <ecblank.gif>
                              Subject:
                              <ecblank.gif>
                              Re: [tm-dev] Programatic Creation of Filters/Pools/References




                              Hey David,

                              That would work if my filter path was the same for each server, but that is not the case. I need a new Filter Pool for each server created so that they can specify their own unique path for that filter, and then make a reference to that filter pool.

                              Thanks,
                              Dan

                              On Aug 17, 2011, at 8:01 AM, David McKnight wrote:
                                                              Hi Daniel,

                                                              I tried the following and I didn't hit any problems:


                                                              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.getFirstDefaultSystemFilterPool();


                                                              if
                                                              (pool != null) {
                                                              poolManager.createSystemFilter(pool,
                                                              "MyFilter", new String[] {"/path/of/super/secret/resource/"});
                                                              }
                                                              }



                                                              You can use the default filter pool for your profile and I don't think you need to explicitly call
                                                              addReferenceToSystemFilterPool().
                                                              ____________________________________
                                                              David McKnight
                                                              Phone: 905-413-3902 , T/L: 969-3902
                                                              Internet:
                                                              dmcknigh@xxxxxxxxxx
                                                              Mail: D1/YFY/8200/TOR
                                                              ____________________________________


                                                              <graycol.gif>
                                                              Daniel Johnson ---17/08/2011 10:53:48 AM---A filter must belong to a filter pool, and then subsystems make references to the filter pools, it i
                                                              <ecblank.gif>
                                                              From:
                                                              <ecblank.gif>
                                                              Daniel Johnson <
                                                              danijoh2@xxxxxxxxx>
                                                              <ecblank.gif>
                                                              To:
                                                              <ecblank.gif>
                                                              Daniel Johnson <
                                                              danijoh2@xxxxxxxxx>
                                                              <ecblank.gif>
                                                              Cc:
                                                              <ecblank.gif>
                                                              TM project developer discussions <
                                                              tm-dev@xxxxxxxxxxx>, tm-dev-bounces@xxxxxxxxxxx
                                                              <ecblank.gif>
                                                              Date:
                                                              <ecblank.gif>
                                                              17/08/2011 10:53 AM
                                                              <ecblank.gif>
                                                              Subject:
                                                              <ecblank.gif>
                                                              Re: [tm-dev] Programatic Creation of Filters/Pools/References
                                                              <ecblank.gif>
                                                              Sent by:
                                                              <ecblank.gif>
                                                              tm-dev-bounces@xxxxxxxxxxx




                                                              A filter must belong to a filter pool, and then subsystems make references to the filter pools, it is up to the user to actually show the filter pool or not.

                                                              http://help.eclipse.org/indigo/topic/org.eclipse.rse.doc.isv/guide/Model.html
                                                              -- Dan

                                                              On Aug 16, 2011, at 5:35 PM, Daniel Johnson wrote:
                                                                                                                              Hello All,

                                                                                                                              I have attached four screenshots to help clarify what I am seeing.

                                                                                                                              The first screenshot is after adding my two server proxies, it shows that the Filter Pools are being created correctly and that everything behaves correctly. Both servers refer to a common "*** Server Hosts:ssh.files" Filter Pool, and then each has its own Filter Pool, "MyServer:ssh.files" and "My2ndServer:ssh.files" respectively.

                                                                                                                              The second screenshot is right when I open up Eclipse, showing the NPE I encounter, right away you can see the decoraters are messed up in the RSE view.

                                                                                                                              The third screenshot is opening the "Select Filter Pools" dialog on My2ndServer, and seeing that now only the "My2ndServer:ssh.files" Filter Pool has been loaded successfully.

                                                                                                                              Further, if I then add a new proxy, "MyThirdServer", then suddenly the common Filter Pool "*** Server Hosts:ssh.files" starts working for all three servers, but the "MyServer:ssh.files" Filter Pool is still unresolved, as seen in the fourth screenshot.

                                                                                                                              I debugged the code and addReferenceToSystemFilterPool(pool) does a .commit() of the whole profile, and while debugging the commit it correctly stepped through every Filter Pool Reference.

                                                                                                                              It is starting to seem like it is actually a problem with persisting the Filter Pools themselves, as the Filter Pool References seem to work again as soon as the Filter Pool is re-created.

                                                                                                                              I should also note that the common Filter Pool works fine between servers as long as I remove this code for adding the unique pool.

                                                                                                                              Finally, here is some updated 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);
                                                                                                                              }


                                                                                                                              // Create the XMP_HOME filter in the Remote Systems Explorer view

                                                                                                                              for
                                                                                                                              (ISubSystem subSystem : host.getSubSystems()) {
                                                                                                                              if
                                                                                                                              (subSystem.getName().equals("Sftp Files")) {
                                                                                                                              ISubSystemConfiguration config = subSystem.getSubSystemConfiguration();
                                                                                                                              ISystemFilterPoolManager poolManager = config.getFilterPoolManager(myProfile);
                                                                                                                              ISystemFilterPool pool = poolManager.createSystemFilterPool(server.getName()+
                                                                                                                              ":ssh.files", true);
                                                                                                                              // pool==null when the pool with the name has already been created

                                                                                                                              if
                                                                                                                              (pool != null) {
                                                                                                                              ISystemFilter filter = pool.createSystemFilter(
                                                                                                                              "Secret", new String[] {"/path/of/super/secret/resource/"});
                                                                                                                              filter.setSubSystem(subSystem);

                                                                                                                              // filter is showing as being dirty, we will commit it now.

                                                                                                                              filter.commit();
                                                                                                                              ISystemFilterPoolReferenceManager refManager = subSystem.getFilterPoolReferenceManager();

                                                                                                                              // addReferenceToSystemFilterPool implementation will do a commit

                                                                                                                              refManager.addReferenceToSystemFilterPool(pool);
                                                                                                                              }
                                                                                                                              }
                                                                                                                              }
                                                                                                                              -------------------------------------------------------------------------------

                                                                                                                              It seems that the call to commit() works all the way up to the SystemProfile, and then goes down through all its children, so the final call to addReferenceToSystemFilterPool should take care of persisting all of the new data.

                                                                                                                              Thanks,
                                                                                                                              Dan



                                                                                                                              On Aug 16, 2011, at 1:52 PM, Daniel Johnson wrote:
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
<Profiles.png>

GIF image

GIF image


Back to the top