Java Code Examples for org.apache.commons.lang.StringEscapeUtils.unescapeJavaScript()

The following are Jave code examples for showing how to use unescapeJavaScript() of the org.apache.commons.lang.StringEscapeUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: personium-core   File: EsQueryHandler.java   View Source Code Vote up 6 votes
/**
 * elasticsearchの検索文字列を返却する.
 * @param expr CommonExpression
 * @return elasticsearchの検索文字列
 */
private Object getSearchValue(CommonExpression expr) {
    if (expr instanceof IntegralLiteral) {
        return ((IntegralLiteral) expr).getValue();
    } else if (expr instanceof Int64Literal) {
        return ((Int64Literal) expr).getValue();
    } else if (expr instanceof DoubleLiteral) {
        return ((DoubleLiteral) expr).getValue();
    } else if (expr instanceof BooleanLiteral) {
        return ((BooleanLiteral) expr).getValue();
    } else if (expr instanceof DateTimeLiteral) {
        return ((DateTimeLiteral) expr).getValue().toDateTime(DateTimeZone.UTC).getMillis();
    } else if (expr instanceof DateTimeOffsetLiteral) {
        return ((DateTimeOffsetLiteral) expr).getValue().getMillis();
    } else {
        String value;
        try {
            value = StringEscapeUtils.unescapeJavaScript(((StringLiteral) expr).getValue());
        } catch (Exception e) {
            log.info("Failed to unescape searchValue.", e);
            throw PersoniumCoreException.OData.OPERATOR_AND_OPERAND_UNABLE_TO_UNESCAPE.params(((StringLiteral) expr)
                    .getValue());
        }
        return value;
    }
}
 
Example 2
Project: lams   File: LearningAction.java   View Source Code Vote up 4 votes
/**
    * Displays results page. When leader gets to this page, scratchingFinished column is set to true for all users.
    */
   private ActionForward showResults(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws ScratchieApplicationException, JSONException, IOException {
initializeScratchieService();
// get back SessionMap
String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID);
boolean isReflectOnActivity = (Boolean) sessionMap.get(ScratchieConstants.ATTR_REFLECTION_ON);
boolean isBurningQuestionsEnabled = (Boolean) sessionMap
	.get(ScratchieConstants.ATTR_IS_BURNING_QUESTIONS_ENABLED);

final Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
ScratchieSession toolSession = service.getScratchieSessionBySessionId(toolSessionId);
Scratchie scratchie = toolSession.getScratchie();
Long userUid = (Long) sessionMap.get(ScratchieConstants.ATTR_USER_UID);

//handle burning questions saving if needed
if (toolSession.isUserGroupLeader(userUid) && scratchie.isBurningQuestionsEnabled() && !toolSession.isScratchingFinished()) {
    saveBurningQuestions(request);
}

if (toolSession.isUserGroupLeader(userUid) && !toolSession.isScratchingFinished()) {
    service.setScratchingFinished(toolSessionId);
}

// get updated score from ScratchieSession
int score = toolSession.getMark();
int maxScore = (Integer) sessionMap.get(ScratchieConstants.ATTR_MAX_SCORE);
double percentage = (maxScore == 0) ? 0 : ((score * 100) / maxScore);
request.setAttribute(ScratchieConstants.ATTR_SCORE, (int) percentage);

// display other groups' BurningQuestions
if (isBurningQuestionsEnabled) {
    List<BurningQuestionItemDTO> burningQuestionItemDtos = service.getBurningQuestionDtos(scratchie,
	    toolSessionId, false);
    request.setAttribute(ScratchieConstants.ATTR_BURNING_QUESTION_ITEM_DTOS, burningQuestionItemDtos);
}

// display other groups' notebooks
if (isReflectOnActivity) {
    List<ReflectDTO> reflections = service.getReflectionList(toolSession.getScratchie().getContentId());

    // remove current session leader reflection
    Iterator<ReflectDTO> refIterator = reflections.iterator();
    while (refIterator.hasNext()) {
	ReflectDTO reflection = refIterator.next();
	if (toolSession.getSessionName().equals(reflection.getGroupName())) {

	    // store for displaying purposes
	    String reflectEntry = StringEscapeUtils.unescapeJavaScript(reflection.getReflection());
	    sessionMap.put(ScratchieConstants.ATTR_REFLECTION_ENTRY, reflectEntry);

	    // remove from list to display other groups' notebooks
	    refIterator.remove();
	    break;
	}
    }

    request.setAttribute(ScratchieConstants.ATTR_REFLECTIONS, reflections);
}

return mapping.findForward(ScratchieConstants.SUCCESS);
   }