[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf ...

Norman Richards norman.richards at jboss.com
Wed Jan 24 01:09:54 EST 2007


  User: nrichards
  Date: 07/01/24 01:09:54

  Modified:    src/pdf/org/jboss/seam/pdf    DocumentStore.java
                        DocumentStorePhaseListener.java
                        DocumentStoreServlet.java
  Log:
  finish pdf name support, make docstore truly conversation
  
  Revision  Changes    Path
  1.4       +19 -10    jboss-seam/src/pdf/org/jboss/seam/pdf/DocumentStore.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DocumentStore.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/DocumentStore.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- DocumentStore.java	20 Jan 2007 07:41:23 -0000	1.3
  +++ DocumentStore.java	24 Jan 2007 06:09:54 -0000	1.4
  @@ -7,7 +7,7 @@
   import org.jboss.seam.annotations.*;
   
   @Name("documentStore")
  - at Scope(ScopeType.SESSION)
  + at Scope(ScopeType.CONVERSATION)
   @Install(precedence=Install.BUILT_IN)
   public class DocumentStore 
       implements Serializable
  @@ -27,8 +27,8 @@
           return String.valueOf(nextId++);
       }
   
  -    public void saveData(String id, DocType type, byte[] data) {
  -        dataStore.put(id, new DocumentData(type,data));
  +    public void saveData(String id, String baseName, DocType type, byte[] data) {
  +        dataStore.put(id, new DocumentData(baseName, type, data));
       }
   
       public byte[] dataForId(String id) {
  @@ -39,6 +39,10 @@
           return dataStore.get(id).getDocType().getMimeType();
       }
   
  +    public String fileNameForId(String id) {
  +        return dataStore.get(id).getBaseName() + "." + dataStore.get(id).getDocType().getExtension();
  +    }
  +
       public static DocumentStore instance()
       {
           return (DocumentStore) Component.getInstance(DocumentStore.class, true);
  @@ -47,11 +51,13 @@
       static class DocumentData {
           byte[] data;
           DocType docType;
  +        String baseName;
           
  -        public DocumentData(DocType docType,byte[] data) {
  +        public DocumentData(String baseName, DocType docType, byte[] data) {
               super();
               this.data = data;
               this.docType = docType;
  +            this.baseName = baseName;
           }
           public byte[] getData() {
               return data;
  @@ -59,16 +65,19 @@
           public DocType getDocType() {
               return docType;
           }      
  +        public String getBaseName() {
  +            return baseName;
  +        }
       }
   
  -    public String preferredUrlForContent(DocType docType, String id) {
  -        String extension = "seam";
  +    public String preferredUrlForContent(String baseName, DocType docType, String id) {
  +        String baseUrl = "seam-doc.seam";
   
           if (useExtensions) {
  -            extension = docType.getExtension();
  +            baseUrl = baseName + "." + docType.getExtension();
           } 
           
  -        return "seam-doc." + extension + "?docId="+id;
  +        return baseUrl + "?docId=" + id;
       }
       
       
  
  
  
  1.4       +4 -0      jboss-seam/src/pdf/org/jboss/seam/pdf/DocumentStorePhaseListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DocumentStorePhaseListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/DocumentStorePhaseListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- DocumentStorePhaseListener.java	22 Jan 2007 05:02:26 -0000	1.3
  +++ DocumentStorePhaseListener.java	24 Jan 2007 06:09:54 -0000	1.4
  @@ -43,6 +43,10 @@
   
               HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
               response.setContentType(store.typeForId(contentId));
  +
  +            response.setHeader("Content-Disposition", 
  +                               "inline; filename=\"" + store.fileNameForId(contentId) + "\"");
  +            
               if (data != null) {
                   response.getOutputStream().write(data);
               }
  
  
  
  1.2       +3 -0      jboss-seam/src/pdf/org/jboss/seam/pdf/DocumentStoreServlet.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DocumentStoreServlet.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/DocumentStoreServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- DocumentStoreServlet.java	20 Jan 2007 07:41:23 -0000	1.1
  +++ DocumentStoreServlet.java	24 Jan 2007 06:09:54 -0000	1.2
  @@ -28,6 +28,9 @@
           byte[] data = store.dataForId(contentId);          
             
           response.setContentType(store.typeForId(contentId));
  +        response.setHeader("Content-Disposition", 
  +                           "inline; filename=\"" + store.fileNameForId(contentId) + "\"");
  +                
           if (data != null) {
               response.getOutputStream().write(data);
           }
  
  
  



More information about the jboss-cvs-commits mailing list