List of usage examples for java.io File toURL
@Deprecated public URL toURL() throws MalformedURLException
file:
URL. From source file:com.headwire.aem.tooling.intellij.communication.ServerConnectionManager.java
public void publishBundle(@NotNull final DataContext dataContext, final @NotNull Module module) { messageManager.sendInfoNotification("deploy.module.prepare", module); InputStream contents = null;/*from w w w. java2s .c o m*/ // Check if this is a OSGi Bundle final UnifiedModule unifiedModule = module.getUnifiedModule(); if (unifiedModule.isOSGiBundle()) { try { updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.updating); boolean localBuildDoneSuccessfully = true; //AS TODO: This should be isBuildLocally instead as we can now build both with Maven or Locally if Facet is specified if (module.getParent().isBuildWithMaven() && module.getUnifiedModule().isMavenBased()) { localBuildDoneSuccessfully = false; List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(dataContext); if (goals == null) { goals = new ArrayList<String>(); } if (goals.isEmpty()) { // goals.add("package"); // If a module depends on anoher Maven module then we need to have it installed into the local repo goals.add("install"); } messageManager.sendInfoNotification("deploy.module.maven.goals", goals); final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(dataContext); if (projectsManager == null) { messageManager.showAlert("Maven Failure", "Could not find Maven Project Manager, need to build manually"); } else { final ToolWindow tw = ToolWindowManager.getInstance(module.getProject()) .getToolWindow(ToolWindowId.RUN); final boolean isShown = tw != null && tw.isVisible(); String workingDirectory = unifiedModule.getModuleDirectory(); MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles(); final MavenRunnerParameters params = new MavenRunnerParameters(true, workingDirectory, goals, explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles()); // This Monitor is used to know when the Maven build is done RunExecutionMonitor rem = RunExecutionMonitor.getInstance(myProject); // We need to tell the Monitor that we are going to start a Maven Build so that the Countdown Latch // is ready rem.startMavenBuild(); try { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { try { MavenRunConfigurationType.runConfiguration(module.getProject(), params, null); } catch (RuntimeException e) { // Ignore it String message = e.getMessage(); } if (isShown) { tw.hide(null); } } }, ModalityState.NON_MODAL); } catch (IllegalStateException e) { if (firstRun) { firstRun = false; messageManager.showAlert("deploy.module.maven.first.run.failure"); } } catch (RuntimeException e) { messageManager.sendDebugNotification("debug.maven.build.failed.unexpected", e); } // Now we can wait for the process to end switch (RunExecutionMonitor.getInstance(myProject).waitFor()) { case done: messageManager.sendInfoNotification("deploy.module.maven.done"); localBuildDoneSuccessfully = true; break; case timedOut: messageManager.sendInfoNotification("deploy.module.maven.timedout"); messageManager.showAlert("deploy.module.maven.timedout"); break; case interrupted: messageManager.sendInfoNotification("deploy.module.maven.interrupted"); messageManager.showAlert("deploy.module.maven.interrupted"); break; } } } else if (!module.getUnifiedModule().isMavenBased()) { // Compile the IntelliJ way final CompilerManager compilerManager = CompilerManager.getInstance(myProject); final CompileScope moduleScope = compilerManager .createModuleCompileScope(module.getUnifiedModule().getModule(), true); WaitableRunner<AtomicBoolean> runner = new WaitableRunner<AtomicBoolean>( new AtomicBoolean(false)) { @Override public void run() { compilerManager.make(moduleScope, new CompileStatusNotification() { public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { getResponse().set(!aborted && errors == 0); } }); } }; runAndWait(runner); // final CountDownLatch waiter = new CountDownLatch(1); // final AtomicBoolean checker = new AtomicBoolean(false); // ApplicationManager.getApplication().invokeLater( // new Runnable() { // public void run() { // } // } // ); // try { // waiter.await(); // } catch(InterruptedException e) { // //AS TODO: Show Info Notification and Alert // } localBuildDoneSuccessfully = runner.getResponse().get(); } if (localBuildDoneSuccessfully) { File buildDirectory = new File(module.getUnifiedModule().getBuildDirectoryPath()); if (buildDirectory.exists() && buildDirectory.isDirectory()) { File buildFile = new File(buildDirectory, module.getUnifiedModule().getBuildFileName()); messageManager.sendDebugNotification("debug.build.file.name", buildFile.toURL()); if (buildFile.exists()) { //AS TODO: This looks like OSGi Symbolic Name to be used here EmbeddedArtifact bundle = new EmbeddedArtifact(module.getSymbolicName(), module.getVersion(), buildFile.toURL()); contents = bundle.openInputStream(); obtainSGiClient().installBundle(contents, bundle.getName()); module.setStatus(ServerConfiguration.SynchronizationStatus.upToDate); } else { messageManager.showAlertWithArguments("deploy.module.maven.missing.build.file", buildFile.getAbsolutePath()); } } updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.upToDate); messageManager.sendInfoNotification("deploy.module.success", module); } } catch (MalformedURLException e) { module.setStatus(ServerConfiguration.SynchronizationStatus.failed); messageManager.sendErrorNotification("deploy.module.failed.bad.url", e); updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.failed); } catch (OsgiClientException e) { module.setStatus(ServerConfiguration.SynchronizationStatus.failed); messageManager.sendErrorNotification("deploy.module.failed.client", e); updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.failed); } catch (IOException e) { module.setStatus(ServerConfiguration.SynchronizationStatus.failed); messageManager.sendErrorNotification("deploy.module.failed.io", e); updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.failed); } finally { IOUtils.closeQuietly(contents); } } else { messageManager.sendNotification("deploy.module.unsupported.maven.packaging", NotificationType.WARNING); } }
From source file:dip.world.variant.VariantManager.java
/** * Searches the given paths for files ending with the given extension(s). * Returns URLs.//w w w . ja v a2 s .co m * */ private List<URL> searchForFiles(final List<File> searchPaths, final List<String> extensions) { final List<URL> urlList = new ArrayList<URL>(); for (final File searchPath : searchPaths) { final Collection<File> list = FileUtils.listFiles(searchPath, null, false); // internal error if list == null; means that // searchPaths[] is not a directory! if (list != null) { for (final File file : list) { String fileName = file.getPath(); if (checkFileName(fileName, extensions)) { try { urlList.add(file.toURL()); } catch (java.net.MalformedURLException e) { // do nothing; we just won't add it } } } } } return urlList; }
From source file:org.wso2.carbon.bridge.EquinoxFrameworkLauncher.java
/** * buildInitialPropertyMap create the initial set of properties from the contents of launch.ini * and for a few other properties necessary to launch defaults are supplied if not provided. * The value '@null' will set the map value to null. * * @return a map containing the initial properties */// w ww .j a v a 2s .com private Map<String, String> buildInitialPropertyMap() { Map<String, String> initialPropertyMap = new HashMap<String, String>(); Properties launchProperties = loadProperties(RESOURCE_BASE + LAUNCH_INI); for (Object o : launchProperties.entrySet()) { Map.Entry entry = (Map.Entry) o; String key = (String) entry.getKey(); String value = (String) entry.getValue(); if (key.endsWith("*")) { //$NON-NLS-1$ if (value.equals(NULL_IDENTIFIER)) { clearPrefixedSystemProperties(key.substring(0, key.length() - 1), initialPropertyMap); } } else if (value.equals(NULL_IDENTIFIER)) { initialPropertyMap.put(key, null); } else { initialPropertyMap.put((String) entry.getKey(), (String) entry.getValue()); } } try { // install.area if not specified if (initialPropertyMap.get(OSGI_INSTALL_AREA) == null) { initialPropertyMap.put(OSGI_INSTALL_AREA, platformDirectory.toURL().toExternalForm()); } // configuration.area if not specified if (initialPropertyMap.get(OSGI_CONFIGURATION_AREA) == null) { File configurationDirectory = new File(platformDirectory, "configuration"); if (!configurationDirectory.exists() && !configurationDirectory.mkdirs()) { context.log("Fail to create the directory: " + configurationDirectory.getAbsolutePath()); } initialPropertyMap.put(OSGI_CONFIGURATION_AREA, configurationDirectory.toURL().toExternalForm()); } // instance.area if not specified if (initialPropertyMap.get(OSGI_INSTANCE_AREA) == null) { File workspaceDirectory = new File(platformDirectory, "workspace"); if (!workspaceDirectory.exists() && !workspaceDirectory.mkdirs()) { context.log("Failed to create the directory: " + workspaceDirectory.getAbsoluteFile()); } initialPropertyMap.put(OSGI_INSTANCE_AREA, workspaceDirectory.toURL().toExternalForm()); } // osgi.framework if not specified if (initialPropertyMap.get(OSGI_FRAMEWORK) == null) { // search for osgi.framework in osgi.install.area String installArea = initialPropertyMap.get(OSGI_INSTALL_AREA); // only support file type URLs for install area if (installArea.startsWith(FILE_SCHEME)) { installArea = installArea.substring(FILE_SCHEME.length()); } String path = new File(installArea, "plugins").toString(); path = searchFor(FRAMEWORK_BUNDLE_NAME, path); if (path == null) { throw new RuntimeException("Could not find framework"); } initialPropertyMap.put(OSGI_FRAMEWORK, new File(path).toURL().toExternalForm()); } } catch (MalformedURLException e) { throw new RuntimeException("Error establishing location"); } return initialPropertyMap; }
From source file:org.ecoinformatics.seek.R.RExpression2.java
private void _showGraphics() throws IllegalActionException { boolean displayGraphicsOutputValue = ((BooleanToken) displayGraphicsOutput.getToken()).booleanValue(); if (displayGraphicsOutputValue) { try {// w ww.j a v a2 s .c om File fout = new File(graphicsOutputFile); URL furl = fout.toURL(); BrowserLauncher.openURL(furl.toString()); } catch (Exception e) { log.error("Oops!:" + e); } } }
From source file:com.adito.core.CoreServlet.java
protected void initCore() throws ServletException { // // Process each specified resource path // while (paths.length() > 0) { // digester.push(moduleConfig); // String path = null; // int comma = paths.indexOf(','); // if (comma >= 0) { // path = paths.substring(0, comma).trim(); // paths = paths.substring(comma + 1); // } else {// www . jav a2 s . c o m // path = paths.trim(); // paths = ""; // } // // if (path.length() < 1) { // break; // } // // this.parseModuleConfigFile(digester, path); // } // Add the additional default struts configs digester.push(moduleConfig); this.parseModuleConfigFile(digester, "/WEB-INF/wizard-struts-config.xml"); digester.push(moduleConfig); this.parseModuleConfigFile(digester, "/WEB-INF/ajax-struts-config.xml"); /** * Install Maverick SSL support */ if (!("false".equals(SystemProperties.get("adito.useMaverickSSL", "true")))) { try { if (log.isInfoEnabled()) log.info("Installing Maverick SSL"); com.maverick.ssl.https.HttpsURLStreamHandlerFactory.addHTTPSSupport(); } catch (IOException ex1) { throw new ServletException("Failed to install Maverick SSL support"); } boolean strictHostVerification = false; System.setProperty("com.maverick.ssl.allowUntrustedCertificates", String.valueOf(!strictHostVerification)); System.setProperty("com.maverick.ssl.allowInvalidCertificates", String.valueOf(!strictHostVerification)); } if (log.isInfoEnabled()) log.info("Adding default authentication modules."); // Add the default authentication modules AuthenticationModuleManager.getInstance().registerModule("Password", PasswordAuthenticationModule.class, "properties", true, true, false); AuthenticationModuleManager.getInstance().registerModule("HTTP", HTTPAuthenticationModule.class, "properties", true, true, false); AuthenticationModuleManager.getInstance().registerModule("PersonalQuestions", PersonalQuestionsAuthenticationModule.class, "properties", false, true, false); AuthenticationModuleManager.getInstance().registerModule("WebDAV", WebDAVAuthenticationModule.class, "properties", true, false, true); AuthenticationModuleManager.getInstance().registerModule("EmbeddedClient", EmbeddedClientAuthenticationModule.class, "properties", true, false, true); // Add the default page scripts addPageScript(new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/cookieDetect.jsp", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/prototype.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/extensions.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/scriptaculous.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/overlibmws.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/ajaxtags.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/cookies.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/table.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/datetimepicker.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/modalbox.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/set.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/resources.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/items.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/input.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/windowManager.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.BEFORE_BODY_END, "JavaScript", "/js/wz_tooltip.js", null, "text/javascript")); // Add the default panels PanelManager.getInstance().addPanel( new DefaultPanel("menu", Panel.SIDEBAR, 50, null, "menu", "navigation", false, true, false, false)); PanelManager.getInstance().addPanel(new DefaultPanel("editingResourceInfo", Panel.SIDEBAR, 100, "/WEB-INF/jsp/tiles/editingResourceInfo.jspf", null, "navigation", false, true, false, false) { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return super.isAvailable(request, response, layout) && !ResourceStack.isEmpty(request.getSession()) && request.getSession().getAttribute(Constants.WIZARD_SEQUENCE) == null; } }); PanelManager.getInstance().addPanel(new DefaultPanel("wizardSequenceInfo", Panel.SIDEBAR, 100, "/WEB-INF/jsp/tiles/wizardSequenceInfo.jspf", null, "navigation", false, true, false, false) { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return super.isAvailable(request, response, layout) && ResourceStack.isEmpty(request.getSession()) && request.getSession().getAttribute(Constants.WIZARD_SEQUENCE) != null; } }); // PanelManager.getInstance().addPanel(new DefaultPanel("about", // Panel.SIDEBAR, // 1000, // "/WEB-INF/jsp/tiles/about.jspf", // null, // "navigation", // false, // false, // false, // false) { // // public boolean isAvailable(HttpServletRequest request, // HttpServletResponse response, String layout) { // return LogonControllerFactory.getInstance().getSessionInfo(request) // != null && layout.equals(MAIN_LAYOUT) && // !ContextHolder.getContext().isSetupMode() // && super.isAvailable(request, response, layout); // } // // }); PanelManager.getInstance().addPanel(new DefaultPanel("pageInfo", Panel.CONTENT, 25, "/WEB-INF/jsp/tiles/pageInfo.jspf", null, "navigation") { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return (LogonControllerFactory.getInstance().getSessionInfo(request) != null || ContextHolder.getContext().isSetupMode()) && request.getSession().getAttribute(Constants.SESSION_LOCKED) == null; } }); PanelManager.getInstance() .addPanel(new DefaultPanel("content", Panel.CONTENT, 50, null, "content", "navigation", false)); PanelManager.getInstance().addPanel(new DefaultPanel("panelOptions", Panel.MESSAGES, 10, "/WEB-INF/jsp/tiles/panelOptions.jspf", null, "navigation", true, true, true, true) { public String getDefaultFrameState() { return FRAME_CLOSED; } }); PanelManager.getInstance().addPanel(new DefaultPanel("pageTasks", Panel.MESSAGES, 50, "/WEB-INF/jsp/tiles/pageTasks.jspf", "pageTasks", "navigation", false, false, true, true)); PanelManager.getInstance().addPanel(new DefaultPanel("toolBar", Panel.CONTENT, 35, "/WEB-INF/jsp/tiles/toolBar.jspf", null, "navigation") { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return (LogonControllerFactory.getInstance().getSessionInfo(request) != null || ContextHolder.getContext().isSetupMode()) && request.getSession().getAttribute(Constants.TOOL_BAR_ITEMS) != null; } }); PanelManager.getInstance().addPanel(new DefaultPanel("errorMessages", Panel.MESSAGES, 60, "/WEB-INF/jsp/tiles/errorMessages.jspf", null, "navigation", true, false, true, true)); PanelManager.getInstance().addPanel(new DefaultPanel("warnings", Panel.MESSAGES, 70, "/WEB-INF/jsp/tiles/warnings.jspf", null, "navigation", true, true, true, true)); PanelManager.getInstance().addPanel(new DefaultPanel("infoMessages", Panel.MESSAGES, 80, "/WEB-INF/jsp/tiles/infoMessages.jspf", null, "navigation", true, true, true, true)); PanelManager.getInstance().addPanel(new ClipboardPanel()); PanelManager.getInstance().addPanel(new DefaultPanel("rssFeeds", Panel.MESSAGES, 120, "/WEB-INF/jsp/tiles/rssFeeds.jspf", null, "navigation", true, true, true, true) { }); PanelManager.getInstance().addPanel(new DefaultPanel("userSessions", Panel.STATUS_TAB, 10, "/WEB-INF/jsp/content/setup/userSessions.jspf", null, "setup", false)); PanelManager.getInstance().addPanel(new DefaultPanel("systemInfo", Panel.STATUS_TAB, 20, "/WEB-INF/jsp/content/setup/systemInfo.jspf", null, "setup", false)); // Add the default key store import types KeyStoreImportTypeManager.getInstance().registerType(new _3SPPurchaseImportType()); KeyStoreImportTypeManager.getInstance().registerType(new RootServerCertificateImportType()); KeyStoreImportTypeManager.getInstance().registerType(new ReplyFromCAImportType()); KeyStoreImportTypeManager.getInstance().registerType(new ServerAuthenticationKeyImportType()); KeyStoreImportTypeManager.getInstance().registerType(new TrustedServerCertificateImportType()); // Add the default user databases UserDatabaseManager.getInstance() .registerDatabase(new UserDatabaseDefinition(JDBCUserDatabase.class, "builtIn", "properties", -1)); /* * Add the 'site' VFS directory as a resource base. This must be done * because we need access to the resources without authentication */ File siteDir = new File(ContextHolder.getContext().getConfDirectory(), "site"); try { if (!siteDir.exists()) { siteDir.mkdirs(); } ContextHolder.getContext().addResourceBase(siteDir.toURL()); } catch (Exception e) { log.error("Failed to add " + siteDir.getPath() + " as a resource base. Site specific resources such as icons may not work."); } // Add the extension store panels. // categories are Installed, Updateable, Beta, Remote Access, // AccessControl, Resources, UserInterface, Misc, Articles PanelManager.getInstance() .addPanel(new DefaultPanel("installed", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 10, "/WEB-INF/jsp/content/extensions/installedExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("updateable", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 20, "/WEB-INF/jsp/content/extensions/updateableExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance().addPanel(new DefaultPanel("beta", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 30, "/WEB-INF/jsp/content/extensions/betaExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("remoteAccess", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 40, "/WEB-INF/jsp/content/extensions/remoteAccessExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("accessControl", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 50, "/WEB-INF/jsp/content/extensions/accessControlExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("resources", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 60, "/WEB-INF/jsp/content/extensions/resourcesExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("userInterface", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 70, "/WEB-INF/jsp/content/extensions/userInterfaceExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance().addPanel(new DefaultPanel("misc", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 80, "/WEB-INF/jsp/content/extensions/miscExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("articles", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 90, "/WEB-INF/jsp/content/extensions/articlesExtensionStoreContent.jspf", null, "extensions", false)); }
From source file:com.sslexplorer.core.CoreServlet.java
protected void initCore() throws ServletException { // // Process each specified resource path // while (paths.length() > 0) { // digester.push(moduleConfig); // String path = null; // int comma = paths.indexOf(','); // if (comma >= 0) { // path = paths.substring(0, comma).trim(); // paths = paths.substring(comma + 1); // } else {/* w w w . j av a2 s .c om*/ // path = paths.trim(); // paths = ""; // } // // if (path.length() < 1) { // break; // } // // this.parseModuleConfigFile(digester, path); // } // Add the additional default struts configs digester.push(moduleConfig); this.parseModuleConfigFile(digester, "/WEB-INF/wizard-struts-config.xml"); digester.push(moduleConfig); this.parseModuleConfigFile(digester, "/WEB-INF/ajax-struts-config.xml"); /** * Install Maverick SSL support */ if (!("false".equals(SystemProperties.get("sslexplorer.useMaverickSSL", "true")))) { try { if (log.isInfoEnabled()) log.info("Installing Maverick SSL"); com.maverick.ssl.https.HttpsURLStreamHandlerFactory.addHTTPSSupport(); } catch (IOException ex1) { throw new ServletException("Failed to install Maverick SSL support"); } boolean strictHostVerification = false; System.setProperty("com.maverick.ssl.allowUntrustedCertificates", String.valueOf(!strictHostVerification)); System.setProperty("com.maverick.ssl.allowInvalidCertificates", String.valueOf(!strictHostVerification)); } if (log.isInfoEnabled()) log.info("Adding default authentication modules."); // Add the default authentication modules AuthenticationModuleManager.getInstance().registerModule("Password", PasswordAuthenticationModule.class, "properties", true, true, false); AuthenticationModuleManager.getInstance().registerModule("HTTP", HTTPAuthenticationModule.class, "properties", true, true, false); AuthenticationModuleManager.getInstance().registerModule("PersonalQuestions", PersonalQuestionsAuthenticationModule.class, "properties", false, true, false); AuthenticationModuleManager.getInstance().registerModule("WebDAV", WebDAVAuthenticationModule.class, "properties", true, false, true); AuthenticationModuleManager.getInstance().registerModule("EmbeddedClient", EmbeddedClientAuthenticationModule.class, "properties", true, false, true); // Add the default page scripts addPageScript(new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/cookieDetect.jsp", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/prototype.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/extensions.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/scriptaculous.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/overlibmws.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/ajaxtags.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/cookies.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/table.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/datetimepicker.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.PAGE_HEADER, "JavaScript", "/js/modalbox.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/set.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/resources.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/items.js", null, "text/javascript")); addPageScript( new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/input.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.AFTER_BODY_START, "JavaScript", "/js/windowManager.js", null, "text/javascript")); addPageScript(new CoreScript(CoreScript.BEFORE_BODY_END, "JavaScript", "/js/wz_tooltip.js", null, "text/javascript")); // Add the default panels PanelManager.getInstance().addPanel( new DefaultPanel("menu", Panel.SIDEBAR, 50, null, "menu", "navigation", false, true, false, false)); PanelManager.getInstance().addPanel(new DefaultPanel("editingResourceInfo", Panel.SIDEBAR, 100, "/WEB-INF/jsp/tiles/editingResourceInfo.jspf", null, "navigation", false, true, false, false) { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return super.isAvailable(request, response, layout) && !ResourceStack.isEmpty(request.getSession()) && request.getSession().getAttribute(Constants.WIZARD_SEQUENCE) == null; } }); PanelManager.getInstance().addPanel(new DefaultPanel("wizardSequenceInfo", Panel.SIDEBAR, 100, "/WEB-INF/jsp/tiles/wizardSequenceInfo.jspf", null, "navigation", false, true, false, false) { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return super.isAvailable(request, response, layout) && ResourceStack.isEmpty(request.getSession()) && request.getSession().getAttribute(Constants.WIZARD_SEQUENCE) != null; } }); // PanelManager.getInstance().addPanel(new DefaultPanel("about", // Panel.SIDEBAR, // 1000, // "/WEB-INF/jsp/tiles/about.jspf", // null, // "navigation", // false, // false, // false, // false) { // // public boolean isAvailable(HttpServletRequest request, // HttpServletResponse response, String layout) { // return LogonControllerFactory.getInstance().getSessionInfo(request) // != null && layout.equals(MAIN_LAYOUT) && // !ContextHolder.getContext().isSetupMode() // && super.isAvailable(request, response, layout); // } // // }); PanelManager.getInstance().addPanel(new DefaultPanel("pageInfo", Panel.CONTENT, 25, "/WEB-INF/jsp/tiles/pageInfo.jspf", null, "navigation") { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return (LogonControllerFactory.getInstance().getSessionInfo(request) != null || ContextHolder.getContext().isSetupMode()) && request.getSession().getAttribute(Constants.SESSION_LOCKED) == null; } }); PanelManager.getInstance() .addPanel(new DefaultPanel("content", Panel.CONTENT, 50, null, "content", "navigation", false)); PanelManager.getInstance().addPanel(new DefaultPanel("panelOptions", Panel.MESSAGES, 10, "/WEB-INF/jsp/tiles/panelOptions.jspf", null, "navigation", true, true, true, true) { public String getDefaultFrameState() { return FRAME_CLOSED; } }); PanelManager.getInstance().addPanel(new DefaultPanel("pageTasks", Panel.MESSAGES, 50, "/WEB-INF/jsp/tiles/pageTasks.jspf", "pageTasks", "navigation", false, false, true, true)); PanelManager.getInstance().addPanel(new DefaultPanel("toolBar", Panel.CONTENT, 35, "/WEB-INF/jsp/tiles/toolBar.jspf", null, "navigation") { public boolean isAvailable(HttpServletRequest request, HttpServletResponse response, String layout) { return (LogonControllerFactory.getInstance().getSessionInfo(request) != null || ContextHolder.getContext().isSetupMode()) && request.getSession().getAttribute(Constants.TOOL_BAR_ITEMS) != null; } }); PanelManager.getInstance().addPanel(new DefaultPanel("errorMessages", Panel.MESSAGES, 60, "/WEB-INF/jsp/tiles/errorMessages.jspf", null, "navigation", true, false, true, true)); PanelManager.getInstance().addPanel(new DefaultPanel("warnings", Panel.MESSAGES, 70, "/WEB-INF/jsp/tiles/warnings.jspf", null, "navigation", true, true, true, true)); PanelManager.getInstance().addPanel(new DefaultPanel("infoMessages", Panel.MESSAGES, 80, "/WEB-INF/jsp/tiles/infoMessages.jspf", null, "navigation", true, true, true, true)); PanelManager.getInstance().addPanel(new ClipboardPanel()); PanelManager.getInstance().addPanel(new DefaultPanel("rssFeeds", Panel.MESSAGES, 120, "/WEB-INF/jsp/tiles/rssFeeds.jspf", null, "navigation", true, true, true, true) { }); PanelManager.getInstance().addPanel(new DefaultPanel("userSessions", Panel.STATUS_TAB, 10, "/WEB-INF/jsp/content/setup/userSessions.jspf", null, "setup", false)); PanelManager.getInstance().addPanel(new DefaultPanel("systemInfo", Panel.STATUS_TAB, 20, "/WEB-INF/jsp/content/setup/systemInfo.jspf", null, "setup", false)); // Add the default key store import types KeyStoreImportTypeManager.getInstance().registerType(new _3SPPurchaseImportType()); KeyStoreImportTypeManager.getInstance().registerType(new RootServerCertificateImportType()); KeyStoreImportTypeManager.getInstance().registerType(new ReplyFromCAImportType()); KeyStoreImportTypeManager.getInstance().registerType(new ServerAuthenticationKeyImportType()); KeyStoreImportTypeManager.getInstance().registerType(new TrustedServerCertificateImportType()); // Add the default user databases UserDatabaseManager.getInstance() .registerDatabase(new UserDatabaseDefinition(JDBCUserDatabase.class, "builtIn", "properties", -1)); /* * Add the 'site' VFS directory as a resource base. This must be done * because we need access to the resources without authentication */ File siteDir = new File(ContextHolder.getContext().getConfDirectory(), "site"); try { if (!siteDir.exists()) { siteDir.mkdirs(); } ContextHolder.getContext().addResourceBase(siteDir.toURL()); } catch (Exception e) { log.error("Failed to add " + siteDir.getPath() + " as a resource base. Site specific resources such as icons may not work."); } // Add the extension store panels. // categories are Installed, Updateable, Beta, Remote Access, // AccessControl, Resources, UserInterface, Misc, Articles PanelManager.getInstance() .addPanel(new DefaultPanel("installed", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 10, "/WEB-INF/jsp/content/extensions/installedExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("updateable", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 20, "/WEB-INF/jsp/content/extensions/updateableExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance().addPanel(new DefaultPanel("beta", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 30, "/WEB-INF/jsp/content/extensions/betaExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("remoteAccess", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 40, "/WEB-INF/jsp/content/extensions/remoteAccessExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("accessControl", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 50, "/WEB-INF/jsp/content/extensions/accessControlExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("resources", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 60, "/WEB-INF/jsp/content/extensions/resourcesExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("userInterface", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 70, "/WEB-INF/jsp/content/extensions/userInterfaceExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance().addPanel(new DefaultPanel("misc", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 80, "/WEB-INF/jsp/content/extensions/miscExtensionStoreContent.jspf", null, "extensions", false)); PanelManager.getInstance() .addPanel(new DefaultPanel("articles", ConfigureExtensionsForm.EXTENSIONS_TAB_ID, 90, "/WEB-INF/jsp/content/extensions/articlesExtensionStoreContent.jspf", null, "extensions", false)); }
From source file:org.quartz.xml.JobSchedulingDataProcessor.java
/** * EntityResolver interface./* w w w .j a v a2s .c om*/ * <p/> * Allow the application to resolve external entities. * <p/> * Until <code>quartz.dtd</code> has a public ID, it must resolved as a * system ID. Here's the order of resolution (if one fails, continue to the * next). * <ol> * <li>Tries to resolve the <code>systemId</code> with <code>ClassLoader.getResourceAsStream(String)</code>. * </li> * <li>If the <code>systemId</code> starts with <code>QUARTZ_SYSTEM_ID_PREFIX</code>, * then resolve the part after <code>QUARTZ_SYSTEM_ID_PREFIX</code> with * <code>ClassLoader.getResourceAsStream(String)</code>.</li> * <li>Else try to resolve <code>systemId</code> as a URL. * <li>If <code>systemId</code> has a colon in it, create a new <code>URL</code> * </li> * <li>Else resolve <code>systemId</code> as a <code>File</code> and * then call <code>File.toURL()</code>.</li> * </li> * </ol> * <p/> * If the <code>publicId</code> does exist, resolve it as a URL. If the * <code>publicId</code> is the Quartz public ID, then resolve it locally. * * @param publicId * The public identifier of the external entity being referenced, * or null if none was supplied. * @param systemId * The system identifier of the external entity being referenced. * @return An InputSource object describing the new input source, or null * to request that the parser open a regular URI connection to the * system identifier. * @exception SAXException * Any SAX exception, possibly wrapping another exception. * @exception IOException * A Java-specific IO exception, possibly the result of * creating a new InputStream or Reader for the InputSource. */ public InputSource resolveEntity(String publicId, String systemId) { InputSource inputSource = null; InputStream is = null; URL url = null; try { if (publicId == null) { if (systemId != null) { // resolve Quartz Schema locally if (QUARTZ_SCHEMA.equals(systemId)) { is = getClass().getResourceAsStream(QUARTZ_XSD); } else { is = getInputStream(systemId); if (is == null) { int start = systemId.indexOf(QUARTZ_SYSTEM_ID_PREFIX); if (start > -1) { String fileName = systemId.substring(QUARTZ_SYSTEM_ID_PREFIX.length()); is = getInputStream(fileName); } else { if (systemId.indexOf(':') == -1) { File file = new java.io.File(systemId); url = file.toURL(); } else { url = new URL(systemId); } is = url.openStream(); } } } } } else { // resolve Quartz DTD locally if (QUARTZ_PUBLIC_ID.equals(publicId)) { is = getClass().getResourceAsStream(QUARTZ_DTD); } else { url = new URL(systemId); is = url.openStream(); } } } catch (Exception e) { e.printStackTrace(); } finally { if (is != null) { inputSource = new InputSource(is); inputSource.setPublicId(publicId); inputSource.setSystemId(systemId); } } return inputSource; }
From source file:org.apache.axis2.jaxws.framework.JAXWSDeployer.java
protected void deployServicesInWARClassPath() { String dir = DeploymentEngine.getWebLocationString(); if (dir != null) { File file = new File(dir + "/WEB-INF/classes/"); URL repository = axisConfig.getRepository(); if (!file.isDirectory() || repository == null) return; ArrayList<String> classList = getClassesInWebInfDirectory(file); ClassLoader threadClassLoader = null; try {/*from w w w. j a v a2 s .com*/ threadClassLoader = Thread.currentThread().getContextClassLoader(); ArrayList<URL> urls = new ArrayList<URL>(); urls.add(repository); String webLocation = DeploymentEngine.getWebLocationString(); if (webLocation != null) { urls.add(new File(webLocation).toURL()); } ClassLoader classLoader = Utils.createClassLoader(urls, axisConfig.getSystemClassLoader(), true, (File) axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR), axisConfig.isChildFirstClassLoading()); Thread.currentThread().setContextClassLoader(classLoader); deployClasses("JAXWS-Builtin", file.toURL(), Thread.currentThread().getContextClassLoader(), classList); } catch (NoClassDefFoundError e) { if (log.isDebugEnabled()) { log.debug(Messages.getMessage("deployingexception", e.getMessage()), e); } } catch (Exception e) { log.info(Messages.getMessage("deployingexception", e.getMessage()), e); } finally { if (threadClassLoader != null) { Thread.currentThread().setContextClassLoader(threadClassLoader); } } } }
From source file:org.talend.repository.services.ui.scriptmanager.ServiceExportWithMavenManager.java
@Override protected void addMavenBuildScripts(ExportFileResource[] processes, List<URL> scriptsUrls, Map<String, String> mavenPropertiesMap) { if (!PluginChecker.isPluginLoaded(PluginChecker.EXPORT_ROUTE_PLUGIN_ID)) { return;/* www .j a v a 2 s.c o m*/ } Item item = processes[0].getItem(); File templatePomFile = null, templateBundleFile = null, templateFeatureFile = null, templateParentFile = null; if (item != null) { IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(item.getProperty()); IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(item.getProperty()); if (itemLocationPath != null && objectTypeFolder != null) { IPath itemRelativePath = itemLocationPath.removeLastSegments(1) .makeRelativeTo(objectTypeFolder.getLocation()); templatePomFile = PomUtil.getTemplateFile(objectTypeFolder, itemRelativePath, TalendMavenConstants.POM_FILE_NAME); if (FilesUtils.allInSameFolder(templatePomFile, IProjectSettingTemplateConstants.MAVEN_CONTROL_BUILD_BUNDLE_FILE_NAME, IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME, IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME)) { templateBundleFile = new File(templatePomFile.getParentFile(), IProjectSettingTemplateConstants.MAVEN_CONTROL_BUILD_BUNDLE_FILE_NAME); templateFeatureFile = new File(templatePomFile.getParentFile(), IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME); templateParentFile = new File(templatePomFile.getParentFile(), IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME); } else { // don't use template file from repository. // other files is not init, so no need set null at all. templatePomFile = null; } } } File mavenBuildFile = new File( getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.POM_FILE_NAME); File mavenBuildBundleFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.MAVEN_CONTROL_BUILD_BUNDLE_FILE_NAME); File mavenBuildFeatureFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME); File mavenBuildParentFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME); try { String mavenScript = MavenTemplateManager.getTemplateContent(templatePomFile, IProjectSettingPreferenceConstants.TEMPLATE_SERVICES_KARAF_POM, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_SERVICES + '/' + TalendMavenConstants.POM_FILE_NAME); if (mavenScript != null) { createMavenBuildFileFromTemplate(mavenBuildFile, mavenScript); updateMavenBuildFileContent(mavenBuildFile, mavenPropertiesMap, false, true); scriptsUrls.add(mavenBuildFile.toURL()); } mavenScript = MavenTemplateManager.getTemplateContent(templateBundleFile, IProjectSettingPreferenceConstants.TEMPLATE_SERVICES_KARAF_BUNDLE, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_SERVICES + '/' + IProjectSettingTemplateConstants.MAVEN_CONTROL_BUILD_BUNDLE_FILE_NAME); if (mavenScript != null) { createMavenBuildFileFromTemplate(mavenBuildBundleFile, mavenScript); updateMavenBuildFileContent(mavenBuildBundleFile, mavenPropertiesMap, true, false); scriptsUrls.add(mavenBuildBundleFile.toURL()); } mavenScript = MavenTemplateManager.getTemplateContent(templateFeatureFile, IProjectSettingPreferenceConstants.TEMPLATE_SERVICES_KARAF_FEATURE, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_SERVICES + '/' + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME); if (mavenScript != null) { createMavenBuildFileFromTemplate(mavenBuildFeatureFile, mavenScript); updateMavenBuildFileContent(mavenBuildFeatureFile, mavenPropertiesMap); scriptsUrls.add(mavenBuildFeatureFile.toURL()); } mavenScript = MavenTemplateManager.getTemplateContent(templateParentFile, IProjectSettingPreferenceConstants.TEMPLATE_SERVICES_KARAF_PARENT, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_SERVICES + '/' + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME); if (mavenScript != null) { createMavenBuildFileFromTemplate(mavenBuildParentFile, mavenScript); updateMavenBuildFileContent(mavenBuildParentFile, mavenPropertiesMap); scriptsUrls.add(mavenBuildParentFile.toURL()); } } catch (Exception e) { ExceptionHandler.process(e); } }
From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java
public void actionPerformed(ActionEvent arg0) { JMenuItem source = (JMenuItem) (arg0.getSource()); if (source.getText().equals(MENU_ABOUT)) { JOptionPane.showMessageDialog(this, WDBearManager.VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "\n" + "Supports any WDB version\n" + "\n" + "Thanks to:\n" + "DarkMan for testing,\n" + "John for the 1.10 specs, Annunaki for helping with the header,\n" + "Andrikos for the 1.6.x WDB specs, Pyro's WDBViewer, WDDG Forum,\n" + "blizzhackers, etc etc\n\n" + "This program uses: \n" + "JGoodies from http://www.jgoodies.com/\n" + "Hypersonic SQL database 1.7.3\n" + "Apache Log4J, Xerces\n" + "Jakarta Commons Logging and CLI\n" + "Castor from ExoLab\n" + "MySQL JDBC connector 3.1.7\n" + "HTTPUNIT from Russell Gold\n" + "Jython 2.1\n" + "Refer to directory 'licenses' for more details about the software used\n" + "PLEASE:\n" + "If you like this program and find it usefull:\n" + "Please donate money to a charity oranization of your choice.\n" + "I recommend any organization that fights cancer.\n\n" + "License:\n" + "WDBearMgr is placed under the GNU GPL. \n" + "For further information, see the page :\n" + "http://www.gnu.org/copyleft/gpl.html.\n" + "See licenses/GPL_license.html\n" + "\n" + "For a different license please contact the author.", "Info " + VERSION_INFO, JOptionPane.INFORMATION_MESSAGE); return;/*from w ww. ja v a 2 s. co m*/ } else if (source.getText().equals(MENU_HELP)) { JFrame myFrame = new JFrame("doc/html/index.html"); //myFrame.setFont( ); URL urlHTML = null; try { JEditorPane htmlPane = new JEditorPane(); //htmlPane.setFont(sourceFont); // .out.println("/scripts/"+source.getName()+".py"); File scriptFile = new File("doc/html/index.html"); urlHTML = scriptFile.toURL();//this.getClass().getResource("/scripts/"+source.getName()+".py"); // .out.println( urlHTML ); // .out.println( urlHTML.toExternalForm() ); htmlPane.setPage(urlHTML); htmlPane.setEditable(false); JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane); htmlPane.addHyperlinkListener(myJEPHL); myFrame.getContentPane().add(new JScrollPane(htmlPane)); myFrame.pack(); myFrame.setSize(640, 480); myFrame.show(); } catch (Exception ex) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not open 'doc/html/index.html'", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); } } else if (source.getText().equals(MENU_JDOCS)) { JFrame myFrame = new JFrame("doc/javadoc/index.html"); //myFrame.setFont( ); URL urlHTML = null; try { JEditorPane htmlPane = new JEditorPane(); //htmlPane.setFont(sourceFont); // .out.println("/scripts/"+source.getName()+".py"); File scriptFile = new File("doc/javadoc/index.html"); urlHTML = scriptFile.toURL(); htmlPane.setPage(urlHTML); htmlPane.setEditable(false); JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane); htmlPane.addHyperlinkListener(myJEPHL); myFrame.getContentPane().add(new JScrollPane(htmlPane)); myFrame.pack(); myFrame.setSize(640, 480); myFrame.show(); } catch (Exception ex) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not open 'doc/javadoc/index.html'", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); } } else if (source.getText().equals(MENU_CHECKUPDATE)) { Properties dbProps = null; String filName = PROPS_CHECK_UPDATE; try { dbProps = ReadPropertiesFile.readProperties(filName); String updFile = dbProps.getProperty(KEY_UPD_FILE); if (updFile == null) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not find update information", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); return; } String updSite = dbProps.getProperty(KEY_WDBMGR_SITE); if (updFile == null) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not find SITE information", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); return; } URL urlUpdScript = new URL(updFile); BufferedReader in = new BufferedReader(new InputStreamReader(urlUpdScript.openStream())); String versionTXT = in.readLine(); String downloadName = in.readLine(); in.close(); if (versionTXT.equals(WDBearManager.VERSION_INFO)) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "You are using the latest version, no updates available", "Info " + VERSION_INFO, JOptionPane.INFORMATION_MESSAGE); return; } else { // Read version.txt String versionInfo = (String) dbProps.getProperty(KEY_VERSION_INFO); URL urlversionInfo = new URL(versionInfo); BufferedReader brVInfo = new BufferedReader(new InputStreamReader(urlversionInfo.openStream())); StringBuffer sbuVInfo = new StringBuffer(); String strLine = ""; boolean foundStart = false; while ((strLine = brVInfo.readLine()) != null) { if (strLine.startsWith("---")) { break; } if (foundStart == true) { sbuVInfo.append(strLine); sbuVInfo.append("\n"); continue; } if (strLine.startsWith(versionTXT)) { foundStart = true; continue; } } brVInfo.close(); int n = JOptionPane.showConfirmDialog(this, "New version available - Please visit " + updSite + "\n\n" + versionTXT + "\n" + "\n" + "You are using version:\n" + WDBearManager.VERSION_INFO + "\n" + "\n" + "Do you want to download this version?\n\n" + "Version information:\n" + sbuVInfo.toString(), VERSION_INFO + "by kizura", JOptionPane.YES_NO_OPTION); // JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" // + "by kizura\n" + WDBManager.EMAIL + "\n\n" // + "New version available - Please visit " + updSite, // "Warning " // + VERSION_INFO, JOptionPane.WARNING_MESSAGE); if (n == 0) { JFileChooser chooser = new JFileChooser(new File(".")); chooser.setDialogTitle("Please select download location"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { URL urlUpd = new URL(downloadName); BufferedInputStream bin = new BufferedInputStream(urlUpd.openStream()); System.out.println( new File(chooser.getSelectedFile(), urlUpd.getFile()).getAbsolutePath()); File thisFile = new File(chooser.getSelectedFile(), urlUpd.getFile()); BufferedOutputStream bout = new BufferedOutputStream( new FileOutputStream(thisFile)); byte[] bufFile = new byte[102400]; int bytesRead = 0; while ((bytesRead = bin.read(bufFile)) != -1) { bout.write(bufFile, 0, bytesRead); } bin.close(); bout.close(); JOptionPane.showMessageDialog(this, "Update downloaded successfully" + "\n" + "Please check '" + thisFile.getAbsolutePath() + "'", "Success " + WDBearManager.VERSION_INFO, JOptionPane.INFORMATION_MESSAGE); //String msg = WriteCSV.writeCSV(chooser.getSelectedFile(), this.items); } catch (Exception ex) { String msg = ex.getMessage(); JOptionPane.showMessageDialog(this, msg + "\n" + "Error downloading update", "Error " + WDBearManager.VERSION_INFO, JOptionPane.ERROR_MESSAGE); } } } // user selected "download" return; } } catch (Exception ex) { ex.printStackTrace(); } } else { System.exit(0); } }