use of org.apache.felix.webconsole.DefaultVariableResolver in project sling by apache.
the class ScriptConsolePlugin method renderContent.
@SuppressWarnings("unchecked")
@Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
final PrintWriter pw = response.getWriter();
DefaultVariableResolver varResolver = (DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request);
varResolver.put("__scriptConfig__", getScriptConfig());
pw.println(TEMPLATE);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class WebConsolePlugin method renderContent.
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException {
DefaultVariableResolver vr = (DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request);
if (getShellService() == null) {
// $NON-NLS-1$
vr.put("shell.status", "Shell Service not available");
// $NON-NLS-1$ //$NON-NLS-2$
vr.put("shell.disabled", "true");
} else {
// $NON-NLS-1$ //$NON-NLS-2$
vr.put("shell.disabled", "false");
}
response.getWriter().print(TEMPLATE);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class ConfigManager method renderContent.
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException {
// extract the configuration PID from the request path
String pid = request.getPathInfo().substring(this.getLabel().length() + 1);
if (pid.length() == 0) {
pid = null;
} else {
pid = pid.substring(pid.lastIndexOf('/') + 1);
}
// check whether the PID is actually a filter for the selection
// of configurations to display, if the filter correctly converts
// into an OSGi filter, we use it to select configurations
// to display
String pidFilter = request.getParameter(PID_FILTER);
if (pidFilter == null) {
pidFilter = pid;
}
if (pidFilter != null) {
try {
getBundleContext().createFilter(pidFilter);
// if the pidFilter was set from the PID, clear the PID
if (pid == pidFilter) {
pid = null;
}
} catch (InvalidSyntaxException ise) {
// its OK, if the PID is just a single PID
pidFilter = null;
}
}
// check both PID and PID filter
if (pid != null && !isAllowedPid(pid)) {
response.sendError(500);
}
if (pidFilter != null && !isAllowedPid(pidFilter)) {
response.sendError(500);
}
final Locale loc = getLocale(request);
final String locale = (loc != null) ? loc.toString() : null;
StringWriter json = new StringWriter();
JSONWriter jw = new JSONWriter(json);
jw.object();
final ConfigAdminSupport ca = getConfigurationAdminSupport();
// $NON-NLS-1$
jw.key("status").value(ca != null ? Boolean.TRUE : Boolean.FALSE);
if (ca != null) {
ca.listConfigurations(jw, pidFilter, locale, loc);
ca.listFactoryConfigurations(jw, pidFilter, locale);
}
jw.endObject();
// if a configuration is addressed, display it immediately
if (request.getParameter(ACTION_CREATE) != null && pid != null) {
// new PlaceholderConfiguration( pid ).getPid();
pid = PLACEHOLDER_PID;
}
// prepare variables
final String referer = request.getParameter(REFERER);
// $NON-NLS-1$
final boolean factoryCreate = "true".equals(request.getParameter(FACTORY_CREATE));
DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
// $NON-NLS-1$
vars.put("__data__", json.toString());
// $NON-NLS-1$ //$NON-NLS-2$
vars.put("selectedPid", pid != null ? pid : "");
// $NON-NLS-1$ //$NON-NLS-2$
vars.put("configurationReferer", referer != null ? referer : "");
// $NON-NLS-1$
vars.put("factoryCreate", Boolean.valueOf(factoryCreate));
// $NON-NLS-1$
vars.put("param.apply", ACTION_APPLY);
// $NON-NLS-1$
vars.put("param.create", ACTION_CREATE);
// $NON-NLS-1$
vars.put("param.unbind", ACTION_UNBIND);
// $NON-NLS-1$
vars.put("param.delete", ACTION_DELETE);
// $NON-NLS-1$
vars.put("param.propertylist", PROPERTY_LIST);
// $NON-NLS-1$
vars.put("param.pidFilter", PID_FILTER);
response.getWriter().print(TEMPLATE);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class BundlesServlet method renderContent.
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException {
// get request info from request attribute
final RequestInfo reqInfo = getRequestInfo(request);
final int startLevel = getStartLevel().getInitialBundleStartLevel();
// prepare variables
DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
vars.put("startLevel", String.valueOf(startLevel));
vars.put("drawDetails", reqInfo.bundleRequested ? Boolean.TRUE : Boolean.FALSE);
vars.put("currentBundle", (reqInfo.bundleRequested && reqInfo.bundle != null ? String.valueOf(reqInfo.bundle.getBundleId()) : "null"));
final String pluginRoot = (String) request.getAttribute(WebConsoleConstants.ATTR_PLUGIN_ROOT);
final String servicesRoot = getServicesRoot(request);
StringWriter w = new StringWriter();
try {
writeJSON(w, reqInfo.bundle, pluginRoot, servicesRoot, request.getLocale(), request.getParameter(FILTER_PARAM), null);
} catch (InvalidSyntaxException e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid LDAP filter specified");
return;
}
vars.put("__bundles__", w.toString());
response.getWriter().print(TEMPLATE_MAIN);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class WebConsolePlugin method renderContent.
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@SuppressWarnings("unchecked")
@Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException {
// get request info from request attribute
final RequestInfo reqInfo = getRequestInfo(request);
StringWriter w = new StringWriter();
PrintWriter w2 = new PrintWriter(w);
renderResult(w2, reqInfo, reqInfo.component);
// prepare variables
DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
// $NON-NLS-1$
vars.put("__drawDetails__", reqInfo.componentRequested ? Boolean.TRUE : Boolean.FALSE);
// $NON-NLS-1$
vars.put("__data__", w.toString());
response.getWriter().print(TEMPLATE);
}
Aggregations