Java Code Examples for javax.portlet.RenderResponse#setTitle()

The following examples show how to use javax.portlet.RenderResponse#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {

	response.setContentType("text/html");
	log.debug("==== doEdit called ====");

	PortletSession pSession = request.getPortletSession(true);

	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);

	// Debug
	String inputData = (String) pSession.getAttribute("sakai.descriptor");
	if ( inputData != null ) log.debug("descriptor.length()={}", inputData.length());
	String url = (String) pSession.getAttribute("sakai.url");
	log.debug("sakai.url={}", url);

	String view = (String) pSession.getAttribute("sakai.view");
	log.debug("sakai.view={}", view);
	if ( "edit.reset".equals(view) ) {
		sendToJSP(request, response, "/editreset.jsp");
	} else {
		prepareEdit(request);
		sendToJSP(request, response, "/edit.jsp");
	}

	clearErrorMessage(request);
	log.debug("==== doEdit called ====");
}
 
Example 2
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void doHelp(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	log.debug("==== doHelp called ====");

	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);
	sendToJSP(request, response, "/help.jsp");

	clearErrorMessage(request);
	log.debug("==== doHelp done  ====");
}
 
Example 3
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {

	response.setContentType("text/html");
	log.debug("==== doEdit called ====");

	PortletSession pSession = request.getPortletSession(true);

	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);

	// Debug
	String inputData = (String) pSession.getAttribute("sakai.descriptor");
	if ( inputData != null ) log.debug("descriptor.length()={}", inputData.length());
	String url = (String) pSession.getAttribute("sakai.url");
	log.debug("sakai.url={}", url);

	String view = (String) pSession.getAttribute("sakai.view");
	log.debug("sakai.view={}", view);
	if ( "edit.reset".equals(view) ) {
		sendToJSP(request, response, "/editreset.jsp");
	} else {
		prepareEdit(request);
		sendToJSP(request, response, "/edit.jsp");
	}

	clearErrorMessage(request);
	log.debug("==== doEdit called ====");
}
 
Example 4
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void doHelp(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	log.debug("==== doHelp called ====");

	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);
	sendToJSP(request, response, "/help.jsp");

	clearErrorMessage(request);
	log.debug("==== doHelp done  ====");
}
 
Example 5
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	response.setContentType("text/html");

	log.debug("==== doView called ====");

	// Grab that underlying request to get a GET parameter
	ServletRequest req = (ServletRequest) ThreadLocalManager.get(CURRENT_HTTP_REQUEST);
	String popupDone = req.getParameter("sakai.popup");

	PrintWriter out = response.getWriter();
	Placement placement = ToolManager.getCurrentPlacement();
	response.setTitle(placement.getTitle());
	String source = placement.getPlacementConfig().getProperty(SOURCE);
	if ( source == null ) source = "";
	String height = placement.getPlacementConfig().getProperty(HEIGHT);
	if ( height == null ) height = "1200px";
	boolean maximize = "true".equals(placement.getPlacementConfig().getProperty(MAXIMIZE));

	boolean popup = false; // Comes from content item
	boolean oldPopup = "true".equals(placement.getPlacementConfig().getProperty(POPUP));

	// Retrieve the corresponding content item and tool to check the launch
	Map<String, Object> content = null;
	Map<String, Object> tool = null;
	Long contentId = getContentIdFromSource(source);
	if ( contentId == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content id placement={} source={}", placement.getId(), source);
		return;
	}
	try {
		content = m_ltiService.getContent(contentId, placement.getContext());
		// SAK-32665 - We get null when an LTI tool is added to a template
		// like !user because the content item points at !user and not the
		// current site.
		if ( content == null ) {
			content = patchContentItem(contentId, placement);
			source = placement.getPlacementConfig().getProperty(SOURCE);
			contentId = getContentIdFromSource(source);
		}

		// If content is still null after patching, let the NPE happen
		Long tool_id = getLongNull(content.get("tool_id"));
		// If we are supposed to popup (per the content), do so and optionally
		// copy the calue into the placement to communicate with the portal
		if (tool_id != null) {
			tool = m_ltiService.getTool(tool_id, placement.getContext());
			m_ltiService.filterContent(content, tool);
		}
		Object popupValue = content.get("newpage");
		popup = getLongNull(popupValue) == 1;
		if ( oldPopup != popup ) {
			placement.getPlacementConfig().setProperty(POPUP, popup ? "true" : "false");
			placement.save();
		}
		String launch = (String) content.get("launch");
		// Force http:// to pop-up if we are https://
		String serverUrl = ServerConfigurationService.getServerUrl();
		if ( request.isSecure() || ( serverUrl != null && serverUrl.startsWith("https://") ) ) {
			if ( launch != null && launch.startsWith("http://") ) popup = true;
		}
	} catch (Exception e) {
		out.println(rb.getString("get.info.notconfig"));
		log.error(e.getMessage(), e);
		return;
	}

	if ( source != null && source.trim().length() > 0 ) {

		Context context = new VelocityContext();
		context.put("tlang", rb);
		context.put("validator", formattedText);
		context.put("source",source);
		context.put("height",height);
		context.put("browser-feature-allow", String.join(";", ServerConfigurationService.getStrings("browser.feature.allow")));
		sendAlert(request,context);
		context.put("popupdone", Boolean.valueOf(popupDone != null));
		context.put("popup", Boolean.valueOf(popup));
		context.put("maximize", Boolean.valueOf(maximize));

		vHelper.doTemplate(vengine, "/vm/main.vm", context, out);
	} else {
		out.println(rb.getString("get.info.notconfig"));
	}
}
 
Example 6
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	
	response.setContentType("text/html");
	PrintWriter out = response.getWriter();
	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);

	Context context = new VelocityContext();
	context.put("tlang", rb);
	context.put("validator", formattedText);
	sendAlert(request,context);

	PortletURL url = response.createActionURL();
	context.put("actionUrl", url.toString());
	context.put("doCancel", "sakai.cancel");
	context.put("doUpdate", "sakai.update");

	// get current site
	Placement placement = ToolManager.getCurrentPlacement();
	String siteId = "";

	// find the right LTIContent object for this page
	String source = placement.getPlacementConfig().getProperty(SOURCE);
	Long key = getContentIdFromSource(source);
	if ( key == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content id placement={} source={}", placement.getId(), source);
		return;
	}

	Map<String, Object> content = m_ltiService.getContent(key, placement.getContext());
	if ( content == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content item placement={} key={}", placement.getId(), key);
		return;
	}

	// attach the ltiToolId to each model attribute, so that we could have the tool configuration page for multiple tools
	String foundLtiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
	Map<String, Object> tool = m_ltiService.getTool(Long.valueOf(foundLtiToolId), placement.getContext());
	if ( tool == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find tool placement={} key={}", placement.getId(), foundLtiToolId);
		return;
	}

	String[] contentToolModel = m_ltiService.getContentModelIfConfigurable(Long.valueOf(foundLtiToolId), placement.getContext());
	if (contentToolModel != null) {
		String formInput = m_ltiService.formInput(content, contentToolModel);
		context.put("formInput", formInput);
	} else {
		String noCustomizations = rb.getString("gen.info.nocustom");
		context.put("noCustomizations", noCustomizations);
	}
	
	vHelper.doTemplate(vengine, "/vm/edit.vm", context, out);
}
 
Example 7
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	response.setContentType("text/html");

	log.debug("==== doView called ====");

	// Grab that underlying request to get a GET parameter
	ServletRequest req = (ServletRequest) ThreadLocalManager.get(CURRENT_HTTP_REQUEST);
	String popupDone = req.getParameter("sakai.popup");

	PrintWriter out = response.getWriter();
	Placement placement = ToolManager.getCurrentPlacement();
	response.setTitle(placement.getTitle());
	String source = placement.getPlacementConfig().getProperty(SOURCE);
	if ( source == null ) source = "";
	String height = placement.getPlacementConfig().getProperty(HEIGHT);
	if ( height == null ) height = "1200px";
	boolean maximize = "true".equals(placement.getPlacementConfig().getProperty(MAXIMIZE));

	boolean popup = false; // Comes from content item
	boolean oldPopup = "true".equals(placement.getPlacementConfig().getProperty(POPUP));

	// Retrieve the corresponding content item and tool to check the launch
	Map<String, Object> content = null;
	Map<String, Object> tool = null;
	Long contentId = getContentIdFromSource(source);
	if ( contentId == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content id placement={} source={}", placement.getId(), source);
		return;
	}
	try {
		content = m_ltiService.getContent(contentId, placement.getContext());
		// SAK-32665 - We get null when an LTI tool is added to a template
		// like !user because the content item points at !user and not the
		// current site.
		if ( content == null ) {
			content = patchContentItem(contentId, placement);
			source = placement.getPlacementConfig().getProperty(SOURCE);
			contentId = getContentIdFromSource(source);
		}

		// If content is still null after patching, let the NPE happen
		Long tool_id = getLongNull(content.get("tool_id"));
		// If we are supposed to popup (per the content), do so and optionally
		// copy the calue into the placement to communicate with the portal
		if (tool_id != null) {
			tool = m_ltiService.getTool(tool_id, placement.getContext());
			m_ltiService.filterContent(content, tool);
		}
		Object popupValue = content.get("newpage");
		popup = getLongNull(popupValue) == 1;
		if ( oldPopup != popup ) {
			placement.getPlacementConfig().setProperty(POPUP, popup ? "true" : "false");
			placement.save();
		}
		String launch = (String) content.get("launch");
		// Force http:// to pop-up if we are https://
		String serverUrl = ServerConfigurationService.getServerUrl();
		if ( request.isSecure() || ( serverUrl != null && serverUrl.startsWith("https://") ) ) {
			if ( launch != null && launch.startsWith("http://") ) popup = true;
		}
	} catch (Exception e) {
		out.println(rb.getString("get.info.notconfig"));
		log.error(e.getMessage(), e);
		return;
	}

	if ( source != null && source.trim().length() > 0 ) {

		Context context = new VelocityContext();
		context.put("tlang", rb);
		context.put("validator", formattedText);
		context.put("source",source);
		context.put("height",height);
		context.put("browser-feature-allow", String.join(";", ServerConfigurationService.getStrings("browser.feature.allow")));
		sendAlert(request,context);
		context.put("popupdone", Boolean.valueOf(popupDone != null));
		context.put("popup", Boolean.valueOf(popup));
		context.put("maximize", Boolean.valueOf(maximize));

		vHelper.doTemplate(vengine, "/vm/main.vm", context, out);
	} else {
		out.println(rb.getString("get.info.notconfig"));
	}
}
 
Example 8
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	
	response.setContentType("text/html");
	PrintWriter out = response.getWriter();
	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);

	Context context = new VelocityContext();
	context.put("tlang", rb);
	context.put("validator", formattedText);
	sendAlert(request,context);

	PortletURL url = response.createActionURL();
	context.put("actionUrl", url.toString());
	context.put("doCancel", "sakai.cancel");
	context.put("doUpdate", "sakai.update");

	// get current site
	Placement placement = ToolManager.getCurrentPlacement();
	String siteId = "";

	// find the right LTIContent object for this page
	String source = placement.getPlacementConfig().getProperty(SOURCE);
	Long key = getContentIdFromSource(source);
	if ( key == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content id placement={} source={}", placement.getId(), source);
		return;
	}

	Map<String, Object> content = m_ltiService.getContent(key, placement.getContext());
	if ( content == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content item placement={} key={}", placement.getId(), key);
		return;
	}

	// attach the ltiToolId to each model attribute, so that we could have the tool configuration page for multiple tools
	String foundLtiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
	Map<String, Object> tool = m_ltiService.getTool(Long.valueOf(foundLtiToolId), placement.getContext());
	if ( tool == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find tool placement={} key={}", placement.getId(), foundLtiToolId);
		return;
	}

	String[] contentToolModel = m_ltiService.getContentModelIfConfigurable(Long.valueOf(foundLtiToolId), placement.getContext());
	if (contentToolModel != null) {
		String formInput = m_ltiService.formInput(content, contentToolModel);
		context.put("formInput", formInput);
	} else {
		String noCustomizations = rb.getString("gen.info.nocustom");
		context.put("noCustomizations", noCustomizations);
	}
	
	vHelper.doTemplate(vengine, "/vm/edit.vm", context, out);
}