You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/07/24 14:48:42 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication DefaultDocumentIdToPathMapper.java

andreas     2003/07/24 05:48:42

  Modified:    src/java/org/apache/lenya/cms/publication
                        DefaultDocumentIdToPathMapper.java
  Log:
  reading document from authoring directory
  
  Revision  Changes    Path
  1.9       +32 -22    cocoon-lenya/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
  
  Index: DefaultDocumentIdToPathMapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultDocumentIdToPathMapper.java	23 Jul 2003 13:21:11 -0000	1.8
  +++ DefaultDocumentIdToPathMapper.java	24 Jul 2003 12:48:42 -0000	1.9
  @@ -57,53 +57,63 @@
   
   import java.io.File;
   
  -
   /**
    * @author egli
    *
    *
    */
   public class DefaultDocumentIdToPathMapper implements DocumentIdToPathMapper {
  -	
  +
       /**
        * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String, java.lang.String)
        */
       public File getFile(Publication publication, String area, String documentId, String language) {
  -        assert documentId.startsWith("/");
  -        File file = new File(publication.getDirectory(),
  -                "content" + File.separator + area + File.separator + getPath(documentId, language));
  -
  +        File file = new File(getDirectory(publication, area, documentId), getFilename(language));
           return file;
       }
  -    
  -	/**
  -	 * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFiles(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String)
  -	 */
  -	public File getDirectory(Publication publication, String area, String documentId) {
  +
  +    /**
  +     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFiles(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String)
  +     */
  +    public File getDirectory(Publication publication, String area, String documentId) {
           assert documentId.startsWith("/");
           // remove leading slash
           documentId = documentId.substring(1);
           documentId = documentId.replace('/', File.separatorChar);
  -        
  -		File file = new File(publication.getDirectory(),
  -			"content" + File.separator + area + File.separator + documentId);
   
  -		return file;
  -	}
  +        if (area.equals(Publication.INFO_AREA)) {
  +            area = Publication.AUTHORING_AREA;
  +        }
  +
  +        File file =
  +            new File(
  +                publication.getDirectory(),
  +                "content" + File.separator + area + File.separator + documentId);
  +
  +        return file;
  +    }
   
       /**
        * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String, java.lang.String)
        */
       public String getPath(String documentId, String language) {
           assert documentId.startsWith("/");
  +        // remove leading slash
  +        documentId = documentId.substring(1);
  +        return documentId + "/" + getFilename(language);
  +    }
  +
  +    /**
  +     * Constructs the filename for a given language.
  +     * @param language The language.
  +     * @return A string value.
  +     */
  +    protected String getFilename(String language) {
           String languageSuffix = "";
           if (language != null && !"".equals(language)) {
               languageSuffix = "_" + language;
           }
  -        
  -        // remove leading slash
  -        documentId = documentId.substring(1);
  -
  -        return documentId + "/" + "index" + languageSuffix + ".xml";
  +        return "index" + languageSuffix + ".xml";
       }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org