Author |
Message |
14/08/2017 16:10:57
|
CaptainCasa
Power User
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 |
|
|
17/08/2017 18:41:03
|
mreich
Power User
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);
|
|
|
17/08/2017 18:46:43
|
CaptainCasa
Power User
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 |
|
|
22/08/2017 10:27:07
|
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 |
|
|
23/08/2017 08:05:19
|
CaptainCasa
Power User
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 |
|
|
23/08/2017 08:28:04
|
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 |
|
|
23/08/2017 09:19:44
|
CaptainCasa
Power User
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 |
|
|
|