Changeset 2134 in josm


Ignore:
Timestamp:
Sep 14, 2009 9:13:06 PM (4 years ago)
Author:
Gubaer
Message:

fixed #3489: Confusing conflict message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r2115 r2134  
    88import java.io.IOException; 
    99import java.net.HttpURLConnection; 
     10import java.text.SimpleDateFormat; 
    1011import java.util.Collection; 
     12import java.util.Date; 
    1113import java.util.LinkedList; 
    1214import java.util.logging.Logger; 
     
    3335import org.openstreetmap.josm.io.OsmChangesetCloseException; 
    3436import org.openstreetmap.josm.io.OsmServerWriter; 
     37import org.openstreetmap.josm.tools.DateUtils; 
    3538import org.openstreetmap.josm.tools.Shortcut; 
    3639import org.xml.sax.SAXException; 
     
    293296 
    294297    /** 
     298     * Handles the case that a conflict was detected while uploading where we don't 
     299     * know what {@see OsmPrimitive} actually caused the conflict (for whatever reason) 
     300     * 
     301     */ 
     302    protected void handleUploadConflictForClosedChangeset(long changsetId, Date d) { 
     303        String msg =  tr("<html>Uploading <strong>failed</strong> because you've been using<br>" 
     304                + "changeset {0} which was already closed at {1}.<br>" 
     305                + "Please upload again with a new or an existing open changeset.", 
     306                changsetId, new SimpleDateFormat().format(d) 
     307        ); 
     308        JOptionPane.showMessageDialog( 
     309                Main.parent, 
     310                msg, 
     311                tr("Changeset closed"), 
     312                JOptionPane.ERROR_MESSAGE 
     313        ); 
     314    } 
     315 
     316    /** 
    295317     * handles an upload conflict, i.e. an error indicated by a HTTP return code 409. 
    296318     * 
     
    303325        if (m.matches()) { 
    304326            handleUploadConflictForKnownConflict(OsmPrimitiveType.from(m.group(3)), Long.parseLong(m.group(4)), m.group(2),m.group(1)); 
    305         } else { 
    306             logger.warning(tr("Warning: error header \"{0}\" did not match expected pattern \"{1}\"", e.getErrorHeader(),pattern)); 
    307             handleUploadConflictForUnknownConflict(); 
    308         } 
     327            return; 
     328        } 
     329        pattern ="The changeset (\\d+) was closed at (.*)"; 
     330        m = p.matcher(e.getErrorHeader()); 
     331        if (m.matches()) { 
     332            handleUploadConflictForClosedChangeset(Long.parseLong(m.group(1)), DateUtils.fromString(m.group(2))); 
     333            return; 
     334        } 
     335        logger.warning(tr("Warning: error header \"{0}\" did not match expected pattern \"{1}\"", e.getErrorHeader(),pattern)); 
     336        handleUploadConflictForUnknownConflict(); 
    309337    } 
    310338 
Note: See TracChangeset for help on using the changeset viewer.