How to Change the Alfresco Share Landing Page to Document Library page for all users

cancel
Showing results for 
Search instead for 
Did you mean: 
alfrescouser99
Member II

How to Change the Alfresco Share Landing Page to Document Library page for all users

Hi, after making below changes, I tried logging in as admin to see changes. I get the below error page rather accessing the document library page. What could be the reason 

<%@ page import="org.alfresco.web.site.*" %>
<%@ page import="org.springframework.extensions.surf.*" %>
<%@ page import="org.springframework.extensions.surf.site.*" %>
<%@ page import="org.springframework.extensions.surf.util.*" %>
<%@ page import="java.util.*" %>
<%
   <!-- // retrieve user name from the session -->
   String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID);
   <!-- // test user dashboard page exists? -->
   RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
   if (!context.getObjectService().hasPage("user/" + userid + "/dashboard"))
   {
   <!-- // no user dashboard page found! create initial dashboard for this user... -->
      Map<String, String> tokens = new HashMap<String, String>();
      tokens.put("userid", userid);
      FrameworkUtil.getServiceRegistry().getPresetsManager().constructPreset("user-dashboard", tokens);
   }
   
   <!-- // redirect to site or user dashboard as appropriate -->
   String siteName = request.getParameter("enterprise");
   if (siteName == null || siteName.length() == 0)
   {
   <!-- // Get and forward to user's home page -->
      SlingshotUserFactory slingshotUserFactory = 
              (SlingshotUserFactory) FrameworkUtil.getServiceRegistry().getUserFactory();
      String userHomePage = slingshotUserFactory.getUserHomePage(context, userid);
      response.sendRedirect(request.getContextPath() + userHomePage);
   }
   else
   {
   <!-- // forward to site specific dashboard page -->
      response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) + "/documentlibrary");
   }
%>
<%
   <!-- // retrieve user name from the session -->
   String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID);
   <!-- // test user dashboard page exists? -->
   RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
   if (!context.getObjectService().hasPage("user/" + userid + "/dashboard"))
   {
   <!-- // no user dashboard page found! create initial dashboard for this user... -->
      Map<String, String> tokens = new HashMap<String, String>();
      tokens.put("userid", userid);
      FrameworkUtil.getServiceRegistry().getPresetsManager().constructPreset("user-dashboard", tokens);
   }
   
   <!-- // redirect to site or user dashboard as appropriate -->
   String siteName = request.getParameter("enterprise");
   if (siteName == null || siteName.length() == 0)
   {
   <!-- // Get and forward to user's home page -->
      SlingshotUserFactory slingshotUserFactory = 
              (SlingshotUserFactory) FrameworkUtil.getServiceRegistry().getUserFactory();
      String userHomePage = slingshotUserFactory.getUserHomePage(context, userid);
      response.sendRedirect(request.getContextPath() + userHomePage);
   }
   else
   {
   <!-- // forward to site specific dashboard page -->
      response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) + "/documentlibrary");
   }
%>

Capture.PNG

 

5 Replies
sanjaybandhniya
Intermediate

Re: How to Change the Alfresco Share Landing Page to Document Library page for all users

Hi,

What type of changes you have performed in these pages?

alfrescouser99
Member II

Re: How to Change the Alfresco Share Landing Page to Document Library page for all users

Thank you! After making below changes now I can see the changes been implemented but I would like to make the page dynampic so any site user can directly visit document library page. From the below I have hard coded to siteName = "enterprise"; can we change it to dynamic. 

<%@ page import="org.alfresco.web.site.*" %>
<%@ page import="org.springframework.extensions.surf.*" %>
<%@ page import="org.springframework.extensions.surf.site.*" %>
<%@ page import="org.springframework.extensions.surf.util.*" %>
<%@ page import="java.util.*" %>
<%
   // retrieve user name from the session
   String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID);
   
   // test user dashboard page exists?
   RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
   if (!context.getObjectService().hasPage("user/" + userid + "/dashboard"))
   {
      // no user dashboard page found! create initial dashboard for this user...
      Map<String, String> tokens = new HashMap<String, String>();
      tokens.put("userid", userid);
      FrameworkUtil.getServiceRegistry().getPresetsManager().constructPreset("user-dashboard", tokens);
   }
   
   // redirect to site or user dashboard as appropriate
   String siteName = request.getParameter("site");
   siteName = "enterprise";
   if (siteName == null || siteName.length() == 0)
   {
      // Get and forward to user's home page
      SlingshotUserFactory slingshotUserFactory = 
              (SlingshotUserFactory) FrameworkUtil.getServiceRegistry().getUserFactory();
      String userHomePage = slingshotUserFactory.getUserHomePage(context, userid);
      response.sendRedirect(request.getContextPath() + userHomePage);
   }
   else
   {
      // forward to site specific dashboard page
      response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) + "/documentlibrary");
   }
%>

 

alfrescouser99
Member II

Re: How to Change the Alfresco Share Landing Page to Document Library page for all users

Can someone provide your input on this. Thanks

sanjaybandhniya
Intermediate

Re: How to Change the Alfresco Share Landing Page to Document Library page for all users

Below Changes will redurect you to Document Library of Particular Site.

response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName)+"/documentlibrary");

alfrescouser99
Member II

Re: How to Change the Alfresco Share Landing Page to Document Library page for all users

I tried the below patch but I get to a screen   

" Something's wrong with this page...

We may have hit an error or something might have been removed or deleted, so check that the URL is correct.

Alternatively you might not have permission to view the page (it could be on a private site) or there could have been an internal error. Try checking with your Alfresco administrator.

If you're trying to get to your home page and it's no longer available you should change it by clicking your name on the Alfresco toolbar."

<%@ page import="org.alfresco.web.site.*" %>
<%@ page import="org.springframework.extensions.surf.*" %>
<%@ page import="org.springframework.extensions.surf.site.*" %>
<%@ page import="org.springframework.extensions.surf.util.*" %>
<%@ page import="java.util.*" %>
<%
   response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName)+"/documentlibrary");
%>