Changeset 35719 for other-projects
- Timestamp:
- 2021-11-03T15:24:04+13:00 (2 years ago)
- Location:
- other-projects/the-macronizer/trunk
- Files:
-
- 5 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/the-macronizer/trunk/src/java/monogram/model/ListModel.java
r30062 r35719 12 12 import java.util.HashSet; 13 13 import java.util.Set; 14 import util.Pool;15 14 16 15 … … 21 20 public class ListModel { 22 21 23 private Set<String> specialConditionsList; 24 private final String CHARSET_ENCODING = "utf-8"; 25 private final String DELIMITER = "\t"; 22 // private static final String DELIMITER = "\t"; 23 24 private final String CHARSET_ENCODING = "utf-8"; 25 private final String path; 26 private final Set<String> specialConditionsList; 27 26 28 27 private Pool<String> pool; 28 private final String path; 29 30 public ListModel(String path, Pool<String> pool){ 29 public ListModel(String path) 30 { 31 31 this.path = path; 32 this. pool = pool;33 specialConditionsList = new HashSet(); 32 this.specialConditionsList = new HashSet<String>(); 33 34 34 init(); 35 36 35 } 37 36 38 private void init() { 37 private void init() 38 { 39 39 BufferedReader reader = null; 40 40 try { … … 54 54 } 55 55 56 private void close(Reader reader) { 56 private void close(Reader reader) 57 { 57 58 if (reader != null) { 58 59 try { … … 64 65 } 65 66 66 public Set<String> getMonogramProbabilities() { 67 public Set<String> getMonogramProbabilities() 68 { 67 69 return specialConditionsList; 68 70 } 69 71 70 public boolean contains(String s){71 72 if(specialConditionsList.contains(s)){73 74 75 76 77 78 72 public boolean contains(String s) 73 { 74 if(specialConditionsList.contains(s)) 75 { 76 return true; 77 } 78 79 return false; 80 } 79 81 80 82 -
other-projects/the-macronizer/trunk/src/java/monogram/model/MonogramFactory.java
r29855 r35719 1 2 1 package monogram.model; 3 2 … … 9 8 * When the pool thread is done this it clears the pool. 10 9 * 11 * @see MonogramMode 12 * 10 * @see MonogramModel 13 11 * 14 12 * @author University of Waikato - Te Whare WÄnanga o Waikato … … 16 14 * @since 2014-11-20 17 15 */ 18 19 public class MonogramFactory { 20 16 public class MonogramFactory 17 { 21 18 private final static MonogramModel macronModel; 22 19 private final static MonogramModel doubleVowelModel; 23 private final static ListModel blackList;20 private final static ListModel blackList; 24 21 25 22 static { … … 27 24 macronModel = new MonogramModel("../data/macron", pool); 28 25 doubleVowelModel = new MonogramModel("../data/doublevowel", pool); 29 blackList = new ListModel("../data/list/blacklist.data" , pool);26 blackList = new ListModel("../data/list/blacklist.data"); 30 27 pool.clear(); 31 28 } 32 29 33 30 private MonogramFactory() { 34 // hide constructor.31 // Hide constructor. 35 32 } 36 /** monogram model for macron data (/data/macron) */ 33 34 /** monogram model for macron data (/data/macron) */ 37 35 public static MonogramModel getMacronModel() { 38 39 36 return macronModel; 40 37 } 41 /** monogram model for double vowel data (/data/doubleVowel) */ 38 39 /** Monogram model for double vowel data (/data/doubleVowel) */ 42 40 public static MonogramModel getDoubleVowelModel() { 43 41 return doubleVowelModel; 44 42 } 45 43 46 /** monogram model for black list data (/data/blacklist) */44 /** Monogram model for black list data (/data/blacklist) */ 47 45 public static ListModel getBlackList() { 48 46 return blackList; 49 }47 } 50 48 } -
other-projects/the-macronizer/trunk/src/java/monogram/plugin/PluginConfiguration.java
r29855 r35719 17 17 private String charsetEncoding; 18 18 private boolean preserveExistingMacrons; 19 private boolean markupChangedWorlds; 19 20 20 21 public File getFile() { … … 32 33 public boolean getPreserveExistingMacrons() { 33 34 return preserveExistingMacrons; 35 } 36 37 public boolean getMarkupChangedWords() 38 { 39 return markupChangedWorlds; 34 40 } 35 41 … … 50 56 } 51 57 58 public void setMarkupChangedWords(boolean value) 59 { 60 markupChangedWorlds = value; 61 } 62 52 63 @Override 53 64 public String toString() { -
other-projects/the-macronizer/trunk/src/java/monogram/plugin/PluginDOCX.java
r30062 r35719 35 35 File documentOut = new File(unzipDir, "word" + File.separator + "mi-tmp-document.xml"); 36 36 XMLRestorer restorer = new XMLRestorer(); 37 restorer.restore(documentIn, "utf-8", documentOut, configuration.getPreserveExistingMacrons()); 37 38 restorer.restore 39 ( 40 documentIn, 41 "utf-8", 42 documentOut, 43 configuration.getPreserveExistingMacrons(), 44 configuration.getMarkupChangedWords() 45 ); 46 38 47 //Delete the old document.xml and rename the restored document. 39 48 documentIn.delete(); -
other-projects/the-macronizer/trunk/src/java/monogram/plugin/PluginODT.java
r30062 r35719 35 35 File documentOut = new File(unzipDir, "mi-tmp-content.xml"); 36 36 XMLRestorer restorer = new XMLRestorer(); 37 restorer.restore(documentIn, "utf-8", documentOut, configuration.getPreserveExistingMacrons()); 37 38 restorer.restore 39 ( 40 documentIn, 41 "utf-8", 42 documentOut, 43 configuration.getPreserveExistingMacrons(), 44 configuration.getMarkupChangedWords() 45 ); 46 38 47 //Delete the old document.xml and rename the restored document. 39 48 documentIn.delete(); -
other-projects/the-macronizer/trunk/src/java/monogram/plugin/PluginTXT.java
r30062 r35719 18 18 private File tmpdir; 19 19 20 public PluginTXT(File tmpdir) { 20 public PluginTXT(File tmpdir) 21 { 21 22 this.tmpdir = tmpdir; 22 23 } 23 24 24 public File run(PluginConfiguration configuration) throws IllegalArgumentException, IOException { 25 if (configuration.getCharsetEncoding() == null) { 26 25 public File run(PluginConfiguration configuration) 26 throws IllegalArgumentException, IOException 27 { 28 if (configuration.getCharsetEncoding() == null) 29 { 27 30 throw new IllegalArgumentException(); 28 31 } 32 29 33 final File outputFile = File.createTempFile("mi-tmp-", configuration.getFileType(), tmpdir); 30 34 final TxtRestorer restorer = new TxtRestorer(); 31 restorer.restore(configuration.getFile(), configuration.getCharsetEncoding(), outputFile, configuration.getPreserveExistingMacrons()); 35 36 restorer.restore 37 ( 38 configuration.getFile(), 39 configuration.getCharsetEncoding(), 40 outputFile, 41 configuration.getPreserveExistingMacrons(), 42 configuration.getMarkupChangedWords() 43 ); 44 32 45 return outputFile; 33 46 } -
other-projects/the-macronizer/trunk/src/java/monogram/restorer/MonogramRestorer.java
r30062 r35719 8 8 import monogram.model.ListModel; 9 9 import util.StringUtil; 10 import web.servlets.DirectInput;11 10 12 11 /** 13 * @author University of Waikato - Te Whare WÄnanga o Waikato12 * @author University of Waikato - Te Whare WÄnanga o Waikato 14 13 * @version 1.0 15 * @since 2014-11-2014 * @since 2014-11-20 16 15 */ 17 16 public class MonogramRestorer { … … 21 20 private MonogramModel doubleVowelModel; 22 21 private ListModel blackListModel; 23 22 24 23 private String previousToken; 25 24 private String currentToken; … … 30 29 macronModel = MonogramFactory.getMacronModel(); 31 30 doubleVowelModel = MonogramFactory.getDoubleVowelModel(); 32 31 blackListModel = MonogramFactory.getBlackList(); 33 32 previousToken = ""; 34 33 selector = new Selector(3); 35 34 } 36 35 37 public String restore(String token ) {38 39 // Test to see if it should preserve the macrons already in the input texts. Ifnot remove all macrons.36 public String restore(String token, Boolean markupChangedWords) { 37 // Test to see if it should preserve the macrons already in the input texts. If 38 // not remove all macrons. 40 39 if (!preserveMacrons && StringUtil.containsAccents(token)) { 41 40 token = StringUtil.removeAccents(token); 42 41 } 43 44 42 45 43 // Make lower case copy of token. 46 44 final String tokenLowerCase = token.toLowerCase(); 47 45 48 46 String restoredToken = token; 49 //If the word is in the black list return the token with no macron. 50 if(blackListModel.contains(token)){return restoredToken;} 47 // If the word is in the black list return the token with no macron. 48 if (blackListModel.contains(token)) { 49 return restoredToken; 50 } 51 51 // Is selector > 0 it is on a sequence 52 52 if (selector.isMacronTokenSequence()) { 53 53 if (restoreByMacronModel(tokenLowerCase)) { 54 55 //Restore capitalization 54 // Restore capitalization 56 55 restoredToken = StringUtil.copyCapitalization(token, currentToken); 57 // If restoredToken is not the same as token then macron/s have been add so add <mark> html. This is the yellow background around the words on the front end. 58 if(!restoredToken.equals(token)){ 59 // only add <mark> html tag if it directinput and not being output to a file. 60 if(DirectInput.DI){restoredToken = "<mark>"+restoredToken+"</mark> ";} 61 } 62 63 //if the tonken can not be restored by the MacronModel try and restor it with the DoubleVowelModel. 56 // If restoredToken is not the same as token then macron/s have been add so add 57 // <mark> html. This is the yellow background around the words on the front end. 58 if (!restoredToken.equals(token)) { 59 // only add <mark> html tag if it directinput and not being output to a file. 60 if (markupChangedWords) { 61 restoredToken = "<mark>" + restoredToken + "</mark> "; 62 } 63 } 64 65 // if the tonken can not be restored by the MacronModel try and restor it with 66 // the DoubleVowelModel. 64 67 } else if (restoreByDoubleVowelModel(tokenLowerCase)) { 65 68 restoredToken = StringUtil.copyDVowelCapitalization(token, currentToken); … … 67 70 currentToken = tokenLowerCase; 68 71 } 69 } 72 } 70 73 // else if it is not in a sequence 71 74 else { … … 73 76 if (restoreByDoubleVowelModel(tokenLowerCase)) { 74 77 restoredToken = StringUtil.copyDVowelCapitalization(token, currentToken); 75 } 78 } 76 79 // try and restor it with the MacronModel 77 80 else if (restoreByMacronModel(tokenLowerCase)) { 78 81 restoredToken = StringUtil.copyCapitalization(token, currentToken); 79 } 82 } 80 83 // Dose not need to be restored 81 84 else { … … 87 90 } 88 91 89 // trys to restore by using the MacronModel and return boolean if it has. 92 // trys to restore by using the MacronModel and return boolean if it has. 90 93 private boolean restoreByMacronModel(String token) { 91 92 // Test to see if token is in the Distinct Transformation hashset. 94 95 // Test to see if token is in the Distinct Transformation hashset. 93 96 if (macronModel.isDistinctTransformation(token)) { 94 //if token is in Distinct Transformation hashset make the distinct ransformation then move along the sequence. 97 // if token is in Distinct Transformation hashset make the distinct 98 // ransformation then move along the sequence. 95 99 currentToken = macronModel.getDistinctTransformation(token); 96 100 selector.incrementMacronTokenSequence(); 97 101 return true; 98 } 99 // If token is in Indistinct Transformation hashset 102 } 103 // If token is in Indistinct Transformation hashset 100 104 else if (macronModel.isIndistinctTransformation(token)) { 101 105 final String[] transformations = macronModel.getIndistinctTransformation(token); 102 106 double maxProbability = Double.MIN_VALUE; 103 107 String maxToken = token; 104 // loops all transformation and finds the one with the highest probability given the previous token. 108 // loops all transformation and finds the one with the highest probability given 109 // the previous token. 105 110 for (String transformation : transformations) { 106 // double probability = macronModel.getIndistinctProbability(transformation);111 // double probability = macronModel.getIndistinctProbability(transformation); 107 112 double probability = 1.0; 108 //if macron model has a probability for this transformation then get its probability. 113 // if macron model has a probability for this transformation then get its 114 // probability. 109 115 if (macronModel.containsMonogramProbability(transformation, previousToken)) { 110 116 probability *= macronModel.getMonogramProbability(transformation, previousToken); 111 117 } 112 113 // if transformation not in macron model then try and find probability in Indistinct probability 118 119 // if transformation not in macron model then try and find probability in 120 // Indistinct probability 114 121 if (probability == 1.0) { 115 122 probability = macronModel.getIndistinctProbability(transformation); 116 123 } 117 118 //If probability is better then any before it update maxProbability and maxToken. 124 125 // If probability is better then any before it update maxProbability and 126 // maxToken. 119 127 if (probability >= maxProbability) { 120 128 maxProbability = probability; … … 144 152 String maxToken = token; 145 153 for (String transformation : transformations) { 146 //double probability = doubleVowelModel.getIndistinctProbability(transformation); 154 // double probability = 155 // doubleVowelModel.getIndistinctProbability(transformation); 147 156 148 157 double probability = 1.0; … … 191 200 } 192 201 193 public boolean isDoubleVowelTokenSequence() {194 return current == 0;195 }202 // public boolean isDoubleVowelTokenSequence() { 203 // return current == 0; 204 // } 196 205 } 197 206 } -
other-projects/the-macronizer/trunk/src/java/monogram/restorer/TxtRestorer.java
r30062 r35719 28 28 } 29 29 30 public void restore(File inputFile, String inputCharsetEncoding, File outputFile, boolean preserveMacrons ) {30 public void restore(File inputFile, String inputCharsetEncoding, File outputFile, boolean preserveMacrons, boolean markupChangedWords) { 31 31 MonogramRestorer restorer = new MonogramRestorer(preserveMacrons); 32 32 BufferedReader reader = null; … … 43 43 final String nonToken = matcher.group(2); 44 44 if (token != null) { 45 String restoredToken = restorer.restore(token );45 String restoredToken = restorer.restore(token, markupChangedWords); 46 46 writer.write(restoredToken); 47 47 } else { -
other-projects/the-macronizer/trunk/src/java/monogram/restorer/XMLRestorer.java
r29855 r35719 26 26 } 27 27 28 public void restore(File inputFile, String inputCharsetEncoding, File outputFile, boolean preserveMacrons ) {28 public void restore(File inputFile, String inputCharsetEncoding, File outputFile, boolean preserveMacrons, boolean markupChangedWords) { 29 29 MonogramRestorer restorer = new MonogramRestorer(preserveMacrons); 30 30 final StringBuilder buffer = new StringBuilder(); … … 50 50 buffer.append(reader.nextChar()); 51 51 } 52 final String restoredToken = restorer.restore(buffer.toString() );52 final String restoredToken = restorer.restore(buffer.toString(), markupChangedWords); 53 53 writer.write(restoredToken); 54 54 } else if (CharacterUtil.isPunctuation(peek)) { 55 final String restoredToken = restorer.restore(String.valueOf(reader.nextChar()) );55 final String restoredToken = restorer.restore(String.valueOf(reader.nextChar()), markupChangedWords); 56 56 writer.write(restoredToken); 57 57 } else { -
other-projects/the-macronizer/trunk/src/java/util/FileUtil.java
r29855 r35719 13 13 public class FileUtil { 14 14 15 p rivate final String TMP_FILE_SUFFIX = "mi-tmp-";15 public static final String TMP_FILE_PREFIX = "mi-tmp-"; 16 16 17 17 /** -
other-projects/the-macronizer/trunk/src/java/util/FixedLinkedList.java
r29855 r35719 4 4 import java.util.Collection; 5 5 import java.util.LinkedList; 6 import java.util.List;7 6 8 7 /** -
other-projects/the-macronizer/trunk/src/java/util/MySQLAccess.java
r32755 r35719 17 17 18 18 import java.util.Properties; 19 20 import java.util.List;21 19 22 20 … … 99 97 statement = connect.createStatement(); 100 98 101 int result =statement.executeUpdate("set names utf8mb4"); // should return 0 for SQL stmts that return nothing99 statement.executeUpdate("set names utf8mb4"); // should return 0 for SQL stmts that return nothing 102 100 System.out.println("Connected to MySQL DB " + DB_NAME); 103 101 success = true; … … 210 208 211 209 //Occurrence into 212 private int insertOccurrence(int wordID, int timeID, int dateID) throws SQLException { 210 private int insertOccurrence(int wordID, int timeID, int dateID) 211 throws SQLException 212 { 213 213 String query = "INSERT INTO Occurrences (word_id, time_id, date_id) VALUES (?,?,?)"; 214 214 preparedStatement = connect.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); … … 218 218 219 219 int occurrence_id = -1; 220 try { 221 int result = preparedStatement.executeUpdate(); 220 221 try 222 { 223 preparedStatement.executeUpdate(); 222 224 resultSet = preparedStatement.getGeneratedKeys(); 223 225 224 if (resultSet.next()) { 226 if (resultSet.next()) 227 { 225 228 occurrence_id = resultSet.getInt(1); 226 229 } 227 230 228 } catch (SQLException e) { 231 } 232 catch (SQLException e) 233 { 229 234 throw e; // any other SQLException is a bad case, so we'll handle it in the caller 230 } finally {231 return occurrence_id; 232 }235 } 236 237 return occurrence_id; 233 238 } 234 239 … … 269 274 270 275 int word_id = -1; 271 try { 272 int result = preparedStatement.executeUpdate(); 276 277 try { 278 preparedStatement.executeUpdate(); 273 279 274 280 resultSet = preparedStatement.getGeneratedKeys(); … … 287 293 } catch (SQLException e) { 288 294 throw e; // any other SQLException is a bad case, so we'll handle it in the caller 289 } finally {290 return word_id;291 }295 } 296 297 return word_id; 292 298 } 293 299 … … 318 324 319 325 int date_id = -1; 320 try { 321 int result = preparedStatement.executeUpdate(); 326 327 try { 328 preparedStatement.executeUpdate(); 322 329 resultSet = preparedStatement.getGeneratedKeys(); 323 330 … … 333 340 } catch (SQLException e) { 334 341 throw e; // any other SQLException is a bad case, so we'll handle it in the caller 335 } finally {336 return date_id;337 }342 } 343 344 return date_id; 338 345 } 339 346 … … 364 371 int time_id = -1; 365 372 try { 366 int result =preparedStatement.executeUpdate();373 preparedStatement.executeUpdate(); 367 374 resultSet = preparedStatement.getGeneratedKeys(); 368 375 … … 378 385 } catch (SQLException e) { 379 386 throw e; // any other SQLException is a bad case, so we'll handle it in the caller 380 } finally {381 return time_id;382 }387 } 388 389 return time_id; 383 390 } 384 391 -
other-projects/the-macronizer/trunk/src/java/util/Utils4JJ.java
r29855 r35719 95 95 * @return Package path for the class. 96 96 */ 97 public static String getPackagePath(final Class clasz) {97 public static String getPackagePath(final Class<?> clasz) { 98 98 checkNotNull("clasz", clasz); 99 99 return clasz.getPackage().getName().replace('.', '/'); … … 111 111 * @return Resource URL. 112 112 */ 113 public static URL getResource(final Class clasz, final String name) {113 public static URL getResource(final Class<?> clasz, final String name) { 114 114 checkNotNull("clasz", clasz); 115 115 checkNotNull("name", name); … … 130 130 * @return Properties. 131 131 */ 132 public static Properties loadProperties(final Class clasz,132 public static Properties loadProperties(final Class<?> clasz, 133 133 final String filename) { 134 134 checkNotNull("clasz", clasz); … … 264 264 checkNotNull("className", className); 265 265 try { 266 final Class clasz = Class.forName(className);266 final Class<?> clasz = Class.forName(className); 267 267 return clasz.newInstance(); 268 268 } catch (final ClassNotFoundException e) { … … 281 281 * URL to add - Cannot be <code>null</code>. 282 282 */ 283 public static void addToClasspath(final String url) { 283 public static void addToClasspath(final String url) 284 throws IOException 285 { 284 286 checkNotNull("url", url); 285 287 try { … … 657 659 * URL to add - Cannot be <code>null</code>. 658 660 */ 659 public static void addToClasspath(final URL url) { 661 public static void addToClasspath(final URL url) 662 throws IOException 663 { 660 664 checkNotNull("url", url); 661 665 final ClassLoader classLoader = Utils4JJ.class.getClassLoader(); … … 681 685 throw new RuntimeException(e); 682 686 } 687 finally { 688 urlClassLoader.close(); 689 } 683 690 } 684 691 } … … 730 737 */ 731 738 private static String getMethodSignature(final String returnType, 732 final String methodName, final Class [] argTypes) {739 final String methodName, final Class<?>[] argTypes) { 733 740 final StringBuffer sb = new StringBuffer(); 734 741 if (returnType != null) { … … 771 778 */ 772 779 public static Object invoke(final Object obj, final String methodName, 773 final Class [] argTypes, final Object[] args)780 final Class<?>[] argTypes, final Object[] args) 774 781 throws InvokeMethodFailedException { 775 782 … … 777 784 checkNotNull("methodName", methodName); 778 785 779 final Class [] argTypesIntern;786 final Class<?>[] argTypesIntern; 780 787 final Object[] argsIntern; 781 788 if (argTypes == null) { … … 842 849 } 843 850 844 private static void checkSameLength(final Class [] argTypes,851 private static void checkSameLength(final Class<?>[] argTypes, 845 852 final Object[] args) { 846 853 if (argTypes.length != args.length) { … … 904 911 final ZipFile zip = new ZipFile(zipFile); 905 912 try { 906 final Enumeration enu = zip.entries();913 final Enumeration<?> enu = zip.entries(); 907 914 while (enu.hasMoreElements() 908 915 && ((cancelable == null) || !cancelable.isCanceled())) { … … 1025 1032 * unchanged. 1026 1033 */ 1027 public static String replaceVars(final String str, final Map vars) {1034 public static String replaceVars(final String str, final Map<?, ?> vars) { 1028 1035 1029 1036 if (str == null) { -
other-projects/the-macronizer/trunk/src/java/web/listeners/MyHttpSessionListener.java
r29855 r35719 2 2 3 3 import java.io.File; 4 import javax.servlet.http.HttpSession;5 4 import javax.servlet.http.HttpSessionEvent; 6 5 import javax.servlet.http.HttpSessionListener; -
other-projects/the-macronizer/trunk/src/java/web/listeners/MyServletContextListener.java
r30060 r35719 3 3 4 4 import java.io.File; 5 import java.io.IOException;6 5 import java.util.Properties; 7 6 import java.util.Timer; -
other-projects/the-macronizer/trunk/src/java/web/servlets/DirectInput.java
r31962 r35719 1 /*2 * To change this template, choose Tools | Templates3 * and open the template in the editor.4 */5 1 package web.servlets; 6 2 … … 13 9 import java.io.InputStreamReader; 14 10 import java.io.OutputStreamWriter; 15 import java.io. Reader;16 import java.io.Writer; 11 import java.io.UnsupportedEncodingException; 12 17 13 import javax.servlet.RequestDispatcher; 18 14 import javax.servlet.ServletConfig; … … 21 17 import javax.servlet.http.HttpServletRequest; 22 18 import javax.servlet.http.HttpServletResponse; 19 20 import com.google.gson.Gson; 21 import com.google.gson.stream.JsonWriter; 22 23 23 import monogram.plugin.PluginConfiguration; 24 24 import monogram.plugin.PluginManager; 25 25 26 import org.apache.log4j.*; 26 27 28 import util.FileUtil; 29 import util.IOUtil; 30 27 31 /** 28 * 32 * Represents a servlet for macronising direct text input. 29 33 * @author OEM 34 * @version 2.0 30 35 */ 31 public class DirectInput extends HttpServlet { 32 33 private final String UNEXPECTED_ERROR = "An unexpected error has occurred. Please try again or contact the web administrator if the problem persists."; 34 private final String UTF8_ENCODING = "utf-8"; 35 public static boolean DI; // This will be used in a test in the mongramRestorer to add html to highlight the changes on the webpage output. 36 public class DirectInput extends HttpServlet 37 { 38 private static final String UTF8_ENCODING = "utf-8"; 39 40 //Create an instance of the logger object defined for this class in log4j.properties 41 private static final Logger logger = Logger.getLogger(web.servlets.DirectInput.class.getName()); 42 43 private final Gson gsonInstance = new Gson(); 44 36 45 private File tmpdir; 37 //Create an instance of the Logger object created for this class in log4j.properties 38 static Logger logger = Logger.getLogger(web.servlets.DirectInput.class.getName()); 46 private PluginManager pluginManager; 39 47 40 48 @Override 41 public void init(ServletConfig config) throws ServletException { 49 public void init(ServletConfig config) throws ServletException 50 { 42 51 super.init(config); 52 43 53 tmpdir = new File((String) config.getServletContext().getAttribute("tmpdir")); 44 } 45 46 /** 47 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. 48 * @param request servlet request 49 * @param response servlet response 50 * @throws ServletException if a servlet-specific error occurs 51 * @throws IOException if an I/O error occurs 52 */ 53 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 54 throws ServletException, IOException { 55 } 56 57 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> 54 pluginManager = new PluginManager(tmpdir); 55 } 56 58 57 /** 59 58 * Handles the HTTP <code>GET</code> method. 60 * @param request servlet request61 * @param response servlet response62 * @throws ServletException if a servlet-specific error occurs63 * @throws IOException if an I/O error occurs 59 * @param request The servlet request. 60 * @param response The servlet response. 61 * @throws IllegalStateException if a reponse has already been committed. 62 * @throws IOException if an I/O error occurs. 64 63 */ 65 64 @Override 66 65 protected void doGet(HttpServletRequest request, HttpServletResponse response) 67 throws ServletException, IOException { 68 processRequest(request, response); 66 throws IllegalStateException, IOException 67 { 68 response.sendError(405); // 405 Method Not Allowed 69 69 } 70 70 71 71 /** 72 72 * Handles the HTTP <code>POST</code> method. 73 * @param request servlet request 74 * @param response servlet response 75 * @throws ServletException if a servlet-specific error occurs 76 * @throws IOException if an I/O error occurs 73 * @param request The servlet request. 74 * @param response The servlet response. 75 * @throws IllegalStateException if a response has already been committed. 76 * @throws IOException if an I/O error occurs. 77 * @throws ServletException if a servlet-specific error occurs. 78 * @throws UnsupportedEncodingException if the selected encoding is not supported. 77 79 */ 78 80 @Override 79 81 protected void doPost(HttpServletRequest request, HttpServletResponse response) 80 throws ServletException, IOException { 81 request.setCharacterEncoding("utf-8"); 82 DI = true; 82 throws IllegalStateException, IOException, ServletException, UnsupportedEncodingException 83 { 84 request.setCharacterEncoding(UTF8_ENCODING); 85 83 86 final String fragment = request.getParameter("fragment"); 87 final Boolean showAdvancedOptions = request.getParameter("options") != null && request.getParameter("options").equals("true"); 88 final Boolean shouldPreserveMacrons = request.getParameter("preserveExistingMacrons") != null && request.getParameter("preserveExistingMacrons").equals("true"); 89 final OutputType outputType = OutputType.parse(request.getParameter("o")); 90 91 // Note that the lang parameter might be null if the request hasn't been made from an internal JSP page 84 92 final String lang = request.getParameter("lang"); 85 final String preserveMacrons = request.getParameter("preserveExistingMacrons") != null ? request.getParameter("preserveExistingMacrons") : "false"; 86 final String options = request.getParameter("options"); 87 final String path = "/jsp" + (lang.equals("en") ? "/en" : "/mi"); 88 //Write the input to a temporary file. 89 File file = File.createTempFile("mi-tmp-", ".txt", tmpdir); 90 write(file, "utf-8", fragment); 93 final String forwardPath = lang != null ? "/jsp/" + lang : "/jsp/mi"; 94 95 try 96 { 97 final String restoredFragment = restoreMacrons 98 ( 99 fragment, 100 shouldPreserveMacrons, 101 true //outputType == OutputType.JspRedirect 102 ); 103 104 if (outputType == OutputType.Json) 105 { 106 response.setContentType("application/json; charset=UTF-8"); 107 JsonWriter writer = gsonInstance.newJsonWriter(response.getWriter()); 108 writer.beginArray(); 109 110 for (String element : restoredFragment.split("\\ ")) 111 { 112 writer.beginObject(); 113 114 if (element.contains("<mark>")) 115 { 116 element = element.replace("<mark>", "").replace("</mark>", ""); 117 writer.name("macronised"); 118 writer.value(true); 119 } 120 121 writer.name("w"); 122 writer.value(element); 123 124 writer.endObject(); 125 } 126 127 writer.endArray(); 128 writer.flush(); 129 } 130 else 131 { 132 request.setAttribute("fragment2", restoredFragment); 133 request.setAttribute("old", fragment); 134 request.setAttribute("options", showAdvancedOptions.toString()); 135 request.setAttribute("preserveMacrons", shouldPreserveMacrons.toString()); 136 137 forward(forwardPath + "/main.jsp", request, response); 138 } 139 140 logger.info("Macron restoration succeeded. Input: " + fragment + " | Output: " + restoredFragment); 141 } 142 catch (Exception ex) 143 { 144 ex.printStackTrace(); 145 logger.error("Failed to restore macrons", ex); 146 147 switch (outputType) { 148 case Json: 149 // 500 Internal Server Error 150 response.sendError(500, "An unexpected error has occurred. Please try again or contact the web administrator if the problem persists."); 151 break; 152 default: 153 request.setAttribute("errorMessage", "UNEXPECTED_ERROR"); 154 forward(forwardPath + "/error.jsp", request, response); 155 break; 156 } 157 } 158 } 159 160 /** 161 * Restores macrons on an input fragment. 162 * @param input The input fragment to restore. 163 * @param preserveMacrons Indicates whether existing macrons on the input should be preserved. 164 * @return The macronised fragment. 165 * @throws IOException 166 * @throws UnsupportedOperationException 167 * @throws Exception 168 */ 169 private String restoreMacrons(String input, boolean preserveMacrons, boolean markupChangedWords) 170 throws IOException, UnsupportedOperationException, Exception 171 { 172 //Write the input to a temporary file. 173 File inputFile = File.createTempFile(FileUtil.TMP_FILE_PREFIX, ".txt", tmpdir); 174 write(inputFile, UTF8_ENCODING, input); 91 175 92 176 //Create a fileview 93 177 PluginConfiguration configuration = new PluginConfiguration(); 94 configuration.setFile( file);95 configuration.setCharsetEncoding( "utf-8");178 configuration.setFile(inputFile); 179 configuration.setCharsetEncoding(UTF8_ENCODING); 96 180 configuration.setFileType(".txt"); 97 configuration.setPreserveExistingMacrons(preserveMacrons.equals("true")); 181 configuration.setPreserveExistingMacrons(preserveMacrons); 182 configuration.setMarkupChangedWords(markupChangedWords); 183 98 184 //Restore the file. 99 PluginManager pluginManager = new PluginManager(tmpdir);100 185 File restoredFile = null; 101 try { 186 187 try 188 { 102 189 restoredFile = pluginManager.run(configuration); 103 //Read the file into a String then delete 104 String restoredFragment = read(restoredFile, "utf-8"); 105 106 request.setAttribute("fragment2", restoredFragment); 107 request.setAttribute("old", fragment); 108 request.setAttribute("options", options); 109 request.setAttribute("preserveMacrons", preserveMacrons); 110 RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(path + "/main.jsp"); 111 dispatcher.forward(request, response); 112 //Generate an "info" level logger message including the input('fragment') and output('restoredFragment') 113 logger.info("Input:"+fragment+"Output: "+restoredFragment); 114 } catch (Exception e) { 115 request.setAttribute("errorMessage", UNEXPECTED_ERROR); 116 forward(path + "/error.jsp", request, response); 117 } finally { 118 file.delete(); 119 if (restoredFile != null) { 120 restoredFile.delete(); 121 } 190 return read(restoredFile, UTF8_ENCODING).trim(); 191 } 192 finally 193 { 194 inputFile.delete(); 195 196 if (restoredFile != null) 197 { 198 restoredFile.delete(); 199 } 122 200 } 123 201 } … … 125 203 /** 126 204 * Forwards a request from a servlet to another resource on the server. 127 * @param path Path to forward to.128 * @param request 129 * @param response 205 * @param path The path to forward to. 206 * @param request The servlet request. 207 * @param response The servlet response. 130 208 * @throws ServletException 131 209 * @throws IOException 132 210 */ 133 211 private void forward(String path, HttpServletRequest request, HttpServletResponse response) 134 throws ServletException, IOException { 212 throws ServletException, IOException 213 { 135 214 final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(path); 136 215 dispatcher.forward(request, response); … … 141 220 * @param file The file to write to. 142 221 * @param fragment The String to write to the file. 143 */ 144 private void write(File file, String charsetEncoding, String fragment) { 222 * @throws IOException 223 */ 224 private void write(File file, String charsetEncoding, String fragment) 225 throws IOException 226 { 145 227 BufferedWriter out = null; 146 try { 228 try 229 { 147 230 out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charsetEncoding)); 148 231 out.write(fragment); 149 } catch (IOException e) {150 e.printStackTrace();151 } finally{152 close(out);232 } 233 finally 234 { 235 IOUtil.closeWriter(out); 153 236 } 154 237 } … … 159 242 * @param charsetEncoding The character set encoding of the file. 160 243 * @return The contents of the file. 161 */ 162 private String read(File file, String charsetEncoding) { 244 * @throws IOException 245 */ 246 private String read(File file, String charsetEncoding) 247 throws IOException 248 { 163 249 final StringBuilder buffer = new StringBuilder(); 164 250 BufferedReader reader = null; 165 try { 251 252 try 253 { 166 254 reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetEncoding)); 167 255 final char[] chars = new char[1024]; 168 256 int numRead = 0; 169 while ((numRead = reader.read(chars)) > -1) { 257 258 while ((numRead = reader.read(chars)) > -1) 259 { 170 260 buffer.append(String.valueOf(chars, 0, numRead)); 171 261 } 172 } catch (IOException e) { 173 e.printStackTrace(); 174 } finally { 175 close(reader); 176 } 262 } 263 finally 264 { 265 IOUtil.closeReader(reader); 266 } 267 177 268 return buffer.toString(); 178 269 } 179 180 /**181 * Close the writer.182 * @param writer The Writer to close.183 */184 private void close(Writer writer) {185 if (writer != null) {186 try {187 writer.close();188 } catch (IOException e) {189 e.printStackTrace();190 }191 }192 }193 194 /**195 * Close the reader.196 * @param reader The Reader to close.197 */198 private void close(Reader reader) {199 if (reader != null) {200 try {201 reader.close();202 } catch (IOException e) {203 e.printStackTrace();204 }205 }206 }207 208 /**209 * Returns a short description of the servlet.210 * @return a String containing servlet description211 */212 @Override213 public String getServletInfo() {214 return "Short description";215 }// </editor-fold>216 270 } -
other-projects/the-macronizer/trunk/src/java/web/servlets/Download.java
r29855 r35719 7 7 import java.io.InputStream; 8 8 import java.io.PrintWriter; 9 import javax.servlet.RequestDispatcher; 9 10 10 import javax.servlet.ServletException; 11 11 import javax.servlet.ServletOutputStream; -
other-projects/the-macronizer/trunk/src/java/web/servlets/FileUpload.java
r31964 r35719 1 1 package web.servlets; 2 2 3 import java.io.BufferedReader;4 3 import java.io.File; 5 import java.io.FileReader;6 4 import java.io.IOException; 7 import java. lang.StringBuilder;5 import java.util.ArrayList; 8 6 import java.util.List; 7 9 8 import javax.servlet.RequestDispatcher; 10 9 import javax.servlet.ServletConfig; … … 13 12 import javax.servlet.http.HttpServletRequest; 14 13 import javax.servlet.http.HttpServletResponse; 14 15 import monogram.plugin.PluginConfiguration; 16 import monogram.plugin.PluginManager; 17 15 18 import org.apache.commons.fileupload.FileItem; 19 import org.apache.commons.fileupload.FileUploadException; 16 20 import org.apache.commons.fileupload.disk.DiskFileItemFactory; 17 21 import org.apache.commons.fileupload.servlet.ServletFileUpload; 18 import monogram.plugin.PluginConfiguration; 22 import org.apache.log4j.*; 23 19 24 import util.FileUtil; 20 import monogram.plugin.PluginManager;21 import org.apache.log4j.*;22 25 23 26 /** … … 28 31 public class FileUpload extends HttpServlet { 29 32 33 // Create an instance of the logger object defined for the DirectInput servlet in log4j.properties. 34 private static final Logger logger = Logger.getLogger(web.servlets.DirectInput.class.getName()); 35 30 36 private File tmpdir; 31 private String inputFile; 32 private String outputFile; 33 34 //Create an instance of the Logger object created for this class in log4j.properties 35 static Logger logger = Logger.getLogger(web.servlets.DirectInput.class.getName()); 37 private PluginManager pluginManager; 36 38 37 39 @Override 38 public void init(ServletConfig config) throws ServletException { 40 public void init(ServletConfig config) 41 throws ServletException 42 { 39 43 super.init(config); 44 40 45 tmpdir = new File((String) config.getServletContext().getAttribute("tmpdir")); 41 } 42 43 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 44 throws ServletException, IOException { 45 //do nothing 46 } 47 46 pluginManager = new PluginManager(tmpdir); 47 } 48 49 /** 50 * Handles the HTTP <code>GET</code> method. 51 * @param request The servlet request. 52 * @param response The servlet response. 53 * @throws IllegalStateException if a reponse has already been committed. 54 * @throws IOException if an I/O error occurs. 55 */ 48 56 @Override 49 57 protected void doGet(HttpServletRequest request, HttpServletResponse response) 50 throws ServletException, IOException { 51 processRequest(request, response); 58 throws IllegalStateException, IOException 59 { 60 response.sendError(405); // 405 Method Not Allowed 52 61 } 53 62 … … 61 70 @Override 62 71 protected void doPost(HttpServletRequest request, HttpServletResponse response) 63 throws ServletException, IOException { 64 // set DI to false as this is not Directinput. 65 DirectInput.DI = false; 66 final Properties properties = handleRequest(request); 67 final String address = "/jsp" + (properties.getLanguage().equals("en") ? "/en" : "/mi"); 68 final PluginConfiguration configuration = configure(properties); 69 final PluginManager pluginManager = new PluginManager(tmpdir); 70 71 if (configuration.getFile().length() == 0) { 72 configuration.getFile().delete(); 73 request.setAttribute("errorCode", "FILE_NOT_FOUND_ERROR"); 74 forward(address + "/error.jsp", request, response); 75 return; 76 } 77 72 throws IllegalStateException, IOException, ServletException 73 { 74 final OutputType outputType = OutputType.parse(request.getParameter("o")); // TODO: This probably won't work with the multipart request 75 78 76 File restoredFile = null; 79 try { 77 PluginConfiguration configuration = null; 78 Properties properties = null; 79 String forwardPath = "/jsp/mi"; 80 81 try 82 { 83 properties = handleRequest(request); 84 forwardPath = properties.getLanguage() != null ? "/jsp/" + properties.getLanguage() : forwardPath; 85 } 86 catch (Exception ex) 87 { 88 setError(outputType, forwardPath, "INVALID_REQUEST", request, response); 89 } 90 91 try 92 { 93 configuration = configure(properties); 94 95 if (configuration.getFile().length() == 0) 96 { 97 configuration.getFile().delete(); 98 setError(outputType, forwardPath, "FILE_NOT_FOUND_ERROR", request, response); 99 return; 100 } 101 80 102 restoredFile = pluginManager.run(configuration); 81 103 request.setAttribute("file", restoredFile); … … 85 107 request.setAttribute("preserveMacrons", properties.getPreserveExistingMacrons()); 86 108 request.setAttribute("options", properties.getOptions()); 87 forward( address+ "/main.jsp", request, response);88 outputFile = stringFromFile(restoredFile); 89 logger.error("Output:"+outputFile); 90 } catch (UnsupportedOperationException e){109 forward(forwardPath + "/main.jsp", request, response); 110 } 111 catch (UnsupportedOperationException uoex) 112 { 91 113 FileUtil.deleteFile(restoredFile); 92 request.setAttribute("errorCode", "FILE_TYPE_NOT_SUPPORTED_ERROR"); 93 forward(address + "/error.jsp", request, response); 94 } catch (Exception e) { 114 logger.error("Failed to restore macrons on a file", uoex); 115 setError(outputType, forwardPath, "FILE_TYPE_NOT_SUPPORTED_ERROR", request, response); 116 } 117 catch (Exception ex) 118 { 95 119 FileUtil.deleteFile(restoredFile); 96 request.setAttribute("errorCode", "UNEXPECTED_ERROR"); 97 forward(address + "/error.jsp", request, response); 98 } finally { 99 FileUtil.deleteFile(configuration.getFile()); 100 } 101 } 102 120 ex.printStackTrace(); 121 logger.error("Failed to restore macrons on a file", ex); 122 setError(outputType, forwardPath, "UNEXPECTED_ERROR", request, response); 123 } 124 finally 125 { 126 if (configuration != null) 127 { 128 FileUtil.deleteFile(configuration.getFile()); 129 } 130 } 131 } 132 133 private void setError(OutputType outputType, String forwardPath, String errorCode, HttpServletRequest request, HttpServletResponse response) 134 throws IOException, ServletException 135 { 136 switch (outputType) { 137 case Json: 138 // 500 Internal Server Error 139 response.sendError(500, errorCode); 140 break; 141 default: 142 request.setAttribute("errorMessage", errorCode); 143 forward(forwardPath + "/error.jsp", request, response); 144 break; 145 } 146 } 147 148 /** 149 * Forwards a request from a servlet to another resource on the server. 150 * @param path The path to forward to. 151 * @param request The servlet request. 152 * @param response The servlet response. 153 * @throws ServletException 154 * @throws IOException 155 */ 103 156 private void forward(String path, HttpServletRequest request, HttpServletResponse response) 104 throws ServletException, IOException { 157 throws ServletException, IOException 158 { 105 159 final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(path); 106 160 dispatcher.forward(request, response); 107 161 } 108 162 109 private Properties handleRequest(HttpServletRequest request) { 163 private Properties handleRequest(HttpServletRequest request) 164 throws Exception, FileUploadException, IOException 165 { 110 166 Properties requestData = new Properties(); 111 167 DiskFileItemFactory factory = new DiskFileItemFactory(); 112 168 factory.setSizeThreshold(10 * 1024 * 1024); 113 169 ServletFileUpload upload = new ServletFileUpload(factory); 114 try { 115 //System.out.println("looking at request parameters..."); 116 List<FileItem> items = upload.parseRequest(request); 117 118 for (FileItem item : items) { 119 if (item.isFormField()) { 120 String fieldName = item.getFieldName(); 121 String fieldValue = item.getString(); 122 if (fieldName.equals("charsetEncoding")) { 123 requestData.setCharsetEncoding(fieldValue); 124 } else if (fieldName.equals("fileType")) { 125 requestData.setFileType(fieldValue); 126 } else if (fieldName.equals("preserveExistingMacrons")) { 127 requestData.setPreserveExistingMacrons(fieldValue); 128 } else if (fieldName.equals("lang")) { 129 requestData.setLanguage(fieldValue); 130 } else if (fieldName.equals("options")) { 131 requestData.setOptions(fieldValue); 132 } 133 } else { 134 String fileType = FileUtil.guessFileType(new File(item.getName())); 135 File file = File.createTempFile("mi-tmp-", fileType, tmpdir); 136 item.write(file); 137 requestData.setFile(file); 138 requestData.setFilename(item.getName()); 139 inputFile=stringFromFile(file); 140 // logger.error("Input:"+logText); 170 171 List<FileItem> items = new ArrayList<>(); 172 for (Object element : upload.parseRequest(request)) { 173 items.add(FileItem.class.cast(element)); 174 } 175 176 for (FileItem item : items) 177 { 178 if (item.isFormField()) 179 { 180 String fieldName = item.getFieldName(); 181 String fieldValue = item.getString(); 182 if (fieldName.equals("charsetEncoding")) { 183 requestData.setCharsetEncoding(fieldValue); 184 } else if (fieldName.equals("fileType")) { 185 requestData.setFileType(fieldValue); 186 } else if (fieldName.equals("preserveExistingMacrons")) { 187 requestData.setPreserveExistingMacrons(fieldValue); 188 } else if (fieldName.equals("lang")) { 189 requestData.setLanguage(fieldValue); 190 } else if (fieldName.equals("options")) { 191 requestData.setOptions(fieldValue); 141 192 } 142 193 } 143 } catch (Exception e) { 144 e.printStackTrace(); 145 } 194 else 195 { 196 String fileType = FileUtil.guessFileType(new File(item.getName())); 197 File file = File.createTempFile(FileUtil.TMP_FILE_PREFIX, fileType, tmpdir); 198 item.write(file); 199 requestData.setFile(file); 200 requestData.setFilename(item.getName()); 201 } 202 } 203 146 204 return requestData; 147 205 } 148 206 149 private String stringFromFile(File file)throws IOException{ 150 BufferedReader reader = new BufferedReader(new FileReader(file)); 151 String line = null; 152 StringBuilder sb = new StringBuilder(); 153 try{ 154 while((line=reader.readLine())!=null){ 155 sb.append(line); 156 } 157 } 158 catch (Exception e){ 159 e.printStackTrace(); 160 } 161 finally{ 162 reader.close(); 163 } 164 return sb.toString(); 165 } 207 /* Useful for debugging file operations */ 208 // private String readStringFromFile(File file) 209 // throws FileNotFoundException, IOException 210 // { 211 // BufferedReader reader = new BufferedReader(new FileReader(file)); 212 // String line = null; 213 // StringBuilder sb = new StringBuilder(); 214 215 // try 216 // { 217 // while ((line=reader.readLine()) != null) 218 // { 219 // sb.append(line); 220 // } 221 // } 222 // finally 223 // { 224 // reader.close(); 225 // } 226 227 // return sb.toString(); 228 // } 166 229 167 private PluginConfiguration configure(Properties properties) { 230 private PluginConfiguration configure(Properties properties) 231 { 168 232 final File file = properties.getFile(); 169 233 final String fileType = properties.getFileType().equals("(detect automatically)") ? FileUtil.guessFileType(file) : properties.getFileType(); … … 176 240 configuration.setCharsetEncoding(charsetEncoding); 177 241 configuration.setPreserveExistingMacrons(Boolean.getBoolean(preserveExistingMacrons)); 242 178 243 return configuration; 179 244 } 180 245 181 private class Properties {182 246 private class Properties 247 { 183 248 private File file; 184 249 private String filename; … … 209 274 } 210 275 276 @SuppressWarnings("unused") 211 277 public String getLanguage() { 212 278 return language; -
other-projects/the-macronizer/trunk/web/WEB-INF/web.xml
r29855 r35719 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 3 <!-- Listener Definitions --> 3 4 <listener> 4 5 <listener-class>web.listeners.MyHttpSessionListener</listener-class> 5 6 </listener> 7 6 8 <listener> 7 9 <listener-class>web.listeners.MyHttpSessionAttributeListener</listener-class> 8 10 </listener> 11 9 12 <listener> 10 13 <listener-class>web.listeners.MyServletContextListener</listener-class> 11 14 </listener> 15 16 <!-- Filter Definitions --> 17 <filter> 18 <filter-name>CorsFilter</filter-name> 19 <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> 20 <init-param> 21 <param-name>cors.allowed.origins</param-name> 22 <!-- Allowing access from localhost:8080 for the gs3 Atea interface dev server. --> 23 <param-value>http://localhost:8080</param-value> <!-- Separate values by a comma --> 24 </init-param> 25 </filter> 26 27 <!-- Servlet Definitions --> 28 12 29 <servlet> 13 30 <servlet-name>FileUpload</servlet-name> 14 31 <servlet-class>web.servlets.FileUpload</servlet-class> 15 32 </servlet> 33 16 34 <servlet> 17 35 <servlet-name>Download</servlet-name> 18 36 <servlet-class>web.servlets.Download</servlet-class> 19 37 </servlet> 38 20 39 <servlet> 21 40 <servlet-name>DirectInput</servlet-name> 22 41 <servlet-class>web.servlets.DirectInput</servlet-class> 23 42 </servlet> 43 24 44 <servlet> 25 45 <servlet-name>EmailServlet</servlet-name> 26 46 <servlet-class>web.servlets.Email</servlet-class> 27 47 </servlet> 48 49 <!-- Filter Mappings --> 50 51 <filter-mapping> 52 <filter-name>CorsFilter</filter-name> 53 <url-pattern>/*</url-pattern> 54 </filter-mapping> 55 56 <!-- Servlet Mappings --> 57 28 58 <servlet-mapping> 29 59 <servlet-name>Download</servlet-name> 30 60 <url-pattern>/jsp/servlet/Download</url-pattern> 31 61 </servlet-mapping> 62 32 63 <servlet-mapping> 33 64 <servlet-name>FileUpload</servlet-name> 34 65 <url-pattern>/jsp/servlet/FileUpload</url-pattern> 35 66 </servlet-mapping> 67 36 68 <servlet-mapping> 37 69 <servlet-name>DirectInput</servlet-name> 38 70 <url-pattern>/jsp/servlet/DirectInput</url-pattern> 39 71 </servlet-mapping> 72 40 73 <servlet-mapping> 41 74 <servlet-name>EmailServlet</servlet-name> 42 75 <url-pattern>/jsp/servlet/EmailServlet</url-pattern> 43 76 </servlet-mapping> 77 44 78 <session-config> 45 79 <session-timeout>1</session-timeout> 46 80 </session-config> 81 47 82 <welcome-file-list> 48 83 <welcome-file>index.jsp</welcome-file>
Note:
See TracChangeset
for help on using the changeset viewer.