Package org.jasig.portal

Examples of org.jasig.portal.UserPreferencesManager


      throws ServletException, IOException {

      IUserInstanceManager userInstanceManager = null;
      IUserInstance ui = null;
    IPerson per = null;
    UserPreferencesManager upm = null;
    IUserLayoutManager ulm = null;

    // make sure the user has a current session
    if (request.getSession(false) == null) {
      log.warn("Attempting to use AJAX preferences as GUEST user");
      printError(response, "Your session has timed out.  Please log in again to make changes to your layout.");
      return;
    }

    try {
            final WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
            userInstanceManager = (IUserInstanceManager) applicationContext.getBean("userInstanceManager", IUserInstanceManager.class);

           
      // Retrieve the user's UserInstance object
      ui = userInstanceManager.getUserInstance(request);

      // Retrieve the user's IPerson object
      per = ui.getPerson();

      // ensure that the user is currently logged in
      if (per.isGuest()) {
        log.warn("Attempting to use AJAX preferences as GUEST user");
        printError(response, "Your session has timed out.  Please log in again to make changes to your layout.");
        return;
      }

      // Retrieve the preferences manager
      upm = (UserPreferencesManager) ui.getPreferencesManager();

      // Retrieve the layout manager
      ulm = upm.getUserLayoutManager();

    } catch (RuntimeException e) {
      log.error(e, e);
      printError(response, "An unknown error occurred.");
      return;
View Full Code Here


            throws IOException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);
        IPerson per = getPerson(ui, response);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();

        try {

            // if the element ID starts with the fragment prefix and is a folder,
            // attempt first to treat it as a pulled fragment subscription
View Full Code Here

            HttpServletResponse response) throws IOException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);
        IPerson per = getPerson(ui, response);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();

        // Get the fragment owner's name from the request and construct
        // an IPerson object representing that user
        String fragmentOwnerName = request.getParameter("sourceID");
        if (StringUtils.isBlank(fragmentOwnerName)) {
            log.warn("Attempted to subscribe to tab with null owner ID");
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return null;
        }
        RestrictedPerson fragmentOwner = PersonFactory.createRestrictedPerson();
        fragmentOwner.setUserName(fragmentOwnerName);

        // Mark the currently-authenticated user as subscribed to this fragment.
        // If an inactivated fragment registration already exists, update it
        // as an active subscription.  Otherwise, create a new fragment
        // subscription.
        IUserFragmentSubscription userFragmentInfo = userFragmentInfoDao
            .getUserFragmentInfo(per, fragmentOwner);
        if (userFragmentInfo == null) {
            userFragmentInfo = userFragmentInfoDao.createUserFragmentInfo(per,
                    fragmentOwner);
        } else {
            userFragmentInfo.setActive(true);
            userFragmentInfoDao.updateUserFragmentInfo(userFragmentInfo);
        }

        try {
            // reload user layout and stylesheet to incorporate new DLM fragment
            ulm.loadUserLayout(true);

            // get the target node this new tab should be moved after
            String destinationId = request.getParameter("elementID");

            // get the user layout for the currently-authenticated user
            int uid = userIdentityStore.getPortalUID(fragmentOwner, false);
            final DistributedUserLayout userLayout = userLayoutStore.getUserLayout(per, upm.getUserProfile());
            Document layoutDocument = userLayout.getLayout();

            // attempt to find the new subscribed tab in the layout so we can
            // move it
            StringBuilder expression = new StringBuilder("//folder[@type='root']/folder[starts-with(@ID,'")
View Full Code Here

        IUserInstance ui = userInstanceManager.getUserInstance(request);
        IPerson per = getPerson(ui, response);
        final Locale locale = RequestContextUtils.getLocale(request);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();

    // portlet to be moved
    String sourceId = request.getParameter("sourceID");

    // Either "insertBefore" or "appendAfter".
View Full Code Here

      @RequestParam(value = "acceptor", required = false) String acceptor) throws IOException, PortalException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);
        IPerson per = getPerson(ui, response);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();

    int newColumnCount = widths.length;

    // build a list of the current columns for this tab
        @SuppressWarnings("unchecked")
View Full Code Here

  public ModelAndView moveTab(HttpServletRequest request,
      HttpServletResponse response) throws IOException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();
        final Locale locale = RequestContextUtils.getLocale(request);

    // gather the parameters we need to move a channel
    String destinationId = request.getParameter("elementID");
    String sourceId = request.getParameter("sourceID");
View Full Code Here

    @RequestMapping(method= RequestMethod.POST , params = "action=addFavorite")
    public ModelAndView addFavorite(@RequestParam String channelId, HttpServletRequest request) {
        //setup
        IUserInstance ui = userInstanceManager.getUserInstance(request);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();
       
        IUserLayoutChannelDescription channel = new UserLayoutChannelDescription(portletDefinitionRegistry.getPortletDefinition(channelId));
       
        final Locale locale = RequestContextUtils.getLocale(request);
       
View Full Code Here

     * @return returns a mav object with a response attribute for noty
     * @throws IOException if it has problem reading the layout file.
     */
    @RequestMapping(method= RequestMethod.POST , params = "action=removeFavorite")
    public ModelAndView removeFavorite(@RequestParam String channelId, HttpServletRequest request, HttpServletResponse response) throws IOException {
        UserPreferencesManager upm = (UserPreferencesManager) userInstanceManager.getUserInstance(request).getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();
        final Locale locale = RequestContextUtils.getLocale(request);
        IPortletDefinition portletDefinition = portletDefinitionRegistry.getPortletDefinition(channelId);
       
        if(portletDefinition != null &&  StringUtils.isNotBlank(portletDefinition.getFName())) {
            String functionalName = portletDefinition.getFName();
            List<IUserLayoutNodeDescription> favoritePortlets = FavoritesUtils.getFavoritePortlets(ulm.getUserLayout());
           
            //search for the favorite to delete
            EqualPredicate nameEqlPredicate = new EqualPredicate(functionalName);
            Object result = CollectionUtils.find(favoritePortlets, new BeanPredicate("functionalName",nameEqlPredicate));
           
            if(result != null && result instanceof UserLayoutChannelDescription) {
                UserLayoutChannelDescription channelDescription = (UserLayoutChannelDescription)result;
                try {
                    if (!ulm.deleteNode(channelDescription.getChannelSubscribeId())) {
                        log.warn("Error deleting the node" + channelId + "from favorites for user " + (upm.getPerson() == null ? "unknown" : upm.getPerson().getID()));
                        response.setStatus(HttpServletResponse.SC_ACCEPTED);
                        return new ModelAndView("jsonView", Collections.singletonMap("response", getMessage("error.remove.favorite", "Can''t remove favorite", locale)));
                    }
                    // save the user's layout
                    ulm.saveUserLayout();
View Full Code Here

    @RequestMapping(method = RequestMethod.POST, params = "action=addPortlet")
  public ModelAndView addPortlet(HttpServletRequest request, HttpServletResponse response) throws IOException, PortalException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);

        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();

    // gather the parameters we need to move a channel
    String destinationId = request.getParameter("elementID");
    String sourceId = request.getParameter("channelID");
    String method = request.getParameter("position");
View Full Code Here

    @RequestMapping(method = RequestMethod.POST, params="action=addTab")
  public ModelAndView addTab(HttpServletRequest request, HttpServletResponse response, @RequestParam("widths[]") String[] widths) throws IOException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);
        IPerson per = getPerson(ui, response);
        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();

        // Verify that the user has permission to add this tab
        final IAuthorizationPrincipal authPrincipal = this.getUserPrincipal(per.getUserName());
        if (!authPrincipal.hasPermission(ADDTAB_PERMISSION_OWNER, ADDTAB_PERMISSION_ACTIVITY, ADDTAB_PERMISSION_TARGET)) {
            log.warn("Attempt to add a tab through the REST API by unauthorized user '" + per.getUserName() + "'");
View Full Code Here

TOP

Related Classes of org.jasig.portal.UserPreferencesManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.