-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCRaterController.java
More file actions
68 lines (61 loc) · 2.81 KB
/
Copy pathCRaterController.java
File metadata and controls
68 lines (61 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Copyright (c) 2008-2021 Regents of the University of California (Regents).
* Created by WISE, Graduate School of Education, University of California, Berkeley.
*
* This software is distributed under the GNU General Public License, v3,
* or (at your option) any later version.
*
* Permission is hereby granted, without written agreement and without license
* or royalty fees, to use, copy, modify, and distribute this software and its
* documentation for any purpose, provided that the above copyright notice and
* the following two paragraphs appear in all copies of this software.
*
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
* HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
* SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
* REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.wise.vle.web;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wise.vle.domain.webservice.crater.CRaterVerificationRequest;
import org.wise.portal.service.ping.CRaterPingService;
import org.wise.vle.domain.webservice.crater.CRaterPingRequest;
import org.wise.vle.domain.webservice.crater.CRaterScoringRequest;
import org.wise.vle.domain.webservice.crater.CRaterService;
@RestController
@RequestMapping("/api/c-rater")
public class CRaterController {
@Autowired
private CRaterService cRaterService;
@Autowired
private CRaterPingService cRaterPingService;
@GetMapping("/verify")
String verifyItemId(CRaterVerificationRequest request) throws JSONException {
return cRaterService.getCRaterResponse(request);
}
@PostMapping("/score")
String scoreItem(@RequestBody CRaterScoringRequest request) throws JSONException {
return cRaterService.getCRaterResponse(request);
}
@PostMapping("/ping")
public String pingItem(@RequestBody CRaterPingRequest ping) throws JSONException {
String itemId = ping.getItemId();
if (!this.cRaterPingService.hasPingedItem(itemId)) {
this.cRaterPingService.cachePingedItem(itemId, 280);
return this.cRaterService.getCRaterResponse(ping);
}
return "";
}
}