status(su, "Logging in to " + g.toString());
status(su, StatusUpdate.LEVEL_GENERIC, "Logging in to " + g.toString());
		private boolean login() {			status(su, "Logging in to " + g.toString());			if (g.getType() != Gallery.TYPE_STANDALONE) {				try {					requestResponse( null, null, g.getLoginUrl(SCRIPT_NAME), false );				} catch (IOException ioe) {					Log.logException(Log.ERROR, MODULE, ioe);					error(su, "Error: " + ioe.toString());				} catch (ModuleException me) {					Log.logException(Log.ERROR, MODULE, me);					error(su, "Error handling request: " + me.getMessage());				}			}			// setup protocol parameters			String username = g.getUsername();			String password = g.getPassword();			if (username == null || username.length() == 0) {				username = (String)JOptionPane.showInputDialog(                    (JFrame) su,                    "Username:",                    "Username",                    JOptionPane.PLAIN_MESSAGE,                    null,                    null,                    null);				g.setUsername(username);			}			if (password == null || password.length() == 0) {				password = (String)JOptionPane.showInputDialog(                    (JFrame) su,                    "Password:",                    "Password",                    JOptionPane.PLAIN_MESSAGE,                    null,                    null,                    null);				g.setPassword(password);			}			NVPair form_data[] = {				new NVPair("cmd", "login"),				new NVPair("protocol_version", PROTOCOL_VERSION),				new NVPair("uname", username),				new NVPair("password", password)			};			Log.log(Log.TRACE, MODULE, "login parameters: " + Arrays.asList(form_data));			// make the request			try	{				// load and validate the response				Properties p = requestResponse( form_data, g.getGalleryUrl(SCRIPT_NAME) );				if ( GR_STAT_SUCCESS.equals( p.getProperty( "status" ) ) ) {					status(su, "Logged in");					try {						String serverVersion = p.getProperty( "server_version" );						int i = serverVersion.indexOf( "." );						serverMinorVersion = Integer.parseInt( serverVersion.substring( i+1 ) );						Log.log(Log.TRACE, MODULE, "Server minor version: " + serverMinorVersion);						if (serverMinorVersion == 1) {							// we have more than the 2.0 capabilities, we have 2.1 capabilities.							capabilities = capabilities1;						} else if (serverMinorVersion >= 2) {							// we have more than the 2.1 capabilities, we have 2.2 capabilities.							capabilities = capabilities2;						}					} catch (Exception e) {						Log.log( Log.ERROR, MODULE, "Malformed server_version: " + p.getProperty( "server_version" ) );						Log.logException(Log.ERROR, MODULE, e);					}					return true;				} else if (GR_STAT_PASSWD_WRONG.equals(p.getProperty("status"))) {					error(su, "Invalid username/password.\n\n" +							"If your Gallery is embedded inside a CMS like PostNuke,\n" +							"you need to use the \"native\" (non-embedded) Gallery URL to log in,\n" +							"as well as the native Gallery user and password.\n" +							"You can test these by trying to go the native URL and trying to log in.");					return false;				} else {					error(su, "Login Error: " + p.getProperty( "status_text" ));					return false;				}			} catch ( GR2Exception gr2e ) {				Log.logException(Log.ERROR, MODULE, gr2e );				error(su, "Error: " + gr2e.getMessage());			} catch (IOException ioe) {				Log.logException(Log.ERROR, MODULE, ioe);				error(su, "Error: " + ioe.toString());			} catch (ModuleException me) {				Log.logException(Log.ERROR, MODULE, me);				error(su, "Error handling request: " + me.getMessage());			}			return false;		}