protected void checkServerVersion(String serverVersion) { String thisVersion = null; if (serverVersion != null) { thisVersion = VersionUtils.getVersion(); if (thisVersion != null) thisVersion = VersionUtils.toAppletVersion(thisVersion); if (thisVersion == null || serverVersion.equals(thisVersion)) return; // ok } String jnlpUrl = "https://www.projity.com/web/jnlp/project-on-demand.jnlp"; // String jnlpUrl="http://192.168.0.2/web/jnlp/project-on-demand.jnlp"; if (Alert.okCancel(Messages.getString("Text.newPODVersion"))) { try { Object basicService = ClassLoaderUtils.forName("javax.jnlp.ServiceManager") .getMethod("lookup", new Class[] {String.class}) .invoke(null, new Object[] {"javax.jnlp.BasicService"}); ClassLoaderUtils.forName("javax.jnlp.BasicService") .getMethod("showDocument", new Class[] {URL.class}) .invoke(basicService, new Object[] {new URL(jnlpUrl)}); } catch (Exception e) { // e.printStackTrace(); // Not running in JavaWebStart or service is not supported. return; // Runtime.getRuntime().exec("javaws "); } // try { // BasicService basicService=(BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); // basicService.showDocument(/*new URL(basicService.getCodeBase(),*/new URL(jnlpUrl)); // }catch (UnavailableServiceException e) { // Runtime.getRuntime().exec("javaws "); // } System.exit(0); } }
*/ public Boolean verifyOpenWritable(Long projectId) { if (projectId == null || projectId == 0) return null; if (ProjectFactory.getInstance().isResourcePoolOpenAndWritable()) { Alert.warn(Messages.getString("Warn.resourcePoolOpen")); return null; } String locker = getLockerName(projectId); boolean openAs = false; if (locker != null) { openAs = (JOptionPane.YES_OPTION == Alert.confirmYesNo(Messages.getStringWithParam("Warn.lockMessage", locker))); if (openAs == false) return null; } return !openAs; }
public List getChange() { ArrayList change = new ArrayList(); for (Iterator i = fieldComponents.keySet().iterator(); i.hasNext(); ) { String fieldId = (String) i.next(); Object component = fieldComponents.get(fieldId); if (component instanceof ChangeAwareComponent && ((ChangeAwareComponent) component).hasChanged()) { String stringValue; if (component instanceof JTextField) stringValue = ((JTextField) component).getText(); // hangle other components here else continue; Field field = Configuration.getFieldFromId(fieldId); try { Object value = FieldConverter.fromString(stringValue, field.getDisplayType()); change.add(new FieldChange(field, value)); } catch (Exception e) { Alert.error(e.getMessage()); } } } return change; }
public boolean doLogin(GraphicManager graphicManager) { if (Environment.isNoPodServer()) { Environment.setNewLook(true); log.info("Login POD Server."); } if (Environment.getStandAlone() || Environment.isNoPodServer()) { if (!Environment.isNoPodServer()) { Environment.setUser(new DefaultUser()); log.info("Locale user."); } return true; } credentials.put("serverUrl", serverUrl); getCredentials(); Environment.setNewLook(true); int badLoginCount = 0; while (true) { // until a good login or exit because of too many bad // graphicManager.getFrame().setVisible(true); if (login == null || password == null || badLoginCount > 0) { URL loginUrl = null; if (login == null || password == null) { try { loginUrl = new URL(serverUrl + "/login"); System.out.println("trying login at " + serverUrl + "/login"); } catch (MalformedURLException e) { } } LoginForm form = LoginDialog.doLogin(graphicManager.getFrame(), loginUrl); // it's actually a singleton if (form.isCancelled()) System.exit(-1); if (form.isUseMenus()) Environment.setNewLook(false); login = form.getLogin(); password = form.getPassword(); } if ("_SA".equals(login) || Environment.getStandAlone()) { // for testing purposes! Environment.setStandAlone(true); Environment.setUser(new DefaultUser()); break; } else { credentials.put("login", login); credentials.put("password", password); SessionFactory.getInstance().setCredentials(credentials); try { Session session = SessionFactory.getInstance().getSession(false); System.out.println("logging in"); final GraphicManager gm = graphicManager; SessionFactory.callNoEx( session, "login", new Class[] {Closure.class}, new Object[] { new Closure() { public void execute(Object arg0) { Map<String, String> env = (Map<String, String>) arg0; if (env != null) { String serverVersion = env.get("serverVersion"); checkServerVersion(serverVersion); } if (gm != null) gm.setConnected(true); } } }); if (!((Boolean) SessionFactory.callNoEx(session, "isLicensedToRunClient", null, null)) .booleanValue()) { Alert.error(Messages.getString("Error.roleCantRunClient")); abort(); return false; } // System.out.println("Application started with args: credentials=" + // credentials.get("login") + " name " + session.getUser().getName() + " Roles " + // session.getUser().getServerRoles()); break; // TODO test if login is valid. If not, reshow login dialog } catch (Exception e) { if (Session.EXPIRED.equals(e.getMessage())) { Alert.error(Messages.getString("Error.accountExpired")); abort(); return false; } System.out.println("failure " + e); badLoginCount++; SessionFactory.getInstance().clearSessions(); if (badLoginCount == NUM_INVALID_LOGINS) { Alert.error(Messages.getString("Login.tooManyBad")); abort(); return false; } else { Alert.error(Messages.getString("Login.error")); } } } } return true; }