1 16 package org.outerj.daisy.publisher.serverimpl.requestmodel; 17 18 import org.outerj.daisy.repository.*; 19 import org.outerj.daisy.publisher.serverimpl.PublisherImpl; 20 import org.outerj.daisy.publisher.serverimpl.docpreparation.PreparedDocuments; 21 import org.outerj.daisy.publisher.serverimpl.docpreparation.ContentProcessor; 22 import org.apache.avalon.framework.logger.Logger; 23 24 import java.util.Locale ; 25 import java.text.DateFormat ; 26 27 public class RootPublisherContext implements PublisherContext { 28 private Repository repository; 29 private PublisherImpl publisher; 30 private Locale locale = Locale.US; 31 private Logger logger; 32 private DateFormat dateFormat; 33 private static final String NO_DOC_AVAILABLE = "A document-related request was used in a context where no document is available."; 34 35 public RootPublisherContext(Repository repository, PublisherImpl publisher, Logger logger) { 36 if (repository == null) 37 throw new IllegalArgumentException ("repository argument cannot be null"); 38 if (logger == null) 39 throw new IllegalArgumentException ("logger argument cannot be null"); 40 this.repository = repository; 41 this.logger = logger; 42 this.publisher = publisher; 43 this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); 44 } 45 46 public Locale getLocale() { 47 return locale; 48 } 49 50 public Repository getRepository() { 51 return repository; 52 } 53 54 public DateFormat getTimestampFormat() { 55 return dateFormat; 56 } 57 58 public long getDocumentId() { 59 throw new AssertionError (NO_DOC_AVAILABLE); 60 } 61 62 public long getBranchId() { 63 throw new AssertionError (NO_DOC_AVAILABLE); 64 } 65 66 public long getLanguageId() { 67 throw new AssertionError (NO_DOC_AVAILABLE); 68 } 69 70 public VariantKey getVariantKey() { 71 throw new AssertionError (NO_DOC_AVAILABLE); 72 } 73 74 public long getVersionId() { 75 throw new AssertionError (NO_DOC_AVAILABLE); 76 } 77 78 public Document getDocument() { 79 throw new AssertionError (NO_DOC_AVAILABLE); 80 } 81 82 public Version getVersion() throws RepositoryException { 83 throw new AssertionError (NO_DOC_AVAILABLE); 84 } 85 86 public boolean hasDocument() { 87 return false; 88 } 89 90 public PublisherImpl getPublisher() { 91 return publisher; 92 } 93 94 public Logger getLogger() { 95 return logger; 96 } 97 98 public PreparedDocuments getPreparedDocuments() { 99 return null; 100 } 101 102 public ContentProcessor getContentProcessor() { 103 return null; 104 } 105 106 public boolean searchRecursivePrepDocs(long documentId, long branchId, long languageId, String pubReqSetName) { 107 return false; 108 } 109 110 public PublisherVersionMode getVersionMode() { 111 return PublisherVersionMode.LIVE; 112 } 113 } 114 | Popular Tags |