private void init_FileManager() throws ClassNotFoundException { if (initParams.containsKey(StrutsConstants.STRUTS_FILE_MANAGER)) { final String fileManagerClassName = initParams.get(StrutsConstants.STRUTS_FILE_MANAGER); final Class<FileManager> fileManagerClass = (Class<FileManager>) Class.forName(fileManagerClassName); if (LOG.isInfoEnabled()) { LOG.info("Custom FileManager specified: #0", fileManagerClassName); } configurationManager.addContainerProvider( new FileManagerProvider(fileManagerClass, fileManagerClass.getSimpleName())); } else { // add any other Struts 2 provided implementations of FileManager configurationManager.addContainerProvider( new FileManagerProvider(JBossFileManager.class, "jboss")); } if (initParams.containsKey(StrutsConstants.STRUTS_FILE_MANAGER_FACTORY)) { final String fileManagerFactoryClassName = initParams.get(StrutsConstants.STRUTS_FILE_MANAGER_FACTORY); final Class<FileManagerFactory> fileManagerFactoryClass = (Class<FileManagerFactory>) Class.forName(fileManagerFactoryClassName); if (LOG.isInfoEnabled()) { LOG.info("Custom FileManagerFactory specified: #0", fileManagerFactoryClassName); } configurationManager.addContainerProvider( new FileManagerFactoryProvider(fileManagerFactoryClass)); } }
public int doEndTag() throws JspException { JspWriter writer = pageContext.getOut(); if (label != null) { try { writer.write("<div class='control-group'><label class='control-label'>"); writer.write(label); writer.write("</label><div class='controls'>"); } catch (IOException e) { if (LOG.isInfoEnabled()) { LOG.info("Could not print out value '" + label + "'", e); } } } component.end(writer, getBody()); if (label != null) { try { writer.write("</div></div>"); } catch (IOException e) { if (LOG.isInfoEnabled()) { LOG.info("Could not print out value '" + label + "'", e); } } } component = null; return EVAL_PAGE; }
/** * Return the path to save uploaded files to (this is configurable). * * @return the path to save uploaded files to * @param servletContext Our ServletContext */ private String getSaveDir(ServletContext servletContext) { String saveDir = multipartSaveDir.trim(); if (saveDir.equals("")) { File tempdir = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); if (LOG.isInfoEnabled()) { LOG.info( "Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir"); } if (tempdir != null) { saveDir = tempdir.toString(); setMultipartSaveDir(saveDir); } } else { File multipartSaveDir = new File(saveDir); if (!multipartSaveDir.exists()) { if (!multipartSaveDir.mkdirs()) { String logMessage; try { logMessage = "Could not find create multipart save directory '" + multipartSaveDir.getCanonicalPath() + "'."; } catch (IOException e) { logMessage = "Could not find create multipart save directory '" + multipartSaveDir.toString() + "'."; } if (devMode) { LOG.error(logMessage); } else { if (LOG.isWarnEnabled()) { LOG.warn(logMessage); } } } } } if (LOG.isDebugEnabled()) { LOG.debug("saveDir=" + saveDir); } return saveDir; }
private void init_CheckWebLogicWorkaround(Container container) { // test whether param-access workaround needs to be enabled if (servletContext != null && servletContext.getServerInfo() != null && servletContext.getServerInfo().contains("WebLogic")) { if (LOG.isInfoEnabled()) { LOG.info("WebLogic server detected. Enabling Struts parameter access work-around."); } paramsWorkaroundEnabled = true; } else { paramsWorkaroundEnabled = "true" .equals( container.getInstance( String.class, StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)); } }