org.apache.struts.config.ModuleConfig Java Examples

The following examples show how to use org.apache.struts.config.ModuleConfig. 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: ExtendedMultiPartRequestHandler.java    From jivejdon with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the path to the temporary directory to be used for uploaded files
 * which are written to disk. The directory used is determined from the
 * first of the following to be non-empty.
 * <ol>
 * <li>A temp dir explicitly defined either using the <code>tempDir</code>
 * servlet init param, or the <code>tempDir</code> attribute of the
 * &lt;controller&gt; element in the Struts config file.</li>
 * <li>The container-specified temp dir, obtained from the
 * <code>javax.servlet.context.tempdir</code> servlet context attribute.</li>
 * <li>The temp dir specified by the <code>java.io.tmpdir</code> system
 * property.</li> (/ol>
 * 
 * @param mc
 *            The module config instance for which the path should be
 *            determined.
 * 
 * @return The path to the directory to be used to store uploaded files.
 */
protected String getRepositoryPath(ModuleConfig mc) {

	// First, look for an explicitly defined temp dir.
	String tempDir = mc.getControllerConfig().getTempDir();

	// If none, look for a container specified temp dir.
	if (tempDir == null || tempDir.length() == 0) {
		if (servlet != null) {
			ServletContext context = servlet.getServletContext();
			File tempDirFile = (File) context.getAttribute("javax.servlet.context.tempdir");
			tempDir = tempDirFile.getAbsolutePath();
		}

		// If none, pick up the system temp dir.
		if (tempDir == null || tempDir.length() == 0) {
			tempDir = System.getProperty("java.io.tmpdir");
		}
	}

	if (log.isTraceEnabled()) {
		log.trace("File upload temp dir: " + tempDir);
	}

	return tempDir;
}
 
Example #2
Source File: SpringAwareLookupDispatchAction.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
protected MessageResources getResources(HttpServletRequest request, String key) {
	// Identify the current module, the right way
	ServletContext context = request.getSession().getServletContext();
	ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context);
	
	// Return the requested message resources instance
	return (MessageResources) context.getAttribute(key + moduleConfig.getPrefix());
}
 
Example #3
Source File: FenixActionForward.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String getPathModule() {
    String currentModule = getModule();

    if (currentModule != null) {
        return currentModule;
    }

    ModuleConfig module = ModuleUtils.getInstance().getModuleConfig(this.request);
    if (module == null) {
        return "";
    }

    return module.getPrefix();
}
 
Example #4
Source File: PojoPlugin.java    From rice with Educational Community License v2.0 4 votes vote down vote up
public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {
    initBeanUtils();
    // override the Struts ControllerConfig with our own wrapper that knows how to
    // dynamically find max file upload size according to Rice run-time settings
    config.setControllerConfig(new KualiControllerConfig(config.getControllerConfig()));
}
 
Example #5
Source File: ExtendedMultiPartRequestHandler.java    From jivejdon with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the maximum allowable size, in bytes, of an uploaded file. The
 * value is obtained from the current module's controller configuration.
 * 
 * @param mc
 *            The current module's configuration.
 * 
 * @return The maximum allowable file size, in bytes.
 */
protected long getSizeMax(ModuleConfig mc) {
	return convertSizeToBytes(mc.getControllerConfig().getMaxFileSize(), DEFAULT_SIZE_MAX);
}
 
Example #6
Source File: ExtendedMultiPartRequestHandler.java    From jivejdon with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the size threshold which determines whether an uploaded file will
 * be written to disk or cached in memory.
 * 
 * @param mc
 *            The current module's configuration.
 * 
 * @return The size threshold, in bytes.
 */
protected long getSizeThreshold(ModuleConfig mc) {
	return convertSizeToBytes(mc.getControllerConfig().getMemFileSize(), DEFAULT_SIZE_THRESHOLD);
}
 
Example #7
Source File: KualiMultipartRequestHandler.java    From rice with Educational Community License v2.0 2 votes vote down vote up
/**
 * Returns the maximum allowable size, in bytes, of an uploaded file. The
 * value is obtained from the current module's controller configuration.
 *
 * @param mc The current module's configuration.
 *
 * @return The maximum allowable file size, in bytes.
 */
public long getSizeMax(ModuleConfig mc) {
    return convertSizeToBytes( sizeMax, super.getSizeMax(mc) );
}