\r
/** Returns one single result. */\r
public class GetAttachmentHandler implements HttpRequestHandler {\r
+ protected final String FORCE_DOWNLOAD = "Content-Type: application/force-download";\r
+\r
private AttachmentsStorage attachmentsStorage;\r
\r
public void handleRequest(HttpServletRequest request,\r
HttpServletResponse response) throws ServletException, IOException {\r
String uuid = request.getParameter("uuid");\r
String contentType = request.getParameter("contentType");\r
+ String name = request.getParameter("name");\r
+ if (contentType == null || "".equals(contentType.trim())) {\r
+ contentType = FORCE_DOWNLOAD;\r
+ }\r
+\r
+ if (contentType.trim().equals(FORCE_DOWNLOAD)) {\r
+ if (name != null) {\r
+ contentType = contentType + ";name=\"" + name + "\"";\r
+ response.setHeader("Content-Disposition",\r
+ "attachment; filename=\"" + name + "\"");\r
+ }\r
+ response.setHeader("Expires", "0");\r
+ response.setHeader("Cache-Control", "no-cache, must-revalidate");\r
+ response.setHeader("Pragma", "no-cache");\r
+ }\r
+\r
SimpleAttachment resourceDescriptor = new SimpleAttachment();\r
resourceDescriptor.setUuid(uuid);\r
resourceDescriptor.setContentType(contentType);\r
public class ExecutionScope implements Scope {
private final static Log log = LogFactory.getLog(ExecutionScope.class);
- private final ThreadLocal<ExecutionContext> executionContext
- = new ThreadLocal<ExecutionContext>();
-
+ private final ThreadLocal<ExecutionContext> executionContext = new ThreadLocal<ExecutionContext>();
+
public final ThreadLocal<String> executionContextBeanName = new ThreadLocal<String>();
-
+
public Object get(String name, ObjectFactory objectFactory) {
if (log.isTraceEnabled())
log.trace("Getting scoped bean " + name);
-
+
// check if an execution context is defined for this thread
- if(executionContext.get() == null) {
+ if (executionContext.get() == null) {
// if not, we expect objectFactory to produce an ExecutionContext
Object obj = objectFactory.getObject();
- if(obj instanceof ExecutionContext) {
+ if (obj instanceof ExecutionContext) {
// store the ExecutionContext in the ThreadLocal
- executionContext.set((ExecutionContext)obj);
+ executionContext.set((ExecutionContext) obj);
executionContextBeanName.set(name);
return obj;
+ } else {
+ throw new SlcException(
+ "Expected an ExecutionContext, got an object of class "
+ + obj.getClass()
+ + " for bean "
+ + name
+ + ": make sure that you have porperly set scope=\"execution\" where required");
}
- else {
- throw new SlcException("Expected an ExecutionContext, got an object of class "
- + obj.getClass() + " for bean " + name);
- }
}
-
- if(name.equals(executionContextBeanName.get())) {
+
+ if (name.equals(executionContextBeanName.get())) {
return executionContext.get();
- }
- else {
- // see if the executionContext already knows the object
+ } else {
+ // see if the executionContext already knows the object
Object obj = executionContext.get().findScopedObject(name);
- if(obj == null) {
+ if (obj == null) {
obj = objectFactory.getObject();
- if(!(obj instanceof ExecutionContext)) {
+ if (!(obj instanceof ExecutionContext)) {
executionContext.get().addScopedObject(name, obj);
- }
- else {
- throw new SlcException("Only one ExecutionContext can be defined per Thread");
+ } else {
+ throw new SlcException(
+ "Only one ExecutionContext can be defined per Thread");
}
}
return obj;
}
-
+
// if (ExecutionContext.getScopedObjects().containsKey(name)) {
// // returns cached instance
// Object obj = ExecutionContext.getScopedObjects().get(name);
}
public String getConversationId() {
-
+
return executionContext.get().getUuid();
}
-
+
public Boolean hasExecutionContext() {
return executionContext.get() != null;
}
-
public void registerDestructionCallback(String name, Runnable callback) {
// TODO: implement it
- //throw new UnsupportedOperationException();
+ // throw new UnsupportedOperationException();
}
public Object remove(String name) {
http://www.springframework.org/schema/beans \r
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
\r
- <service ref="resultListener" interface="org.argeo.slc.core.test.tree.TreeTestResultListener" />\r
+ <!-- Deprecated -->\r
+ <service ref="resultListener"\r
+ interface="org.argeo.slc.core.test.tree.TreeTestResultListener" />\r
<service ref="resultListener" interface="org.argeo.slc.test.TestResultListener" />\r
+\r
+ <!-- Deprecated -->\r
+ <service ref="treeTestResultLogger" interface="org.argeo.slc.test.TestResultListener" />\r
+ <service ref="treeTestResultLogger"\r
+ interface="org.argeo.slc.core.test.tree.TreeTestResultListener" />\r
+\r
<service ref="slcExecutionListener" interface="org.argeo.slc.process.SlcExecutionNotifier" />\r
\r
<!-- Manager -->\r
\r
<service ref="jmsAgent.attachmentUploader" interface="org.argeo.slc.core.attachment.AttachmentUploader" />\r
\r
- <service interface="org.argeo.slc.core.test.tree.TreeTestResultListener">\r
- <beans:bean class="org.argeo.slc.core.test.tree.TreeTestResultLogger" />\r
- </service>\r
\r
<list id="slcExecutionListeners" interface="org.argeo.slc.process.SlcExecutionNotifier"\r
cardinality="0..N" />\r