Author: asankaa Date: Thu Dec 4 08:50:16 2008 New Revision: 25814 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=25814
Log: fixing the CARBON-643 -invalid date formats Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java?rev=25814&r1=25813&r2=25814&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java Thu Dec 4 08:50:16 2008 @@ -188,20 +188,26 @@ if (log.isDebugEnabled()) { log.debug("ReNew request recived for SynapseSubscription ID : " + subscription.getId()); } - if (subscriptionManager.renewSubscription(subscription)) { - //send the response - if (log.isDebugEnabled()) { - log.debug("Sending ReNew response for SynapseSubscription ID : " + subscription.getId()); + String subID = subscription.getId(); + if (subID != null) { + if (subscriptionManager.renewSubscription(subscription)) { + //send the response + if (log.isDebugEnabled()) { + log.debug("Sending ReNew response for SynapseSubscription ID : " + subscription.getId()); + } + SOAPEnvelope soapEnvelope = messageBuilder.genRenewSubscriptionResponse(subscription); + RelatesTo relatesTo = new RelatesTo(subscription.getId()); + dispatchResponse(soapEnvelope, EventingConstants.WSE_RENEW_RESPONSE, relatesTo, mc, synCfg, synEnv); + } else { + // Send the Fault responce + if (log.isDebugEnabled()) { + log.debug("ReNew failed, sending fault response"); + } + SOAPEnvelope soapEnvelope = messageBuilder.genFaultResponse(EventingConstants.WSE_FAULT_CODE_RECEIVER, "wse:UnableToRenew", "", ""); + dispatchResponse(soapEnvelope, EventingConstants.WSA_FAULT, null, mc, synCfg, synEnv); } - SOAPEnvelope soapEnvelope = messageBuilder.genRenewSubscriptionResponse(subscription); - RelatesTo relatesTo = new RelatesTo(subscription.getId()); - dispatchResponse(soapEnvelope, EventingConstants.WSE_RENEW_RESPONSE, relatesTo, mc, synCfg, synEnv); } else { - // Send the Fault responce - if (log.isDebugEnabled()) { - log.debug("ReNew failed, sending fault response"); - } - SOAPEnvelope soapEnvelope = messageBuilder.genFaultResponse(EventingConstants.WSE_FAULT_CODE_RECEIVER, "wse:UnableToRenew", "", ""); + SOAPEnvelope soapEnvelope = messageBuilder.genFaultResponse(SubscriptionMessageBuilder.getErrorCode(), SubscriptionMessageBuilder.getErrorSubCode(), SubscriptionMessageBuilder.getErrorReason(), ""); dispatchResponse(soapEnvelope, EventingConstants.WSA_FAULT, null, mc, synCfg, synEnv); } } else { Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java?rev=25814&r1=25813&r2=25814&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java Thu Dec 4 08:50:16 2008 @@ -61,6 +61,7 @@ private static String errorSubCode = null; private static String errorReason = null; private static String errorCode = null; + /** * (01) <s12:Envelope * (02) xmlns:s12="http://www.w3.org/2003/05/soap-envelope" @@ -160,15 +161,18 @@ } OMElement expiryElem = elem.getFirstChildWithName(EXPIRES); if (expiryElem != null) { - Calendar calendarExpires = ConverterUtil.convertToDateTime(expiryElem.getText()); + Calendar calendarExpires = null; + try { + calendarExpires = ConverterUtil.convertToDateTime(expiryElem.getText()); + } catch (Exception e) { + log.error("Error converting the expiration date ," + e.toString()); + setExpirationFault(subscription); + } Calendar calendarNow = Calendar.getInstance(); if (calendarNow.before(calendarExpires)) { subscription.setExpires(calendarExpires); } else { - setErrorCode(EventingConstants.WSE_FAULT_CODE_SENDER); - setErrorSubCode("wse:InvalidExpirationTime"); - setErrorReason("The expiration time requested is invalid"); - subscription.setId(null); + setExpirationFault(subscription); } } } else { @@ -262,8 +266,22 @@ if (renewElem != null) { OMElement expiryElem = renewElem.getFirstChildWithName(EXPIRES); if (expiryElem != null) { - Calendar calendar = ConverterUtil.convertToDateTime(expiryElem.getText()); - subscription.setExpires(calendar); + Calendar calendarExpires=null; + try{ + calendarExpires = ConverterUtil.convertToDateTime(expiryElem.getText()); + }catch(Exception e){ + setExpirationFault(subscription); + } + Calendar calendarNow = Calendar.getInstance(); + if (calendarNow.before(calendarExpires)) { + subscription.setExpires(calendarExpires); + } else { + setExpirationFault(subscription); + } + + subscription.setExpires(calendarExpires); + } else { + setExpirationFault(subscription); } } return subscription; @@ -348,6 +366,13 @@ } public static void setErrorCode(String errorCodes) { - errorCode = errorCodes; + errorCode = errorCodes; + } + + private static void setExpirationFault(SynapseSubscription subscription) { + setErrorCode(EventingConstants.WSE_FAULT_CODE_SENDER); + setErrorSubCode("wse:InvalidExpirationTime"); + setErrorReason("The expiration time requested is invalid"); + subscription.setId(null); } } _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
