Skip to content

Commit

Permalink
2003-01-13 Pierre-Luc Paour <gallery@paour.com> (1.3-b15)
Browse files Browse the repository at this point in the history
	* Detect even more screwed up album hierarchies and
	  display an alert to suggest a fix.
  • Loading branch information
Pierre-Luc Paour committed Jan 14, 2004
1 parent ca2a0e6 commit 60250b5
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 68 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2003-01-13 Pierre-Luc Paour <gallery@paour.com> (1.3-b15)

* Detect even more screwed up album hierarchies and
display an alert to suggest a fix.

2003-01-11 Pierre-Luc Paour <gallery@paour.com> (1.3-b14)

* Fixed adding album into root album: extra album would appear
Expand Down
52 changes: 44 additions & 8 deletions com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -29,6 +29,7 @@
import com.gallery.GalleryRemote.prefs.PreferenceNames;
import com.gallery.GalleryRemote.util.GRI18n;
import com.gallery.GalleryRemote.util.HTMLEscaper;
import com.gallery.GalleryRemote.util.UrlMessageDialog;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -358,6 +359,8 @@ GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, b
GalleryProperties p = new GalleryProperties();
p.load(new StringBufferInputStream(response));

//mConnection.stop();

su.stopProgress(StatusUpdate.LEVEL_UPLOAD_ONE, GRI18n.getString(MODULE, "addImgOk"));

return p;
Expand Down Expand Up @@ -857,16 +860,49 @@ private void list22() throws IOException, ModuleException {
while (it.hasNext()) {
Album a = (Album) it.next();

if (a.getAlbumDepth() == depth) {
try {
if (a.getAlbumDepth() == depth) {
it.remove();

Album parentAlbum = a.getParentAlbum();
if (parentAlbum == null) {
orderedAlbums.add(a);
} else {
int i = orderedAlbums.indexOf(parentAlbum);
orderedAlbums.add(i + 1, a);
}
}
} catch (IllegalArgumentException e) {
it.remove();

Album parentAlbum = a.getParentAlbum();
if (parentAlbum == null) {
orderedAlbums.add(a);
} else {
int i = orderedAlbums.indexOf(parentAlbum);
orderedAlbums.add(i + 1, a);
Log.log(Log.LEVEL_TRACE, MODULE, "Gallery server album list is corrupted: " +
"album " + a.getName() + " has a bad containment hierarchy.");

/*JOptionPane.showMessageDialog(GalleryRemote.getInstance().mainFrame,
GRI18n.getString(MODULE, "fixCorrupted", new String[] {
a.getTitle(),
a.getGallery().getGalleryUrl(a.getName()).toString()}),
GRI18n.getString(MODULE, "fixCorruptedTitle"),
JOptionPane.ERROR_MESSAGE);*/

if (! GalleryRemote.getInstance().properties.getBooleanProperty(SUPPRESS_WARNING_CORRUPTED)) {
UrlMessageDialog md = new UrlMessageDialog(
GRI18n.getString(MODULE, "fixCorrupted", new String[] {
a.getTitle(),
a.getGallery().getGalleryUrl(a.getName()).toString()}),
a.getGallery().getGalleryUrl(GRI18n.getString(MODULE, "fixCorruptedUrl", new String[] {
a.getName()} )).toString(),
null);

if (md.dontShow()) {
GalleryRemote.getInstance().properties.setBooleanProperty(SUPPRESS_WARNING_CORRUPTED, true);
}
}

// This doesn't work: there's a problem with the connection (maybe not re-entrant...)
//if (answer == JOptionPane.YES_OPTION) {
//a.moveAlbumTo(su, null);
//moveAlbum(su, a, null, true);
//}
}
}

Expand Down
10 changes: 7 additions & 3 deletions com/gallery/GalleryRemote/model/Album.java
Expand Up @@ -687,16 +687,20 @@ void setPicturesList(ArrayList pictures) {
notifyListeners();
}

public int getAlbumDepth() {
public int getAlbumDepth() throws IllegalArgumentException {
if (albumDepth == null) {
albumDepth = new Integer(depthHelper(0));
}

return albumDepth.intValue();
}

int depthHelper(int depth) {
if (getParentAlbum() != null && getParentAlbum() != this) {
int depthHelper(int depth) throws IllegalArgumentException {
if (getParentAlbum() == this || depth > 20) {
throw new IllegalArgumentException("Circular containment hierarchy. Gallery corrupted!");
}

if (getParentAlbum() != null) {
return getParentAlbum().depthHelper(depth + 1);
} else {
return depth;
Expand Down
1 change: 1 addition & 0 deletions com/gallery/GalleryRemote/prefs/PreferenceNames.java
Expand Up @@ -60,4 +60,5 @@ public interface PreferenceNames {
// Other
public static final String SUPPRESS_WARNING_IM = "suppressWarningIM";
public static final String SUPPRESS_WARNING_JPEGTRAN = "suppressWarningJpegtran";
public static final String SUPPRESS_WARNING_CORRUPTED = "suppressWarningCorrupted";
}
7 changes: 7 additions & 0 deletions com/gallery/GalleryRemote/resources/GRResources.properties
Expand Up @@ -330,6 +330,13 @@ GalComm2.fetchAlbImagesDone = Received {0} images descriptions from server.
GalComm2.moveAlbum = Moving album {0} to {1}
GalComm2.moveAlbumDone = Album successfully moved
GalComm2.rootAlbum = root album
GalComm2.fixCorrupted = <html>The album called {0} at URL: <br><br>&nbsp;&nbsp;{1}<br><br> is corrupted: \
its containment hierarchy is an endless loop.<br> \
Gallery Remote can help you fix this situation. Log in to the gallery that contains \
this album with the administrator account, then click on the link below.<br> \
This will fix the album by placing it at the root of the gallery.<br> \
You will need then want to move it to a permanent location.
GalComm2.fixCorruptedUrl = gallery_remote2.php?cmd=move-album&protocol_version=2.7&set_albumName={0}&set_destalbumName=0


#NewAlbum module
Expand Down
57 changes: 2 additions & 55 deletions com/gallery/GalleryRemote/util/ImageUtils.java
Expand Up @@ -27,8 +27,6 @@

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.io.*;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -815,7 +813,7 @@ static void stopUsingIM() {
if (!GalleryRemote.getInstance().properties.getBooleanProperty(PreferenceNames.SUPPRESS_WARNING_IM)) {
if (GalleryRemote.getInstance().mainFrame != null
&& GalleryRemote.getInstance().mainFrame.isVisible()) {
MessageDialog md = new MessageDialog(
UrlMessageDialog md = new UrlMessageDialog(
GRI18n.getString(MODULE, "warningTextIM"),
GRI18n.getString(MODULE, "warningUrlIM"),
GRI18n.getString(MODULE, "warningUrlTextIM")
Expand All @@ -836,7 +834,7 @@ static void stopUsingJpegtran() {
if (!GalleryRemote.getInstance().properties.getBooleanProperty(PreferenceNames.SUPPRESS_WARNING_JPEGTRAN)) {
if (GalleryRemote.getInstance().mainFrame != null
&& GalleryRemote.getInstance().mainFrame.isVisible()) {
MessageDialog md = new MessageDialog(
UrlMessageDialog md = new UrlMessageDialog(
GRI18n.getString(MODULE, "warningTextJpegtran"),
GRI18n.getString(MODULE, "warningUrlJpegtran"),
GRI18n.getString(MODULE, "warningUrlTextJpegtran")
Expand All @@ -850,55 +848,4 @@ static void stopUsingJpegtran() {
}
}
}

static class MessageDialog extends JDialog {
JLabel jIcon = new JLabel();
JLabel jMessage = new JLabel();
BrowserLink jURL = new BrowserLink();
JCheckBox jDontShow = new JCheckBox();
JButton jOk = new JButton();

public MessageDialog(String message, String url, String urlText) {
super(GalleryRemote.getInstance().mainFrame,
GRI18n.getString(MODULE, "warningTitle"),
true);

jIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
getContentPane().setLayout(new GridBagLayout());
jMessage.setText(message);
jURL.setText(urlText);
jURL.setUrl(url);
jDontShow.setText(GRI18n.getString(MODULE, "warningDontShow"));
jOk.setText(GRI18n.getString(MODULE, "warningOK"));
jOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});

getContentPane().add(jIcon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(5, 5, 0, 10), 0, 0));
getContentPane().add(jMessage, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
getContentPane().add(jURL, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
getContentPane().add(jDontShow, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
getContentPane().add(jOk, new GridBagConstraints(2, 2, 1, 2, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));

getRootPane().setDefaultButton(jOk);

pack();

DialogUtil.center(this, getOwner());

setVisible(true);
}

public boolean dontShow() {
return jDontShow.isSelected();
}
}
}
71 changes: 71 additions & 0 deletions com/gallery/GalleryRemote/util/UrlMessageDialog.java
@@ -0,0 +1,71 @@
package com.gallery.GalleryRemote.util;

import com.gallery.GalleryRemote.GalleryRemote;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
* Created by IntelliJ IDEA.
* User: paour
* Date: Jan 13, 2004
*/
public class UrlMessageDialog extends JDialog {
public static final String MODULE = "ImageUtils";
JLabel jIcon = new JLabel();
JLabel jMessage = new JLabel();
BrowserLink jURL = new BrowserLink();
JCheckBox jDontShow = new JCheckBox();
JButton jOk = new JButton();

public UrlMessageDialog(String message, String url, String urlText) {
super(GalleryRemote.getInstance().mainFrame,
GRI18n.getString(MODULE, "warningTitle"),
true);

jIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
getContentPane().setLayout(new GridBagLayout());
jMessage.setText(message);

if (urlText != null) {
jURL.setText(urlText);
} else {
jURL.setText(url);
}

jURL.setUrl(url);
jDontShow.setText(GRI18n.getString(MODULE, "warningDontShow"));
jOk.setText(GRI18n.getString(MODULE, "warningOK"));
jOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});

getContentPane().add(jIcon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(5, 5, 0, 10), 0, 0));
getContentPane().add(jMessage, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
getContentPane().add(jURL, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
getContentPane().add(jDontShow, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
getContentPane().add(jOk, new GridBagConstraints(2, 2, 1, 2, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));

getRootPane().setDefaultButton(jOk);

pack();

DialogUtil.center(this, getOwner());

setVisible(true);
}

public boolean dontShow() {
return jDontShow.isSelected();
}
}
7 changes: 5 additions & 2 deletions defaults.properties
Expand Up @@ -100,6 +100,9 @@ uiLocale=
suppressWarningIM=false
suppressWarningJpegtran=false;

# Warning windows for corruped galleries
suppressWarningCorrupted=false

#
# --- File Menu ---
#
Expand Down Expand Up @@ -165,6 +168,6 @@ updateUrlBeta=http://gallery.sourceforge.net/gallery_remote_version_check_beta.p
#
# --- Do not edit below this line ---
#
version=1.3-b14
releaseDate=2004/01/11
version=1.3-b15
releaseDate=2004/01/13
aboutText=Gallery Remote\n \n \nA part of the Gallery Open-Source Project\nhttp://gallery.sourceforge.net\n \n \nMaintained by:\n \nPierre-Luc Paour\nAmedeo Paglione\nChris Schwerdt\n \n \nInitial version by Chris Smith\n \n \nContributors:\n \nTim Miller\nDolan Halbrook\nMarkus Cozowicz\nScott Gartner\n \n \nArtwork by Ross A. Reyman\n \n \nBundled software:\n \nImageMagick\nJSX\nJava look and feel Graphics Repository icons\njpegtran, Guido Vollbeding's version\nMetadataExtractor

0 comments on commit 60250b5

Please sign in to comment.