Subversion Repositories SmartDukaan

Rev

Rev 11943 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11943 Rev 12859
Line 14... Line 14...
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Date;
16
import java.util.Date;
17
import java.util.List;
17
import java.util.List;
18
 
18
 
-
 
19
import nl.captcha.Captcha;
-
 
20
 
19
import org.apache.commons.lang.StringUtils;
21
import org.apache.commons.lang.StringUtils;
20
import org.apache.log4j.Logger;
22
import org.apache.log4j.Logger;
21
import org.apache.thrift.TException;
23
import org.apache.thrift.TException;
22
import org.apache.thrift.transport.TTransportException;
24
import org.apache.thrift.transport.TTransportException;
23
 
25
 
Line 35... Line 37...
35
    private UserCommunicationType formType   = null;
37
    private UserCommunicationType formType   = null;
36
 
38
 
37
    List<Order>                   orders     = null;
39
    List<Order>                   orders     = null;
38
    List<LineItem>                products   = null;
40
    List<LineItem>                products   = null;
39
    List<Long>                    order_ids  = null;
41
    List<Long>                    order_ids  = null;
-
 
42
    
-
 
43
    private String failureMsg = "";
40
 
44
 
41
    public ContactUsController() {
45
    public ContactUsController() {
42
        super();
46
        super();
43
    }
47
    }
44
 
48
 
Line 97... Line 101...
97
        return "ajax";
101
        return "ajax";
98
    }
102
    }
99
 
103
 
100
    // POST /Save Communication
104
    // POST /Save Communication
101
    public String create() {
105
    public String create() {
-
 
106
        if(!verifyCaptcha()){
-
 
107
            setFailureMsg(UserMessage.INVALID_CAPTCHA);
-
 
108
            return "success";
-
 
109
        }
102
        // Default communication type OTHER
110
        // Default communication type OTHER
103
        long communicationType = 8;
111
        long communicationType = 8;
104
        long orderId = -1;
112
        long orderId = -1;
105
 
113
 
106
        try {
114
        try {
Line 195... Line 203...
195
    }
203
    }
196
 
204
 
197
    public String getSuccessMsg() {
205
    public String getSuccessMsg() {
198
        return UserMessage.USER_COMMUNICATION_SUCCESS;
206
        return UserMessage.USER_COMMUNICATION_SUCCESS;
199
    }
207
    }
-
 
208
    
-
 
209
    public void setFailureMsg(String failureMsg){
-
 
210
        this.failureMsg = failureMsg;
-
 
211
    }
-
 
212
    
-
 
213
    public String getFailureMsg(){
-
 
214
        return failureMsg;
-
 
215
    }
200
 
216
 
201
    private String getOrderIdSelector(List<Long> order_ids) {
217
    private String getOrderIdSelector(List<Long> order_ids) {
202
        StringBuilder html = new StringBuilder();
218
        StringBuilder html = new StringBuilder();
203
 
219
 
204
        if (order_ids == null || order_ids.size() == 0) {
220
        if (order_ids == null || order_ids.size() == 0) {
Line 250... Line 266...
250
    }
266
    }
251
 
267
 
252
    public String getIdsOfCancellableOrders() {
268
    public String getIdsOfCancellableOrders() {
253
        return getOrderIdSelector(this.order_ids);
269
        return getOrderIdSelector(this.order_ids);
254
    }
270
    }
-
 
271
    
-
 
272
    private boolean verifyCaptcha() {
-
 
273
        String cookieCaptchaAnswer = getCookie(Captcha.NAME, true, "saholic");
-
 
274
        String captchaReceived = (String) request.getParameter("captcha_response_field");
-
 
275
        
-
 
276
        if (captchaReceived.equalsIgnoreCase(cookieCaptchaAnswer)) {
-
 
277
            return true;
-
 
278
        } 
-
 
279
        else {
-
 
280
            return false;
-
 
281
        }
-
 
282
    }
255
}
283
}
256
284