import com.indexdata.mkjsf.config.ConfigurationReader;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands;\r
import com.indexdata.mkjsf.pazpar2.commands.sp.InitDocUpload;\r
-import com.indexdata.mkjsf.pazpar2.data.InitResponse;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
import com.indexdata.mkjsf.pazpar2.data.Responses;\r
import org.apache.log4j.Logger;\r
import org.apache.myfaces.custom.fileupload.UploadedFile;\r
\r
-import com.indexdata.mkjsf.pazpar2.ClientCommandResponse;\r
import com.indexdata.mkjsf.pazpar2.HttpResponseWrapper;\r
import com.indexdata.mkjsf.pazpar2.ServiceProxyExtensions;\r
import com.indexdata.mkjsf.utils.FileUpload;\r
package com.indexdata.mkjsf.pazpar2.data;\r
\r
+import java.io.IOException;\r
import java.io.Serializable;\r
+import java.io.UnsupportedEncodingException;\r
import java.util.List;\r
import java.util.Map;\r
import java.util.concurrent.ConcurrentHashMap;\r
\r
import javax.enterprise.context.SessionScoped;\r
+import javax.faces.context.ExternalContext;\r
+import javax.faces.context.FacesContext;\r
import javax.inject.Named;\r
\r
+import org.apache.commons.io.FilenameUtils;\r
import org.apache.log4j.Logger;\r
\r
import com.indexdata.mkjsf.errors.ErrorHelper;\r
return null;\r
}\r
\r
-}\r
+ public void download(String commandName) throws UnsupportedEncodingException, IOException {\r
+ logger.info(Utils.objectId(this) + " got a download request for "\r
+ + commandName);\r
+ FacesContext facesContext = FacesContext.getCurrentInstance();\r
+ ExternalContext externalContext = facesContext.getExternalContext();\r
+ externalContext.setResponseHeader("Content-Type","application/xml; charset=\"utf-8\"");\r
+ externalContext.setResponseHeader("Content-Length",String.valueOf(dataObjects.get(commandName).getXml().getBytes("UTF-8").length));\r
+ externalContext.setResponseHeader("Content-Disposition","attachment;filename=\"" + commandName + ".xml\"");\r
+ externalContext.getResponseOutputStream().write(dataObjects.get(commandName).getXml().getBytes("UTF-8"));\r
+ facesContext.responseComplete();\r
+ }\r
+}
\ No newline at end of file
externalContext.getResponseOutputStream().write(getUploadedFile().getBytes());\r
facesContext.responseComplete();\r
}\r
- \r
- public void downloadResponse () throws IOException {\r
- logger.info(Utils.objectId(this) + " got a download request");\r
- FacesContext facesContext = FacesContext.getCurrentInstance();\r
- ExternalContext externalContext = facesContext.getExternalContext();\r
- externalContext.setResponseHeader("Content-Type", response.getContentType());\r
- externalContext.setResponseHeader("Content-Length", String.valueOf((response.getBytes().length)));\r
- externalContext.setResponseHeader("Content-Disposition", "attachment;filename=\"initresponse.xml\"");\r
- externalContext.getResponseOutputStream().write(response.getBytes());\r
- facesContext.responseComplete();\r
- }\r
-\r
-\r
\r
}\r