Skip to content

Commit

Permalink
Added a bit more of a safety net for saved profiles that don't load r…
Browse files Browse the repository at this point in the history
…ight.
  • Loading branch information
Pierre-Luc Paour committed Sep 9, 2002
1 parent 3d1cfc3 commit 9a06523
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
28 changes: 17 additions & 11 deletions com/gallery/GalleryRemote/GalleryProperties.java
Expand Up @@ -224,6 +224,7 @@ public void setThumbnailSize( Dimension size ) {
*/
public Dimension getDimensionProperty( String name ) {
String value = getProperty( name );
if (value == null) return null;

StringTokenizer st;
if ( value != null && ( st = new StringTokenizer( value, "," ) ).countTokens() == 2 ) {
Expand Down Expand Up @@ -255,6 +256,7 @@ public void setDimensionProperty( String name, Dimension d ) {
*/
public Rectangle getRectangleProperty( String name ) {
String value = getProperty( name );
if (value == null) return null;

StringTokenizer st;
if ( value != null && ( st = new StringTokenizer( value, "," ) ).countTokens() == 4 ) {
Expand Down Expand Up @@ -332,6 +334,8 @@ public void setIntProperty( String name, int value ) {
*/
public String getBase64Property( String name ) {
String base64S = getProperty( name );
if (base64S == null) return null;

try {
return Base64.decode( base64S );
} catch ( Error e ) {
Expand All @@ -351,17 +355,6 @@ public void setBase64Property( String name, String value ) {
}


/**
* Set a property as a Date value
*
*@param name Name of the property
*@param value The value of the property
*/
public void setDateProperty( String name, Date date ) {
setProperty( name, dateFormat.format( date ) );
}


/**
* Gets the date Property attribute of the PropertiesFile object
*
Expand All @@ -370,6 +363,8 @@ public void setDateProperty( String name, Date date ) {
*/
public Date getDateProperty( String name ) {
String dateS = getProperty( name );
if (dateS == null) return null;

try {
return dateFormat.parse( dateS );
} catch ( ParseException e ) {
Expand All @@ -378,6 +373,17 @@ public Date getDateProperty( String name ) {
}


/**
* Set a property as a Date value
*
*@param name Name of the property
*@param value The value of the property
*/
public void setDateProperty( String name, Date date ) {
setProperty( name, dateFormat.format( date ) );
}


public String getProperty( String name, String defaultValue ) {
String tmp = getProperty( name );

Expand Down
21 changes: 13 additions & 8 deletions com/gallery/GalleryRemote/MainFrame.java
Expand Up @@ -122,14 +122,19 @@ public MainFrame() {
int i = -1;
String url;
while ( ( url = p.getProperty( "url." + (++i) ) ) != null ) {
String username = p.getProperty( "username." + i );
String password = p.getBase64Property( "password." + i );

Log.log(Log.INFO, MODULE, "loaded saved URL: " + url + " (" + username + "/******)" );

Gallery g = new Gallery(url, username, password);

galleries.addElement(g);
try {
String username = p.getProperty( "username." + i );
String password = p.getBase64Property( "password." + i );

Log.log(Log.INFO, MODULE, "loaded saved URL: " + url + " (" + username + "/******)" );

Gallery g = new Gallery(url, username, password);

galleries.addElement(g);
} catch (Exception e) {
Log.log(Log.ERROR, MODULE, "Error trying to load profile");
Log.logException(Log.ERROR, MODULE, e);
}
}

if ( galleries.getSize() == 0 ) {
Expand Down

0 comments on commit 9a06523

Please sign in to comment.