Subversion Repositories SmartDukaan

Rev

Rev 12616 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12616 Rev 16848
Line 180... Line 180...
180
            cookiesMap.put(cookie.getName(), cookie);
180
            cookiesMap.put(cookie.getName(), cookie);
181
        }
181
        }
182
    }
182
    }
183
 
183
 
184
    private void updateAffCookie() {
184
    private void updateAffCookie() {
185
        try {
185
		try {
-
 
186
			UserClient userContextServiceClient = new UserClient();
-
 
187
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
188
			long affiliateId = Long.parseLong(affId);
-
 
189
			Affiliate affiliate = userClient.getAffiliateById(affiliateId);
-
 
190
			if (affiliate != null) {
-
 
191
				affCookie = (Cookie) cookiesMap.get(AFF_COOKIE);
-
 
192
				if (affCookie != null) {
-
 
193
					Long.parseLong(affCookie.getValue());
186
            if(affId == null || affId.isEmpty()) {
194
					if (affiliateId == Long.parseLong(affCookie.getValue())) {
-
 
195
						return;
-
 
196
					}
-
 
197
				}
-
 
198
				// create new aff cookie if affCookie ==null or affiliateId() !=
-
 
199
				// affCookie.
-
 
200
				Cookie newAffCookie = new Cookie(AFF_COOKIE,String.valueOf(affiliateId));
-
 
201
				newAffCookie.setMaxAge(SECONDS_IN_DAY * 5);
-
 
202
				newAffCookie.setPath("/");
-
 
203
				if (!cookieDomain.isEmpty()) {
-
 
204
					newAffCookie.setDomain(cookieDomain);
-
 
205
				}
-
 
206
				cookiesMap.put(AFF_COOKIE, newAffCookie);
-
 
207
				response.addCookie(newAffCookie);
-
 
208
			}
-
 
209
		} catch (Exception e) {
187
                if (referer != null && !referer.isEmpty() && !referer.startsWith("http://www.saholic.com") && !referer.startsWith("http://www.shop2020.in")) {
210
            if (referer != null && !referer.isEmpty() && !referer.startsWith("http://www.saholic.com") && !referer.startsWith("http://www.shop2020.in")) {
188
                    Cookie affCookie = cookiesMap.get(AFF_COOKIE);
211
                Cookie affCookie = cookiesMap.get(AFF_COOKIE);
189
                    if(affCookie != null) {
212
                if(affCookie != null) {
190
                        affCookie.setDomain(cookieDomain);
213
                    affCookie.setDomain(cookieDomain);
191
                        affCookie.setPath("/");
214
                    affCookie.setPath("/");
192
                        affCookie.setValue("");
215
                    affCookie.setValue("");
193
                        affCookie.setMaxAge(0);
216
                    affCookie.setMaxAge(0);
194
                        response.addCookie(affCookie);
217
                    response.addCookie(affCookie);
195
                    }
-
 
196
                }
218
                }
197
                return;
-
 
198
            }
219
            }
199
            UserClient userContextServiceClient = new UserClient();
-
 
200
            in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
201
            long affiliateId = Long.parseLong(affId);
-
 
202
            Affiliate affiliate = userClient.getAffiliateById(affiliateId);
-
 
203
            if (affiliate != null) {
-
 
204
                affCookie = (Cookie) cookiesMap.get(AFF_COOKIE);
-
 
205
                if (affCookie != null) {
-
 
206
                    Long.parseLong(affCookie.getValue());
-
 
207
                    if (affiliateId == Long.parseLong(affCookie.getValue())) {
-
 
208
                        return;
-
 
209
                    }
-
 
210
                }
-
 
211
                // create new aff cookie if affCookie ==null or affiliateId() != affCookie.
-
 
212
                Cookie newAffCookie = new Cookie(AFF_COOKIE, String.valueOf(affiliateId));
-
 
213
                newAffCookie.setMaxAge(SECONDS_IN_DAY * 5);
-
 
214
                newAffCookie.setPath("/");
-
 
215
                if (!cookieDomain.isEmpty()) {
-
 
216
                    newAffCookie.setDomain(cookieDomain);
-
 
217
                }
-
 
218
                cookiesMap.put(AFF_COOKIE, newAffCookie);
-
 
219
                response.addCookie(newAffCookie);
-
 
220
            }
-
 
221
        } catch (Exception e) {
-
 
222
            log.error("Failed to update affcookie.", e);
220
			log.error("Failed to update affcookie.", e);
223
        }
221
		}
224
	}
222
	}
225
    
223
    
226
    private String getSource() {    
224
    private String getSource() {    
227
        String src = "";
225
        String src = "";
228
        
226