Subversion Repositories SmartDukaan

Rev

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

Rev 390 Rev 400
Line 2... Line 2...
2
 
2
 
3
import in.shop2020.serving.pages.PageContentKeys;
3
import in.shop2020.serving.pages.PageContentKeys;
4
import in.shop2020.serving.pages.PageEnum;
4
import in.shop2020.serving.pages.PageEnum;
5
import in.shop2020.serving.pages.PageManager;
5
import in.shop2020.serving.pages.PageManager;
6
 
6
 
-
 
7
import java.io.UnsupportedEncodingException;
7
import java.util.HashMap;
8
import java.util.HashMap;
8
import java.util.Map;
9
import java.util.Map;
9
import java.util.StringTokenizer;
10
import java.util.StringTokenizer;
10
 
11
 
-
 
12
import javax.servlet.http.HttpServletRequest;
-
 
13
 
-
 
14
import org.apache.juli.logging.Log;
-
 
15
import org.apache.juli.logging.LogFactory;
-
 
16
import org.apache.struts2.interceptor.ServletRequestAware;
11
import org.apache.struts2.rest.DefaultHttpHeaders;
17
import org.apache.struts2.rest.DefaultHttpHeaders;
12
import org.apache.struts2.rest.HttpHeaders;
18
import org.apache.struts2.rest.HttpHeaders;
13
 
19
 
14
 
20
 
15
 
21
 
16
 
22
 
17
public class RatingsController extends BaseController {
23
public class RatingsController extends BaseController implements ServletRequestAware{
18
	
24
	
-
 
25
	/**
-
 
26
	 * 
-
 
27
	 */
-
 
28
	private static Log log = LogFactory.getLog(MyresearchController.class);
-
 
29
	
-
 
30
	/**
-
 
31
	 * 
-
 
32
	 */
-
 
33
	private HttpServletRequest request;
-
 
34
 
19
	//id is in format entityID_ratingType_rating_userID  
35
	//id is in format entityID_ratingType_rating_userID  
20
	private String id;
36
	private String id;
21
	
37
	
22
	private String customer_id;
38
	private String customer_id;
23
	
39
	
24
	private String entity_id;
40
	private String entity_id;
25
	
41
	
26
	private String rating_type;
42
	private String rating_type;
27
	
43
	
28
	private String rating; 
44
	private String rating; 
-
 
45
 
-
 
46
    // GET /ratings
-
 
47
    public HttpHeaders index() throws UnsupportedEncodingException {
-
 
48
    	log.info("this.request=" + this.request);
29
	
49
	
-
 
50
        return new DefaultHttpHeaders("show")
-
 
51
            .disableCaching();
-
 
52
    }
30
	//Handle /ratings/{id}
53
	//Handle /ratings/{id}
31
	public HttpHeaders show(){
54
	public HttpHeaders show(){
32
		getFields();
55
		getFields();
33
		Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
56
		Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
34
		params.put(PageContentKeys.ENTITY_ID, entity_id);
57
		params.put(PageContentKeys.ENTITY_ID, entity_id);
-
 
58
		if(customer_id != null){
35
		params.put(PageContentKeys.CUSTOMER_ID, customer_id);
59
			params.put(PageContentKeys.CUSTOMER_ID, customer_id);
-
 
60
		}
36
		params.put(PageContentKeys.RATING_TYPE, rating_type);
61
		params.put(PageContentKeys.RATING_TYPE, rating_type);
37
		params.put(PageContentKeys.RATING, rating);
62
		params.put(PageContentKeys.RATING, rating);
38
		PageManager.getPageManager().getPageContents(PageEnum.RATINGS_PAGE, params);
63
		PageManager.getPageManager().getPageContents(PageEnum.RATINGS_PAGE, params);
39
		return new DefaultHttpHeaders("show");
64
		return new DefaultHttpHeaders("show");
40
	}
65
	}
Line 46... Line 71...
46
		rating =  tokenizer.nextToken();
71
		rating =  tokenizer.nextToken();
47
		if(tokenizer.hasMoreTokens()){
72
		if(tokenizer.hasMoreTokens()){
48
			customer_id = tokenizer.nextToken();
73
			customer_id = tokenizer.nextToken();
49
		}
74
		}
50
		else{
75
		else{
51
			customer_id = "";
76
			customer_id = null;
52
		}
77
		}
53
	}
78
	}
54
 
79
 
-
 
80
    public void setId(String id) {
-
 
81
        this.id = id;
-
 
82
    }
-
 
83
 
-
 
84
 
-
 
85
    @Override
-
 
86
	public void setServletRequest(HttpServletRequest request) {
-
 
87
		this.request = request;
55
	
88
	}
-
 
89
 
-
 
90
    
56
}
91
}