Package org.olat.core.util

Examples of org.olat.core.util.URIHelper


      // definition the URI is ISO encoded. ureq.getParameter() does use
      // the standard tomcat behaviour. Quite a mess, see here:
      // http://marc.info/?l=tomcat-user&m=121762788714431
      // The URIHelper decodes the uri parameters using UTF-8
      // (OLAT-3846)
      URIHelper uriHelper;
      String reqUri = ureq.getHttpReq().getRequestURI();
      String query = ureq.getHttpReq().getQueryString();
      String getUri = reqUri + "?" + query;
      try {
        uriHelper = new URIHelper(getUri);
      } catch (URISyntaxException e) {
        logWarn("Could not generate URIHelper for URI::" + getUri, e);
        return;
      }

      // handle move events: fire event to parent controller and let him decide
      // if the move should be allowed or not
      if (event.getCommand().equals(CMD_MOVE)) {
        String node = uriHelper.getParameter(PARAM_NODE);
        String oldParent = uriHelper.getParameter(PARAM_OLD_PARENT);
        String newParent = uriHelper.getParameter(PARAM_NEW_PARENT);
        String index = uriHelper.getParameter(PARAM_INDEX);
        int position = Integer.parseInt(index);
        // notify parent controller about the move
        MoveTreeNodeEvent moveEvent = new MoveTreeNodeEvent(node, oldParent, newParent, position);
        fireEvent(ureq, moveEvent);
        // prepare response as javascript string
        StringMediaResource smr = new StringMediaResource();
        // content type javascript forces menu tree to eval result
        smr.setContentType(CONTENT_TYPE_JAVASCRIPT);
        smr.setEncoding(ENCODING_UTF_8);
        if (moveEvent.isResultSuccess()) {
          // send ok back
          smr.setData("b_amt_status=true;");
        } else {
          // send failure and some messages for the user
          smr.setData("b_amt_status_title=\"" + moveEvent.getResultFailureTitle() + "\", b_amt_status_msg=\""
              + moveEvent.getResultFailureMessage() + "\"; b_amt_status=false;");
        }
        ureq.getDispatchResult().setResultingMediaResource(smr);

      } else if (event.getCommand().equals(CMD_CLICK)) {
        String node = uriHelper.getParameter(PARAM_NODE);
        TreeNodeClickedEvent clickedEvent = new TreeNodeClickedEvent(node);
        fireEvent(ureq, clickedEvent);

      } else if (event.getCommand().equals(CMD_EDIT)) {
        String node = uriHelper.getParameter(PARAM_NODE);
        String newValue = uriHelper.getParameter(PARAM_VALUE);
        TreeNodeModifiedEvent editedEvent = new TreeNodeModifiedEvent(node, newValue);
        fireEvent(ureq, editedEvent);

      } else if (event.getCommand().equals(CMD_EXPAND)) {
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        String expandedPath = uriHelper.getParameter(PARAM_PATH);
        Set<String> oldPathes = (Set<String>) guiPrefs.get(TreeController.class, guiPrefsKey);
        if (oldPathes == null) oldPathes = new HashSet<String>();
        Set<String> newPathes = new HashSet();
        for (String oldPath : oldPathes) {
          // remove all parent pathes to reduce redundancy
          if (!expandedPath.startsWith(oldPath)) newPathes.add(oldPath);
        }
        // add newly expaned node
        newPathes.add(expandedPath);
        guiPrefs.putAndSave(TreeController.class, guiPrefsKey, newPathes);
        // return empty resource
        ureq.getDispatchResult().setResultingMediaResource(okMediaResource);
       
      } else if (event.getCommand().equals(CMD_COLLAPSE)) {
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        String collapsedPath = uriHelper.getParameter(PARAM_PATH);
        Set<String> oldPathes = (Set<String>) guiPrefs.get(TreeController.class, guiPrefsKey);
        if (oldPathes == null) oldPathes = new HashSet<String>();
        Set<String> newPathes = new HashSet();
        for (String oldPath : oldPathes) {
          // remove all child pathes
View Full Code Here


      String origUrl = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_ENTRYURL);
      if (origUrl != null) {
        // we had a direct jump request
        // to avoid a endless redirect, remove the guest parameter if any
        // this can happen if a guest has cookies disabled
        String url = new URIHelper(origUrl).removeParameter(GUEST).toString();
        DispatcherAction.redirectTo(response, url);
        return;
      }
      String businessPath = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_BUSINESSPATH);
      if (businessPath != null) {
View Full Code Here

      String origUrl = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_ENTRYURL);
      if (origUrl != null) {
        // we had a direct jump request
        // to avoid a endless redirect, remove the guest parameter if any
        // this can happen if a guest has cookies disabled
        String url = new URIHelper(origUrl).removeParameter(GUEST).toString();
        DispatcherAction.redirectTo(response, url);
        return;
      }
      // 1. check for direct launch urls
      if (!ureq.isValidDispatchURI()) {
View Full Code Here

TOP

Related Classes of org.olat.core.util.URIHelper

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.