1 package org.tigris.scarab.screens.admin; 2 3 48 49 import java.text.SimpleDateFormat ; 51 52 import org.apache.turbine.RunData; 54 import org.apache.turbine.TemplateContext; 55 import org.apache.turbine.modules.Module; 56 57 import org.tigris.scarab.screens.Default; 59 import org.tigris.scarab.util.ScarabConstants; 60 61 67 public class ViewXMLExportSettings extends Default 68 { 69 72 public void doBuildTemplate(RunData data, TemplateContext context) 73 throws Exception 74 { 75 super.doBuildTemplate(data, context); 76 77 String downloadType = data.getParameters().getString("downloadtype"); 80 if (downloadType != null && downloadType.equals("1")) 81 { 82 data.getResponse().setContentType("text/plain"); 83 } 84 else 85 { 86 data.getResponse().setContentType("application/octet-stream"); 87 String filename = data.getParameters().getString("filename"); 88 if (filename == null 89 || filename.length() == 0 90 || filename.indexOf('/') > 0 91 || filename.indexOf(':') > 0 92 || filename.indexOf(';') > 0) 93 { 94 filename = "scarab-settings-export.xml"; 95 } 96 data.getResponse().setHeader("Content-Disposition", 97 "attachment; filename=" + filename); 98 } 99 100 String includeUsers = data.getParameters().getString("includeUsers"); 101 if (includeUsers != null && includeUsers.equals("1")) 102 { 103 context.put ("includeUsers", Boolean.TRUE); 104 } 105 else 106 { 107 context.put ("includeUsers", Boolean.FALSE); 108 } 109 110 context.put("renderedFromScreen", Boolean.TRUE); 111 context.put("sdf", new SimpleDateFormat (ScarabConstants.DATE_FORMAT)); 112 String result = 113 Module.handleRequest (context, "macros/XMLExportSettingsMacro.vm"); 114 data.getResponse().setContentLength(result.length()); 115 data.getResponse().getOutputStream().print(result); 116 context.remove("renderedFromScreen"); 117 118 data.setTarget(null); 120 } 121 } 122 | Popular Tags |