As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<%@ 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.*" %> <%@ page import="java.io.IOException" %> <%@ page import="java.net.URL" %> <%@ page import="org.apache.commons.io.IOUtils" %> <%@ page import="org.json.simple.JSONArray" %> <%@ page import="org.json.simple.JSONObject" %> <%@ page import="org.json.simple.JSONValue" %> <%@ page import="org.json.simple.parser.ParseException" %> <%@ page import="org.json.JSONException" %> <% //retrieve user name from the session (site-index OTB fragment) String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID); //retrieve JSON array from the people/userid/sites String url = "http://localhost:8080/alfresco/service/api/people/" + userid + "/sites"; String peopleJson = IOUtils.toString(new URL(url)); JSONObject peopleJsonObject = (JSONObject) JSONValue.parseWithException(peopleJson); // get the site user id(shortName) JSONArray siteArray = (JSONArray) peopleJsonObject.get("shortName"); // get the first site JSONObject usersitejson = (JSONObject) siteArray.get(0); String usersite = usersitejson.toString(); // Admin redirection validation if (usersite == null || usersite.length() == 0 || userid == "admin") // forward to user specific dashboard page(admin) { response.sendRedirect(request.getContextPath() + "/page/user/" + URLEncoder.encode(userid) + "/dashboard"); } else // forward to user respective site documentlibrary { response.sendRedirect(request.getContextPath() + "/page/sites/" + URLEncoder.encode(usersite) + "/documentlibrary"); } %>