With DM and DAM enabled how would I force certain users to default to the DAM tab on Login?

Some users of DAM are pure consumers of digital assets and will only use the DAM interface. When they first login I would like them to see the DAM ui by default, and I would also like to hide the DM tab for those users. I will put these users into a group called “DAM Only” and then create a filter on the DM tab to hide it (or not show it) for users in the DAM Only group. But how do I re-direct these users to the DAM ui by default?

Thanks, Bruce.

1 votes

3 answers

1237 views

ANSWER



The easiest way to redirect the user on the DAM tab is to override the default startupHelper used by Nuxeo by a custom one in you own module, something like:

import static org.jboss.seam.ScopeType.SESSION;

import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.nuxeo.ecm.core.api.NuxeoPrincipal;
import org.nuxeo.ecm.platform.ui.web.api.WebActions;
import org.nuxeo.ecm.webapp.helpers.StartupHelper;

@Name("startupHelper")
@Scope(SESSION)
@Install(precedence = 11) // default install precedence APPLICATION is set to 10
public class CustomStartupHelper extends StartupHelper {

    private static final long serialVersionUID = -1L;

    @In(create = true)
    protected transient WebActions webActions;

    @Override
    @Begin(id = "#{conversationIdGenerator.nextMainConversationId}", join = true)
    public String initDomainAndFindStartupPage(String domainTitle, String viewId) {
        String result = super.initDomainAndFindStartupPage(domainTitle, viewId);
        NuxeoPrincipal principal = (NuxeoPrincipal) documentManager.getPrincipal();
        if (principal.isMemberOf("DAM Only")) {
            webActions.setCurrentTabIds("MAIN_TABS:dam");
            return "assets";
        } else {
            return result;
        }
    }
}
1 votes



thanks Thomas.
02/14/2012


DM tab is a simple action, so you just have to override it. Here is the definition of this action:

<action id="documents" link="view_documents"
  label="label.main.tab.documents" order="40">
  <category>MAIN_TABS</category>
</action>

defined into the org.nuxeo.ecm.platform.actions component (don't forget to add the require item in your xml) So your contribution must something like:

 <component name="name.you.want.for.you.component">
 <require>org.nuxeo.ecm.platform.actions</require>
<extension target="org.nuxeo.ecm.platform.actions.ActionService"
    point="actions">
<action id="documents" link="view_documents"
  label="label.main.tab.documents" order="40">
  <category>MAIN_TABS</category>
  <filter id="yourFilterName">
    <rule grant="true">
      <condition>... put here your condition ...</condition>
    </rule>
  </filter>
</action>
</component>

Refer to the action documentation and filter documentation that explain With that you will limit the visibility of the tab.

About to not redirect to the DM view, may you will have information here.

Hope this will help you.

2 votes



Thanks - apparently I can only mark one item as answer! But your link to redirect is what I was looking for - and this is shown below.

Cheers, Bruce.

02/14/2012

No problem, I'm fair, even if I'm answered also to the tab part :D
02/14/2012


Thanks to Thomas and Bjalon for their quick response! I started with the code Thomas suggested, but to make it work I had to modify - mainly because the NuxeoPrincipal object is not available, nor is the CoreSession (documentManager) until Domain is initialized. The code below works as expected.

@Name("startupHelper")
@Scope(SESSION)
@Install(precedence = Install.APPLICATION + 1)
public class GripStartupHelper extends StartupHelper {

    private static final long serialVersionUID = -1L;

    @In(create = true)
    protected transient WebActions webActions;

    @Override
    @Begin(id = "#{conversationIdGenerator.nextMainConversationId}", join = true)
    public String initDomainAndFindStartupPage(String domainTitle, String viewId) {

        String result = super.initDomainAndFindStartupPage(domainTitle, viewId);

        NuxeoPrincipal principal = (NuxeoPrincipal) documentManager.getPrincipal();
        if (principal.isMemberOf("DAM Only")) {
            webActions.setCurrentTabIds("MAIN_TABS:dam");
            return "assets";
        } else {
            return result;
        }
    }

}
0 votes



Thanks, I've updated my answer to reflect your changes.
02/14/2012