Subversion Repositories SmartDukaan

Rev

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

Rev 11690 Rev 11808
Line 74... Line 74...
74
		}
74
		}
75
	}
75
	}
76
 
76
 
77
	// GET /index
77
	// GET /index
78
	public HttpHeaders index() throws Exception{
78
	public HttpHeaders index() throws Exception{
79
		if(isPrivatedealUser()){
79
		if(userinfo.isPrivateDealUser()){
80
			redirectUrl = "/private-deals/1";
80
			redirectUrl = "/private-deals/1";
81
		} else {
81
		} else {
82
			redirectUrl = "/";
82
			redirectUrl = "/";
83
		}
83
		}
84
		return new DefaultHttpHeaders("redirect");
84
		return new DefaultHttpHeaders("redirect");
Line 86... Line 86...
86
 
86
 
87
	// GET /show
87
	// GET /show
88
	@SuppressWarnings("unchecked")
88
	@SuppressWarnings("unchecked")
89
	public HttpHeaders show() {
89
	public HttpHeaders show() {
90
		try {
90
		try {
91
			if(isPrivatedealUser()){
91
			if(userinfo.isPrivateDealUser()){
92
 
92
 
93
				EhcacheWrapper<String, Object> showcasePageSnippetsCache = new EhcacheWrapper<String, Object>(
93
				EhcacheWrapper<String, Object> showcasePageSnippetsCache = new EhcacheWrapper<String, Object>(
94
						EhcacheWrapper.SHOWCASE_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
94
						EhcacheWrapper.SHOWCASE_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
95
				if(sourceId == -1){
95
				if(sourceId == -1){
96
					this.snippets = (List<String>)showcasePageSnippetsCache.get(SHOWCASE_PRIVATE_DEALS_CACHE_KEY + beginIndex);
96
					this.snippets = (List<String>)showcasePageSnippetsCache.get(SHOWCASE_PRIVATE_DEALS_CACHE_KEY + beginIndex);
Line 133... Line 133...
133
			}
133
			}
134
			else{
134
			else{
135
				redirectUrl = "/";
135
				redirectUrl = "/";
136
				return new DefaultHttpHeaders("redirect");
136
				return new DefaultHttpHeaders("redirect");
137
			}
137
			}
138
		} catch (TTransportException e) {
-
 
139
			log.error("Exception in User Service .", e);
-
 
140
			redirectUrl = "/";
-
 
141
			return new DefaultHttpHeaders("redirect");
-
 
142
		} catch (CacheException e) {
138
		} catch (CacheException e) {
143
			log.error("Cache Exception .", e);
139
			log.error("Cache Exception .", e);
144
			redirectUrl = "/";
140
			redirectUrl = "/";
145
			return new DefaultHttpHeaders("redirect");
141
			return new DefaultHttpHeaders("redirect");
146
		} catch (TException e) {
-
 
147
			log.error("Transport Exception in User Service .", e);
-
 
148
			redirectUrl = "/";
-
 
149
			return new DefaultHttpHeaders("redirect");
-
 
150
		}
142
		}
151
	}
143
	}
152
 
144
 
153
	private void setSnippets(){
145
	private void setSnippets(){
154
		this.snippets = new ArrayList<String>();
146
		this.snippets = new ArrayList<String>();
Line 198... Line 190...
198
		return redirectUrl;
190
		return redirectUrl;
199
	}
191
	}
200
	public boolean isUserLoggedIn()	{
192
	public boolean isUserLoggedIn()	{
201
		return userinfo.isLoggedIn();
193
		return userinfo.isLoggedIn();
202
	}
194
	}
203
	public boolean isPrivatedealUser() throws TTransportException, TException{
-
 
204
		try {
-
 
205
			uc = new UserClient().getClient();
-
 
206
			return uc.isPrivateDealUser(userinfo.getUserId());
-
 
207
		} catch (TTransportException e) {
-
 
208
			log.error("Unable to get user service client.", e);	
-
 
209
		}
-
 
210
		return false;
-
 
211
	}
-
 
212
}
195
}