Skip to content

Commit

Permalink
Check for registration not open http return code and report a nicer w…
Browse files Browse the repository at this point in the history
…arning.
  • Loading branch information
chenson42 committed Oct 4, 2007
1 parent cf3c279 commit 0983698
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
@@ -0,0 +1,7 @@
package org.jumpmind.symmetric.service;

public class RegistrationNotOpenException extends RuntimeException {

private static final long serialVersionUID = 7736136383224998646L;

}
Expand Up @@ -20,6 +20,7 @@
import org.jumpmind.symmetric.model.IncomingBatchHistory.Status;
import org.jumpmind.symmetric.service.IDataLoaderService;
import org.jumpmind.symmetric.service.IIncomingBatchService;
import org.jumpmind.symmetric.service.RegistrationNotOpenException;
import org.jumpmind.symmetric.transport.IIncomingTransport;
import org.jumpmind.symmetric.transport.ITransportManager;
import org.jumpmind.symmetric.transport.internal.InternalIncomingTransport;
Expand Down Expand Up @@ -85,6 +86,8 @@ protected List<IncomingBatchHistory> loadDataAndReturnBatches(
}
} catch (ConnectException ex) {
logger.warn(ErrorConstants.COULD_NOT_CONNECT_TO_TRANSPORT);
} catch (RegistrationNotOpenException ex) {
logger.warn("Registration attempt failed. Registration was not open for the node.");
} catch (Exception e) {
if (status != null) {
logger.error("Failed to load batch "
Expand Down
Expand Up @@ -6,7 +6,9 @@
import java.net.HttpURLConnection;

import org.apache.commons.io.IOUtils;
import org.jumpmind.symmetric.service.RegistrationNotOpenException;
import org.jumpmind.symmetric.transport.IIncomingTransport;
import org.jumpmind.symmetric.web.WebConstants;

public class HttpIncomingTransport implements IIncomingTransport {

Expand All @@ -27,8 +29,12 @@ public boolean isOpen() {
}

public BufferedReader open() throws IOException {
if (WebConstants.REGISTRATION_NOT_OPEN == conn.getResponseCode()) {
throw new RegistrationNotOpenException();
} else {
reader = new BufferedReader(
new InputStreamReader(conn.getInputStream(), "UTF-8"));
return reader;
}
}
}

0 comments on commit 0983698

Please sign in to comment.