1 23 24 package com.sun.enterprise.appclient.jws; 25 26 import com.sun.enterprise.deployment.Application; 27 import java.io.File ; 28 import java.io.IOException ; 29 import java.net.URI ; 30 import java.net.URISyntaxException ; 31 import java.util.Collection ; 32 import java.util.HashMap ; 33 import java.util.Map ; 34 import java.util.Properties ; 35 36 40 public abstract class ContentOrigin { 41 42 protected static String lineSep = System.getProperty("line.separator"); 43 44 48 protected Map <String ,Content> pathToContent; 49 50 51 private boolean adhocPathRegistered = false; 52 53 58 public ContentOrigin() { 59 pathToContent = new HashMap <String ,Content>(); 60 } 61 62 68 public abstract boolean isEnabled(); 69 70 protected Content getContent(String contentKey) { 71 return pathToContent.get(contentKey); 72 } 73 74 protected DynamicContent addDynamicContent(String path, String template, Properties tokenValues, String mimeType) throws IOException { 75 return addDynamicContent(path, template, tokenValues, mimeType, false ); 76 } 77 78 protected DynamicContent addDynamicContent( 79 String path, 80 String template, 81 Properties tokenValues, 82 String mimeType, 83 boolean requiresElevatedPrivs) { 84 String docText = Util.replaceTokens(template, tokenValues); 86 String contentKey = getContentKeyPrefix() + path; 87 DynamicContent result = new DynamicContent(this, contentKey, path, docText, mimeType, requiresElevatedPrivs); 88 pathToContent.put(result.getContentKey(), result); 89 return result; 90 } 91 92 protected DynamicContent addDynamicContent(DynamicContent content) { 93 pathToContent.put(content.getContentKey(), content); 94 return content; 95 } 96 97 protected StaticContent addStaticContent(String path, URI installRootURI, File file) throws URISyntaxException { 98 String contentKey = getContentKeyPrefix() + path; 99 StaticContent result = new StaticContent(this, contentKey, path, file, installRootURI, false ); 100 return addStaticContent(result); 101 } 102 103 protected StaticContent addStaticContent(StaticContent content) { 104 pathToContent.put(content.getContentKey(), content); 105 return content; 106 } 107 108 112 protected abstract String getContentKeyPrefix(); 113 114 118 public Collection <Content> getContents() { 119 return pathToContent.values(); 120 } 121 122 125 void adhocPathRegistered() { 126 adhocPathRegistered=true; 127 } 128 129 133 boolean isAdhocPathRegistered() { 134 return adhocPathRegistered; 135 } 136 137 141 public String toLongString() { 142 return toString() + pathToContent.toString(); 143 } 144 } 145 | Popular Tags |