[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Workplace Management - conditions on XML based Function Tree configuration  XML
Forum Index -> Development
Author Message
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5521
Offline

(from mail conversation)

The workpalce management allows to define function trees by XML configuration. The question is, if it possible to somehow influence the procedure from bringing the XML into the workplace, so that certain items are filtered out (e.g. due to security reason).

The number one response of course is: build the WorkplaceFunctionTreeInfoNode-hierarchy dynamically instead of having it configured in "static XML". But this is not really the reflecting the problem here...

So, there is a way:

WorkplaceFunctionsManager has a static Class which you can set via the initFunctionTreeClass method. - The corresponding parts of code are:

Code:
     public static class FunctionTree extends WorkplaceFunctionTreeFromInfoNode implements Serializable
     {
         public FunctionTree(IDispatcher owner, WorkplaceFunctionTreeInfoNode rootNode)
         {
             super(owner, rootNode);
         }
     }
     
 
     static Class s_functionTreeClass = FunctionTree.class;
     
     public static void initFunctionTreeClass(Class clazz)
     {
         s_functionTreeClass = clazz;
     }
 
     private FunctionTree createFunctionTree(IWorkpageDispatcher owner, WorkplaceFunctionTreeInfoNode infoNode)
     {
         FunctionTree tree = null;
         try
         {
             Constructor con = s_functionTreeClass.getConstructor(IDispatcher.class,WorkplaceFunctionTreeInfoNode.class);
             return (FunctionTree) con.newInstance(owner,infoNode);
         }
         catch (Throwable t)
         {
             CLog.L.log(CLog.LL_INF,"Problem creating FunctionTree with class: " + s_functionTreeClass.getName(),t);
             tree = new FunctionTree(owner,infoNode);
         }
         return tree;
     }
 
 
 


You now can extend the "FunctionTree" class by some own implementation. In the implementation you may override the method:

Code:
     protected boolean checkIfToRenderNode(WorkplaceFunctionTreeInfoNode node)
     {
         return true;
     }
 


So you receive the function node (which is read from XML) and you can decide if the really render it or not.

CaptainCasa uses this function internally as well, for having one demo workplace in which certain nodes which are e.g. Swing-client-specific are not rendered within a RISC-HTML environment.

Regards, Björn

Björn Müller, CaptainCasa GmbH
mreich

Power User
[Avatar]

Joined: 30/01/2009 08:34:23
Messages: 744
Offline

great hint!
so the best place to set this is in the Dispatcher.java I think?
Code:
WorkplaceFunctionsManager.initFunctionTreeClass(MyFunctionTree.class);
[WWW]
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5521
Offline

...yes... - best by doing something like:

Code:
 
 public Dispatcher()
 {
    StaticsInitializer.initialize();
 }
 


und dann so was wie

Code:
 public class StaticsInitializer()
 {
     static boolean s_initialized = false;
     static Object s_synchronizer = new Object();
     public static void initialize()
     {
         if (s_initialied == false)
         {
             synchronized(s_synchronizer)
             {
                 if (s_initialized == false)
                 {
                     ...
                     ...
                     s_initialized = true;
                 }
             }
         }
     }
 }
 


I know that you would never do it in some other way! ;-) But I have seen too many cases in which the initialization/start up of things is somehow distributed over many classes and in which synchronization issues during startup are not handled.

Regards, Björn

Björn Müller, CaptainCasa GmbH
dperezlopez

Active

Joined: 23/01/2015 14:55:04
Messages: 18
Offline

Hi all, for testing I just returned false for all nodes but I see that sections are still rendered so I assume that if there is a similar check for them it is placed in another class. Can you give us some light there, Björn?

David
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5521
Offline

Hi,

yes, the check is done only within a function tree processing. We can extend this on top level of "big sections" as well.

Regards, Björn

Björn Müller, CaptainCasa GmbH
dperezlopez

Active

Joined: 23/01/2015 14:55:04
Messages: 18
Offline

That would be great, Björn. Because if a user doesn't have permission for any of the items in a section, it is irrelevant for him/her to see the empty section + we would gain some precious space. Thanks!

David
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5521
Offline

...I already implemented it (before I forget about it...). Is part of next update...

Regard, Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team