Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/util/ImageGalleryBundler.java =================================================================== diff -u -r4b47f86b588e38c9e7e9f2760c75f775cb080831 -rbb58d96f6bfcb90f6c28751772590f9acbcfee7a --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/util/ImageGalleryBundler.java (.../ImageGalleryBundler.java) (revision 4b47f86b588e38c9e7e9f2760c75f775cb080831) +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/util/ImageGalleryBundler.java (.../ImageGalleryBundler.java) (revision bb58d96f6bfcb90f6c28751772590f9acbcfee7a) @@ -42,6 +42,8 @@ import org.lamsfoundation.lams.util.HttpUrlConnectionUtil; public class ImageGalleryBundler extends Bundler { + + private static final char URL_SEPARATOR = '/'; public ImageGalleryBundler() { } @@ -82,22 +84,22 @@ } this.createDirectories(directories); - String urlToConnectTo = getImagesUrlDir() + File.separator + "javascript" + File.separator + "jquery.rating.1.1.js"; + String urlToConnectTo = getImagesUrlDir() + "javascript" + URL_SEPARATOR + "jquery.rating.1.1.js"; String directoryToStoreFile = outputDirectory + File.separator + "javascript"; HttpUrlConnectionUtil.writeResponseToFile(urlToConnectTo, directoryToStoreFile, "jquery.rating.1.1.js", cookies); log.debug("Copying image from source: " + urlToConnectTo + "to desitnation: " + directoryToStoreFile); - urlToConnectTo = getImagesUrlDir() + File.separator + "javascript" + File.separator + "jquery-1.2.6.pack.js"; + urlToConnectTo = getImagesUrlDir() + "javascript" + URL_SEPARATOR + "jquery-1.2.6.pack.js"; directoryToStoreFile = outputDirectory + File.separator + "javascript"; HttpUrlConnectionUtil.writeResponseToFile(urlToConnectTo, directoryToStoreFile, "jquery-1.2.6.pack.js", cookies); log.debug("Copying image from source: " + urlToConnectTo + "to desitnation: " + directoryToStoreFile); - urlToConnectTo = getImagesUrlDir() + File.separator + "css" + File.separator + "jquery.rating.css"; + urlToConnectTo = getImagesUrlDir() + "css" + URL_SEPARATOR + "jquery.rating.css"; directoryToStoreFile = outputDirectory + File.separator + "css"; HttpUrlConnectionUtil.writeResponseToFile(urlToConnectTo, directoryToStoreFile, "jquery.rating.css", cookies); log.debug("Copying image from source: " + urlToConnectTo + "to desitnation: " + directoryToStoreFile); - urlToConnectTo = getImagesUrlDir() + File.separator + "images" + File.separator + "star.gif"; + urlToConnectTo = getImagesUrlDir() + "images" + URL_SEPARATOR + "star.gif"; directoryToStoreFile = outputDirectory + File.separator + "images"; HttpUrlConnectionUtil.writeResponseToFile(urlToConnectTo, directoryToStoreFile, "star.gif", cookies); log.debug("Copying image from source: " + urlToConnectTo + "to desitnation: " + directoryToStoreFile); @@ -110,8 +112,12 @@ log.error("Unable to get path to the LAMS ImageGallery URL from the configuration table. ImageGallery javascript files export failed"); return ""; } else { - imageGalleryUrlPath = imageGalleryUrlPath + File.separator + "tool" + File.separator - + ImageGalleryConstants.TOOL_SIGNATURE + File.separator + "includes"; + if (!imageGalleryUrlPath.endsWith("/")) { + imageGalleryUrlPath += "/"; + } + + imageGalleryUrlPath = imageGalleryUrlPath + "tool" + URL_SEPARATOR + + ImageGalleryConstants.TOOL_SIGNATURE + URL_SEPARATOR + "includes" + URL_SEPARATOR; return imageGalleryUrlPath; } } Index: lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/util/SpreadsheetBundler.java =================================================================== diff -u -re044a561b88b3eb68dc50846451a30d258108e0f -rbb58d96f6bfcb90f6c28751772590f9acbcfee7a --- lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/util/SpreadsheetBundler.java (.../SpreadsheetBundler.java) (revision e044a561b88b3eb68dc50846451a30d258108e0f) +++ lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/util/SpreadsheetBundler.java (.../SpreadsheetBundler.java) (revision bb58d96f6bfcb90f6c28751772590f9acbcfee7a) @@ -43,92 +43,103 @@ public class SpreadsheetBundler extends Bundler { - public SpreadsheetBundler() {} + private static final char URL_SEPARATOR = '/'; + + public SpreadsheetBundler() { + } + + /** + * This method bundles the files to the given output dir + * + * @param request + * the request for the export + * @param cookies + * cookies for the request + * @param outputDirectory + * the location where the files should be written + * @throws Exception + */ + public void bundle(HttpServletRequest request, Cookie[] cookies, String outputDirectory) throws Exception { + bundleViaHTTP(request, cookies, outputDirectory); + } + + /** + * See bundle + * + * @param request + * @param cookies + * @param outputDirectory + * @throws MalformedURLException + * @throws FileNotFoundException + * @throws IOException + */ + private void bundleViaHTTP(HttpServletRequest request, Cookie[] cookies, String outputDirectory) + throws MalformedURLException, FileNotFoundException, IOException { - /** - * This method bundles the files to the given output dir - * - * @param request the request for the export - * @param cookies cookies for the request - * @param outputDirectory the location where the files should be written - * @throws Exception - */ - public void bundle(HttpServletRequest request, Cookie[] cookies, String outputDirectory) throws Exception - { - bundleViaHTTP(request, cookies, outputDirectory); + String[] directoriesNames = { + "translations", + "tinymce" + File.separator + "langs", + "tinymce" + File.separator + "utils", + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "css", + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "images", + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "jscripts", + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "langs", + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "css", + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "images", + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "jscripts", + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "langs"}; + + List directories = new ArrayList(); + for (String directoryName : directoriesNames) { + directories.add(outputDirectory + File.separator + "simple_spreadsheet" + File.separator + directoryName); } - - /** - * See bundle - * - * @param request - * @param cookies - * @param outputDirectory - * @throws MalformedURLException - * @throws FileNotFoundException - * @throws IOException - */ - private void bundleViaHTTP(HttpServletRequest request, Cookie[] cookies, String outputDirectory) throws MalformedURLException, FileNotFoundException, IOException{ + this.createDirectories(directories); - String[] directoriesNames = { - "translations", - "tinymce" + File.separator + "langs", - "tinymce" + File.separator + "utils", - "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "css", - "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "images", - "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "jscripts", - "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "langs", - "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "css", - "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "images", - "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "jscripts", - "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "langs"}; - - List directories = new ArrayList(); - for (String directoryName : directoriesNames) { - directories.add(outputDirectory + File.separator + "simple_spreadsheet" + File.separator + directoryName); - } - this.createDirectories(directories); - - Map filesNames = new HashMap(); - filesNames.put("", new String [] {"changelog.txt", "editor.htm", "index_offline.html", "keycodes.html", "LICENSE.txt", "manual.html", "print.css", "print_noline.css", "spreadsheet.js", "spreadsheet_exported.html", "spreadsheet_offline.html", "styles.css", "styles_noline.css"}); - filesNames.put(File.separator + "translations", new String [] {"cz.js", "da.js", "de.js", "en.js", "enUK.js", "es.js", "fr.js", "hr.js", "hu.js", "it.js", "nl.js", "pl.js", "ptBR.js", "ru.js", "se.js", "sk.js", "tr.js"}); - filesNames.put(File.separator + "tinymce", new String [] {"blank.htm", "index.html", "license.txt", "test.html", "tiny_mce.js", "tiny_mce_popup.js"}); - filesNames.put(File.separator + "tinymce" + File.separator + "langs", new String [] {"en.js"}); - filesNames.put(File.separator + "tinymce" + File.separator + "utils", new String [] {"editable_selects.js", "form_utils.js", "mclayer.js", "mctabs.js", "validate.js"}); - filesNames.put(File.separator + "tinymce" + File.separator + "plugins" + File.separator + "paste", new String [] {"blank.htm", "editor_plugin.js", "pastetext.htm", "pasteword.htm"}); - filesNames.put(File.separator + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "css", new String [] {"blank.css", "pasteword.css"}); - filesNames.put(File.separator + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "images", new String [] {"pastetext.gif", "pasteword.gif", "selectall.gif"}); - filesNames.put(File.separator + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "jscripts", new String [] {"pastetext.js", "pasteword.js"}); - filesNames.put(File.separator + "tinymce" + File.separator + "plugins" + File.separator + "paste" + File.separator + "langs", new String [] {"en.js"}); - filesNames.put(File.separator + "tinymce" + File.separator + "themes" + File.separator + "advanced", new String [] {"about.htm", "anchor.htm", "charmap.htm", "color_picker.htm", "editor_template.js", "image.htm", "link.htm", "source_editor.htm"}); - filesNames.put(File.separator + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "css", new String [] {"editor_content.css", "editor_popup.css", "editor_ui.css"}); - filesNames.put(File.separator + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "images", new String [] {"anchor.gif", "anchor_symbol.gif", "backcolor.gif", "bold.gif", "bold_de_se.gif", "bold_es.gif", "bold_fr.gif", "bold_ru.gif", "bold_tw.gif", "browse.gif", "bullist.gif", "button_menu.gif", "buttons.gif", "cancel_button_bg.gif", "charmap.gif", "cleanup.gif", "close.gif", "code.gif", "color.gif", "copy.gif", "custom_1.gif", "cut.gif", "forecolor.gif", "help.gif", "hr.gif", "image.gif", "indent.gif", "insert_button_bg.gif", "italic.gif", "italic_de_se.gif", "italic_es.gif", "italic_ru.gif", "italic_tw.gif", "justifycenter.gif", "justifyfull.gif", "justifyleft.gif", "justifyright.gif", "link.gif", "menu_check.gif", "newdocument.gif", "numlist.gif", "opacity.png", "outdent.gif", "paste.gif", "redo.gif", "removeformat.gif", "separator.gif", "spacer.gif", "statusbar_resize.gif", "strikethrough.gif", "sub.gif", "sup.gif", "underline.gif", "underline_es.gif", "underline_fr.gif", "underline_ru.gif", "underline_tw.gif", "undo.gif", "unlink.gif", "visualaid.gif"}); - filesNames.put(File.separator + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "jscripts", new String [] {"about.js", "anchor.js", "charmap.js", "color_picker.js", "image.js", "link.js", "source_editor.js"}); - filesNames.put(File.separator + "tinymce" + File.separator + "themes" + File.separator + "advanced" + File.separator + "langs", new String [] {"en.js"}); - - for (String filePath: filesNames.keySet()) { - for(String fileName : filesNames.get(filePath)) { - - String urlToConnectTo = getImagesUrlDir() + filePath + File.separator + fileName; - String directoryToStoreFile = outputDirectory + File.separator + "simple_spreadsheet" + filePath; - HttpUrlConnectionUtil.writeResponseToFile(urlToConnectTo, directoryToStoreFile, fileName , cookies); //cookies aren't really needed here. - - log.debug("Copying image from source: " + urlToConnectTo + "to desitnation: " + directoryToStoreFile); - } - } + Map filesNames = new HashMap(); + filesNames.put("", new String [] {"changelog.txt", "editor.htm", "index_offline.html", "keycodes.html", "LICENSE.txt", "manual.html", "print.css", "print_noline.css", "spreadsheet.js", "spreadsheet_exported.html", "spreadsheet_offline.html", "styles.css", "styles_noline.css"}); + filesNames.put(URL_SEPARATOR + "translations", new String [] {"cz.js", "da.js", "de.js", "en.js", "enUK.js", "es.js", "fr.js", "hr.js", "hu.js", "it.js", "nl.js", "pl.js", "ptBR.js", "ru.js", "se.js", "sk.js", "tr.js"}); + filesNames.put(URL_SEPARATOR + "tinymce", new String [] {"blank.htm", "index.html", "license.txt", "test.html", "tiny_mce.js", "tiny_mce_popup.js"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "langs", new String [] {"en.js"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "utils", new String [] {"editable_selects.js", "form_utils.js", "mclayer.js", "mctabs.js", "validate.js"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "plugins" + URL_SEPARATOR + "paste", new String [] {"blank.htm", "editor_plugin.js", "pastetext.htm", "pasteword.htm"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "plugins" + URL_SEPARATOR + "paste" + URL_SEPARATOR + "css", new String [] {"blank.css", "pasteword.css"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "plugins" + URL_SEPARATOR + "paste" + URL_SEPARATOR + "images", new String [] {"pastetext.gif", "pasteword.gif", "selectall.gif"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "plugins" + URL_SEPARATOR + "paste" + URL_SEPARATOR + "jscripts", new String [] {"pastetext.js", "pasteword.js"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "plugins" + URL_SEPARATOR + "paste" + URL_SEPARATOR + "langs", new String [] {"en.js"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "themes" + URL_SEPARATOR + "advanced", new String [] {"about.htm", "anchor.htm", "charmap.htm", "color_picker.htm", "editor_template.js", "image.htm", "link.htm", "source_editor.htm"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "themes" + URL_SEPARATOR + "advanced" + URL_SEPARATOR + "css", new String [] {"editor_content.css", "editor_popup.css", "editor_ui.css"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "themes" + URL_SEPARATOR + "advanced" + URL_SEPARATOR + "images", new String [] {"anchor.gif", "anchor_symbol.gif", "backcolor.gif", "bold.gif", "bold_de_se.gif", "bold_es.gif", "bold_fr.gif", "bold_ru.gif", "bold_tw.gif", "browse.gif", "bullist.gif", "button_menu.gif", "buttons.gif", "cancel_button_bg.gif", "charmap.gif", "cleanup.gif", "close.gif", "code.gif", "color.gif", "copy.gif", "custom_1.gif", "cut.gif", "forecolor.gif", "help.gif", "hr.gif", "image.gif", "indent.gif", "insert_button_bg.gif", "italic.gif", "italic_de_se.gif", "italic_es.gif", "italic_ru.gif", "italic_tw.gif", "justifycenter.gif", "justifyfull.gif", "justifyleft.gif", "justifyright.gif", "link.gif", "menu_check.gif", "newdocument.gif", "numlist.gif", "opacity.png", "outdent.gif", "paste.gif", "redo.gif", "removeformat.gif", "separator.gif", "spacer.gif", "statusbar_resize.gif", "strikethrough.gif", "sub.gif", "sup.gif", "underline.gif", "underline_es.gif", "underline_fr.gif", "underline_ru.gif", "underline_tw.gif", "undo.gif", "unlink.gif", "visualaid.gif"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "themes" + URL_SEPARATOR + "advanced" + URL_SEPARATOR + "jscripts", new String [] {"about.js", "anchor.js", "charmap.js", "color_picker.js", "image.js", "link.js", "source_editor.js"}); + filesNames.put(URL_SEPARATOR + "tinymce" + URL_SEPARATOR + "themes" + URL_SEPARATOR + "advanced" + URL_SEPARATOR + "langs", new String [] {"en.js"}); + for (String filePath : filesNames.keySet()) { + for (String fileName : filesNames.get(filePath)) { + + String urlToConnectTo = getImagesUrlDir() + filePath + URL_SEPARATOR + fileName; + String directoryToStoreFile = outputDirectory + File.separator + "simple_spreadsheet" + filePath; + HttpUrlConnectionUtil.writeResponseToFile(urlToConnectTo, directoryToStoreFile, fileName, cookies); // cookies aren't really needed here. + + log.debug("Copying image from source: " + urlToConnectTo + "to desitnation: " + directoryToStoreFile); + } } + + } - private String getImagesUrlDir() { - String spreadsheetUrlPath = Configuration.get(ConfigurationKeys.SERVER_URL); - if (spreadsheetUrlPath == null) { - log.error("Unable to get path to the LAMS Spreadsheet URL from the configuration table. Spreadsheet javascript files export failed"); - return ""; - } else { - spreadsheetUrlPath = spreadsheetUrlPath + File.separator + "tool" + File.separator + SpreadsheetConstants.TOOL_SIGNATURE + File.separator + "includes" + File.separator + "javascript" + File.separator + "simple_spreadsheet"; - return spreadsheetUrlPath; - } + private String getImagesUrlDir() { + String spreadsheetUrlPath = Configuration.get(ConfigurationKeys.SERVER_URL); + if (spreadsheetUrlPath == null) { + log.error("Unable to get path to the LAMS Spreadsheet URL from the configuration table. Spreadsheet javascript files export failed"); + return ""; + } else { + if (!spreadsheetUrlPath.endsWith("/")) { + spreadsheetUrlPath += "/"; + } + + spreadsheetUrlPath = spreadsheetUrlPath + "tool" + URL_SEPARATOR + SpreadsheetConstants.TOOL_SIGNATURE + + URL_SEPARATOR + "includes" + URL_SEPARATOR + "javascript" + URL_SEPARATOR + "simple_spreadsheet"; + return spreadsheetUrlPath; } + } } \ No newline at end of file