1 17 18 19 20 package org.apache.lenya.cms.publication; 21 22 import java.io.File ; 23 24 public class IdentityDocumentIdToPathMapper implements DocumentIdToPathMapper { 25 26 29 public File getFile(Publication publication, String area, String documentId, String language) { 30 File areaDirectory = 31 new File (publication.getDirectory(), Publication.CONTENT_PATH + File.separator + area); 32 File file = new File (areaDirectory, getPath(documentId, language)); 33 return file; 34 } 35 36 40 public File getDirectory(Publication publication, String area, String documentId) { 41 return getFile(publication, area, documentId, null).getParentFile(); 42 } 43 44 47 public String getPath(String documentId, String language) { 48 assert documentId.startsWith("/"); 49 documentId = documentId.substring(1); 51 return documentId + getSuffix(language); 52 } 53 54 59 protected String getSuffix(String language) { 60 String languageSuffix = ""; 61 if (language != null && !"".equals(language)) { 62 languageSuffix = "_" + language; 63 } 64 return languageSuffix + ".xml"; 65 } 66 67 } 68 | Popular Tags |