Author: richard.opalka(a)jboss.com
Date: 2008-02-28 06:38:08 -0500 (Thu, 28 Feb 2008)
New Revision: 5841
Added:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultConstant.java
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMServerSequence.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMStore.java
Log:
throw RMFaults instead of runtime TODO exceptions
Added: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
(rev 0)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java 2008-02-28
11:38:08 UTC (rev 5841)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.wsrm;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.xml.ws.WebServiceException;
+
+/**
+ * RM fault
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @see org.jboss.ws.extensions.wsrm.RMFaultCode
+ * @see org.jboss.ws.extensions.wsrm.RMFaultConstant
+ */
+public class RMFault extends WebServiceException
+{
+
+ private final RMFaultCode faultCode;
+ private final Map<String, Object> details;
+
+ /**
+ * Constructor
+ * @param faultCode reason
+ */
+ public RMFault(RMFaultCode faultCode)
+ {
+ this(faultCode, Collections.EMPTY_MAP);
+ }
+
+ /**
+ * Constructor
+ * @param faultCode reason
+ * @param details to be de/serialized
+ */
+ public RMFault(RMFaultCode faultCode, Map<String, Object> details)
+ {
+ super();
+ this.faultCode = faultCode;
+ this.details = details;
+ }
+
+ /**
+ * Gets fault code
+ * @return fault code
+ */
+ public final RMFaultCode getFaultCode()
+ {
+ return this.faultCode;
+ }
+
+ /**
+ * Gets details
+ * @return details
+ */
+ public final Map<String, Object> getDetails()
+ {
+ return this.details;
+ }
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java 2008-02-28
11:38:08 UTC (rev 5841)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.wsrm;
+
+/**
+ * RM fault constants
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @see org.jboss.ws.extensions.wsrm.RMFault
+ * @see org.jboss.ws.extensions.wsrm.RMFaultConstant
+ */
+public final class RMFaultCode
+{
+
+ private final String subcode;
+ private final String reason;
+
+ /**
+ * Encountering an unrecoverable condition or detection of violation of the protocol.
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender or
Receiver</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:SequenceTerminated</td></tr>
+ * <tr><td>[Reason]</td><td>The Sequence has been terminated
due to an unrecoverable error.</td></tr>
+ * <tr><td>[Detail]</td><td><wsrm:Identifier...>
xs:anyURI </wsrm:Identifier></td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode SEQUENCE_TERMINATED = new RMFaultCode(
+ "SequenceTerminated",
+ "The Sequence has been terminated due to an unrecoverable error."
+ );
+
+ /**
+ * Response to a message containing an
+ * unknown or terminated Sequence identifier.
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:UnknownSequence</td></tr>
+ * <tr><td>[Reason]</td><td>The value of wsrm:Identifier is
not a known Sequence identifier.</td></tr>
+ * <tr><td>[Detail]</td><td><wsrm:Identifier...>
xs:anyURI </wsrm:Identifier></td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode UNKNOWN_SEQUENCE = new RMFaultCode(
+ "UnknownSequence",
+ "The value of wsrm:Identifier is not a known Sequence identifier."
+ );
+
+ /**
+ * An example of when this fault is generated is when a message
+ * is Received by the RM Source containing a SequenceAcknowledgement
+ * covering messages that have not been sent.
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:InvalidAcknowledgement</td></tr>
+ * <tr><td>[Reason]</td><td>The SequenceAcknowledgement
violates the cumulative Acknowledgement invariant.</td></tr>
+ *
<tr><td>[Detail]</td><td><wsrm:SequenceAcknowledgement
...> ... </wsrm:SequenceAcknowledgement></td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode INVALID_ACKNOWLEDGEMENT = new RMFaultCode(
+ "InvalidAcknowledgement",
+ "The SequenceAcknowledgement violates the cumulative Acknowledgement
invariant."
+ );
+
+ /**
+ * Message number in /wsrm:Sequence/wsrm:MessageNumber of a Received
+ * message exceeds the internal limitations of an RM Destination
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:MessageNumberRollover</td></tr>
+ * <tr><td>[Reason]</td><td>The maximum value for
wsrm:MessageNumber has been exceeded.</td></tr>
+ * <tr><td>[Detail]</td><td>
+ * <table>
+ * <tr><td><wsrm:Identifier ...> xs:anyURI
</wsrm:Identifier></td></tr>
+ * <tr><td><wsrm:MaxMessageNumber>
wsrm:MessageNumberType </wsrm:MaxMessageNumber></td></tr>
+ * </table>
+ * </td></tr></table>
+ * </p>
+ */
+ public static final RMFaultCode MESSAGE_NUMBER_ROLLOVER = new RMFaultCode(
+ "MessageNumberRollover",
+ "The maximum value for wsrm:MessageNumber has been exceeded."
+ );
+
+ /**
+ * In response to a CreateSequence message when the RM
+ * Destination does not wish to create a new Sequence.
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender or
Receiver</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:CreateSequenceRefused</td></tr>
+ * <tr><td>[Reason]</td><td>The Create Sequence request has
been refused by the RM Destination.</td></tr>
+ * <tr><td>[Detail]</td><td>xs:any</td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode CREATE_SEQUENCE_REFUSED = new RMFaultCode(
+ "CreateSequenceRefused",
+ "The Create Sequence request has been refused by the RM Destination."
+ );
+
+ /**
+ * This fault is generated by an RM Destination to indicate
+ * that the specified Sequence has been closed.
+ * This fault MUST be generated when an RM Destination is asked
+ * to accept a message for a Sequence that is closed.
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:SequenceClosed</td></tr>
+ * <tr><td>[Reason]</td><td>The Sequence is closed and cannot
accept new messages.</td></tr>
+ * <tr><td>[Detail]</td><td><wsrm:Identifier...>
xs:anyURI </wsrm:Identifier></td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode SEQUENCE_CLOSED = new RMFaultCode(
+ "SequenceClosed",
+ "The Sequence is closed and cannot accept new messages."
+ );
+
+ /**
+ * If an RM Destination requires the use of WS-RM,
+ * this fault is generated when it Receives an incoming
+ * message that did not use this protocol.
+ *
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:WSRMRequired</td></tr>
+ * <tr><td>[Reason]</td><td>The RM Destination requires the
use of WSRM</td></tr>
+ * <tr><td>[Detail]</td><td>xs:any</td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode WSRM_REQUIRED = new RMFaultCode(
+ "WSRMRequired",
+ "The RM Destination requires the use of WSRM"
+ );
+
+ /**
+ * Hidden constructor
+ * @param subcode the subcode
+ * @param reason message
+ */
+ private RMFaultCode(String subcode, String reason)
+ {
+ super();
+ this.subcode = subcode;
+ this.reason = reason;
+ }
+
+ /**
+ * Gets subcode
+ * @return subcode
+ */
+ public final String getSubcode()
+ {
+ return this.subcode;
+ }
+
+ /**
+ * Gets message
+ * @return message
+ */
+ public final String getReason()
+ {
+ return this.reason;
+ }
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultConstant.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultConstant.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultConstant.java 2008-02-28
11:38:08 UTC (rev 5841)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.wsrm;
+
+/**
+ * These constant are used in fault details map
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @see org.jboss.ws.extensions.wsrm.RMFault
+ * @see org.jboss.ws.extensions.wsrm.RMFaultCode
+ */
+public final class RMFaultConstant
+{
+
+ /**
+ * Forbidden constructor
+ */
+ private RMFaultConstant() {}
+
+ public static final String IDENTIFIER = "identifier";
+ public static final String ACKNOWLEDGEMENT = "acknowledgement";
+ public static final String MAX_MESSAGE_NUMBER = "maxMessageNumber";
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultConstant.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java 2008-02-28
11:02:04 UTC (rev 5840)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java 2008-02-28
11:38:08 UTC (rev 5841)
@@ -40,6 +40,9 @@
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.extensions.wsrm.RMAddressingConstants;
import org.jboss.ws.extensions.wsrm.RMConstant;
+import org.jboss.ws.extensions.wsrm.RMFault;
+import org.jboss.ws.extensions.wsrm.RMFaultCode;
+import org.jboss.ws.extensions.wsrm.RMFaultConstant;
import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
@@ -124,15 +127,20 @@
private static synchronized Map<String, Object> prepareResponseContext(Endpoint
ep, Invocation inv, String dataDir)
{
CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
- AddressingProperties addrProps =
(AddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
- if (addrProps == null)
- throw new IllegalStateException("WS-Addressing properties not found in
server request");
Map<String, Object> rmReqProps = (Map<String,
Object>)msgContext.get(RMConstant.REQUEST_CONTEXT);
msgContext.remove(RMConstant.REQUEST_CONTEXT);
if (rmReqProps == null)
- throw new IllegalStateException("WS-RM specific data not found in server
request");
+ {
+ throw new RMFault(RMFaultCode.WSRM_REQUIRED);
+ }
+ AddressingProperties addrProps =
(AddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
+ if (addrProps == null)
+ {
+ throw new IllegalStateException("WS-Addressing properties not found in
server request");
+ }
+
List<QName> protocolMessages = new LinkedList<QName>();
Map<String, Object> rmResponseContext = new HashMap<String, Object>();
rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES, protocolMessages);
@@ -155,10 +163,9 @@
RMCloseSequence payload =
(RMCloseSequence)data.get(rmConstants.getCloseSequenceQName());
String seqIdentifier = payload.getIdentifier();
sequence = RMStore.deserialize(dataDir, seqIdentifier, true);
- //sequence = RMHelper.getServerSequenceByInboundId(seqIdentifier, sequences);
if (sequence == null)
{
- throw new NotImplementedException("TODO: implement unknown sequence
fault" + seqIdentifier);
+ throw getUnknownSequenceFault(seqIdentifier);
}
sequence.close();
@@ -175,16 +182,24 @@
RMSequenceAcknowledgement payload =
(RMSequenceAcknowledgement)data.get(rmConstants.getSequenceAcknowledgementQName());
String seqIdentifier = payload.getIdentifier();
sequence = RMStore.deserialize(dataDir, seqIdentifier, false);
- //sequence = RMHelper.getServerSequenceByOutboundId(seqIdentifier, sequences);
if (sequence == null)
{
- throw new NotImplementedException("TODO: implement unknown sequence
fault" + seqIdentifier);
+ throw getUnknownSequenceFault(seqIdentifier);
}
for (RMSequenceAcknowledgement.RMAcknowledgementRange range :
payload.getAcknowledgementRanges())
{
for (long i = range.getLower(); i <= range.getUpper(); i++)
{
+ if (i > sequence.getLastMessageNumber())
+ {
+ // invalid acknowledgement - generating fault
+ RMStore.serialize(dataDir, sequence);
+ Map<String, Object> detailsMap = new HashMap<String,
Object>(2);
+ detailsMap.put(RMFaultConstant.ACKNOWLEDGEMENT, range);
+ throw new RMFault(RMFaultCode.INVALID_ACKNOWLEDGEMENT, new
HashMap<String, Object>(2));
+ }
+
sequence.addReceivedOutboundMessage(i);
}
}
@@ -201,7 +216,7 @@
//sequence = RMHelper.getServerSequenceByInboundId(seqIdentifier, sequences);
if (sequence == null)
{
- throw new NotImplementedException("TODO: implement unknown sequence
fault" + seqIdentifier);
+ throw getUnknownSequenceFault(seqIdentifier);
}
RMStore.serialize(dataDir, sequence); // TODO: serialization of terminated
sequence results in no file
@@ -228,7 +243,7 @@
//sequence = RMHelper.getServerSequenceByInboundId(seqIdentifier, sequences);
if (sequence == null)
{
- throw new NotImplementedException("TODO: implement unknown sequence
fault" + seqIdentifier);
+ throw getUnknownSequenceFault(seqIdentifier);
}
sequence.addReceivedInboundMessage(payload.getMessageNumber());
@@ -265,6 +280,13 @@
return rmResponseContext;
}
+ private static RMFault getUnknownSequenceFault(String sequenceId)
+ {
+ Map<String, Object> detailsMap = new HashMap<String, Object>(2);
+ detailsMap.put(RMFaultConstant.IDENTIFIER, sequenceId);
+ return new RMFault(RMFaultCode.UNKNOWN_SEQUENCE, detailsMap);
+ }
+
@Override
public final void invoke(Endpoint ep, Invocation inv) throws Exception
{
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMServerSequence.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMServerSequence.java 2008-02-28
11:02:04 UTC (rev 5840)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMServerSequence.java 2008-02-28
11:38:08 UTC (rev 5841)
@@ -28,12 +28,18 @@
import java.io.ObjectOutputStream;
import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Iterator;
import org.jboss.logging.Logger;
import org.jboss.ws.extensions.addressing.AddressingClientUtil;
+import org.jboss.ws.extensions.wsrm.RMFault;
+import org.jboss.ws.extensions.wsrm.RMFaultCode;
+import org.jboss.ws.extensions.wsrm.RMFaultConstant;
+import org.jboss.ws.extensions.wsrm.RMFaultConstants;
import org.jboss.ws.extensions.wsrm.RMSequence;
/**
@@ -126,8 +132,26 @@
public final void addReceivedInboundMessage(long messageId)
{
- this.receivedInboundMessages.add(messageId);
- logger.debug("Inbound Sequence: " + this.inboundId + ", received
message no. " + messageId);
+ if (this.closed)
+ {
+ Map<String, Object> detailsMap = new HashMap<String, Object>(2);
+ detailsMap.put(RMFaultConstant.IDENTIFIER, this.inboundId);
+ throw new RMFault(RMFaultCode.SEQUENCE_CLOSED, detailsMap);
+ }
+ else
+ {
+ if (messageId == Long.MAX_VALUE)
+ {
+ // maximum number achieved - generating fault
+ Map<String, Object> detailsMap = new HashMap<String, Object>(3);
+ detailsMap.put(RMFaultConstant.IDENTIFIER, this.inboundId);
+ detailsMap.put(RMFaultConstant.MAX_MESSAGE_NUMBER, this.messageNumber);
+ throw new RMFault(RMFaultCode.MESSAGE_NUMBER_ROLLOVER, detailsMap);
+ }
+
+ this.receivedInboundMessages.add(messageId);
+ logger.debug("Inbound Sequence: " + this.inboundId + ", received
message no. " + messageId);
+ }
}
public final void addReceivedOutboundMessage(long messageId)
@@ -144,7 +168,14 @@
public final long newMessageNumber()
{
- // no need for synchronization
+ if (this.messageNumber == Long.MAX_VALUE)
+ {
+ Map<String, Object> detailsMap = new HashMap<String, Object>(3);
+ detailsMap.put(RMFaultConstant.IDENTIFIER, this.outboundId);
+ detailsMap.put(RMFaultConstant.MAX_MESSAGE_NUMBER, this.messageNumber);
+ throw new RMFault(RMFaultCode.MESSAGE_NUMBER_ROLLOVER, detailsMap);
+ }
+
return ++this.messageNumber;
}
@@ -174,11 +205,21 @@
this.closed = true;
}
+ public boolean isClosed()
+ {
+ return this.closed;
+ }
+
public void terminate()
{
this.terminated = true;
}
+ public boolean isTerminated()
+ {
+ return this.terminated;
+ }
+
public byte[] toByteArray() throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMStore.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMStore.java 2008-02-28
11:02:04 UTC (rev 5840)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMStore.java 2008-02-28
11:38:08 UTC (rev 5841)
@@ -40,17 +40,27 @@
public static final void serialize(String dataDir, RMServerSequence seq)
{
File dir = new File(dataDir);
- dir.mkdirs();
- File file = new File(dir, seq.getId());
+ if (false == dir.exists())
+ {
+ dir.mkdirs();
+ }
+ File sequenceFile = new File(dir, seq.getId());
+ if (seq.isTerminated() && sequenceFile.exists())
+ {
+ // throw away terminated sequences
+ sequenceFile.delete();
+ return;
+ }
+
FileOutputStream fos = null;
try
{
- fos = new FileOutputStream(file);
+ fos = new FileOutputStream(sequenceFile);
fos.write(seq.toByteArray());
}
catch (IOException ioe)
{
- logger.error(ioe.getMessage(), ioe);
+ logger.error("Can't write sequence to file " +
sequenceFile.getName(), ioe);
}
finally
{
@@ -60,9 +70,9 @@
{
fos.close();
}
- catch (IOException ignore)
+ catch (IOException ioe)
{
- // do nothing
+ logger.error("Can't close sequence file " +
sequenceFile.getName(), ioe);
}
}
}
@@ -88,7 +98,7 @@
}
catch (IOException ioe)
{
- logger.error(ioe.getMessage(), ioe);
+ logger.error("Can't read sequence from file " +
sequences[i].getName(), ioe);
}
}