@Controller
public class SampleController {
/* the @Roles() annotation will check for the entitlement based on the role combination defined in a config file called entitlementdefinition.properties */
/* the @WebAudit() annotation will tell how to audit based on config in logconfig.properties file */
/* the controllers will only support JSON as of now. if there is a need for XML data, then we will introduce content negotiation */
/**
* Accepts a POST request with query parameters
* @param1 used for ...
* @param2 used for ...
* @param3 is an optional parameter
* @param4 is an optional parameter, with a default value
* @return response which is a string after escaping it for html content
*/
@RequestMapping(value="/netx360wb/bf1", method=RequestMethod.POST)
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
public String myMethod(
@RequestParam("param1") String strVar1,
@RequestParam("param2") String strVal2,
@RequestParam(value="param3",required=false) String strVal3,
@RequestParam(value="param4",defaultValue="default", required=false) String strVal4
) {
/* Pack your request Object here */
/* Call your service */
return HtmlUtils.htmlEscape(response);
}
/**
* Accepts a POST request with query parameters
* @param1 used for ...
* @param2 used for ...
* @param3 is an optional parameter
* @param4 is an optional parameter, with a default value
* @return response which is a string after escaping it for html content
*/
@RequestMapping(value="/netx360wb/bf2", method=RequestMethod.POST)
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
@ResponseBody public JsonResponse myMethod(
@RequestParam("param1") String strVar1,
@RequestParam("param2") String strVal2,
@RequestParam(value="param3",required=false) String strVal3,
@RequestParam(value="param4",defaultValue="default", required=false) String strVal4
) {
}
/**
* Accepts a POST request with multipart/form-data content
* @param name the name of the file being uploaded
* @param file the binary file
* @return response message indicating success or failure
*/
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
@RequestMapping(value="postformdata",method=RequestMethod.POST,headers="Content-/form-data") public @ResponseBody String handleFormUpload(@RequestParam("description") String description,@RequestParam("file") MultipartFile file){
if (!file.isEmpty()) {
byte[] bytes=null;
try {
bytes=file.getBytes();
}
catch ( IOException e) {
logger.info("error processing uploaded file",e);
}
return "file upload received! Name:[" + description + "] Size:["+ bytes.length+ "]";
}
else {
return "file upload failed!";
}
}
/**
* Accepts a POST request with query parameters
* Packs the params in to an object directly, all checks need to be done at service layer
*
*
*/
@ResponseBody
@RequestMapping(value="/netx360wb/bf1", method=RequestMethod.POST)
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
public JsonResponse myMethod(@RequestBody MyRequestObject myRequest){
/* Call your service */
return HtmlUtils.htmlEscape(response);
}
}
---------------------------------------------
PageController(HTTPRequest){
CheckEntitlement();
CreateView(); /* Merge default config and preferences */
RenderView();
}
page.jsp
{
view layout
entitlment check wherever necessary
tiles templating
}
/* Uses content negotiator */
DataController(HTTPRequest){
CheckEntitlement();
CallDataService();
SendRespData();
}
/* Not remotely invocable */
DataService(VO){
RequestHelper();
CallBEService();
ResponseHelper();
ApplyDataPreferences();
}
PreferencesService(){
CreateView(){
GetGBPPreference(); /* read once and store in session */
ReadDefaultConfig(Component); /* Component Config from XML */
GetPersonalizationData(ComponentName); /* component specific customization data from DB
*/
}
}
------------------------------
public class SampleController {
/* the @Roles() annotation will check for the entitlement based on the role combination defined in a config file called entitlementdefinition.properties */
/* the @WebAudit() annotation will tell how to audit based on config in logconfig.properties file */
/* the controllers will only support JSON as of now. if there is a need for XML data, then we will introduce content negotiation */
/**
* Accepts a POST request with query parameters
* @param1 used for ...
* @param2 used for ...
* @param3 is an optional parameter
* @param4 is an optional parameter, with a default value
* @return response which is a string after escaping it for html content
*/
@RequestMapping(value="/netx360wb/bf1", method=RequestMethod.POST)
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
public String myMethod(
@RequestParam("param1") String strVar1,
@RequestParam("param2") String strVal2,
@RequestParam(value="param3",required=false) String strVal3,
@RequestParam(value="param4",defaultValue="default", required=false) String strVal4
) {
/* Pack your request Object here */
/* Call your service */
return HtmlUtils.htmlEscape(response);
}
/**
* Accepts a POST request with query parameters
* @param1 used for ...
* @param2 used for ...
* @param3 is an optional parameter
* @param4 is an optional parameter, with a default value
* @return response which is a string after escaping it for html content
*/
@RequestMapping(value="/netx360wb/bf2", method=RequestMethod.POST)
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
@ResponseBody public JsonResponse myMethod(
@RequestParam("param1") String strVar1,
@RequestParam("param2") String strVal2,
@RequestParam(value="param3",required=false) String strVal3,
@RequestParam(value="param4",defaultValue="default", required=false) String strVal4
) {
}
/**
* Accepts a POST request with multipart/form-data content
* @param name the name of the file being uploaded
* @param file the binary file
* @return response message indicating success or failure
*/
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
@RequestMapping(value="postformdata",method=RequestMethod.POST,headers="Content-/form-data") public @ResponseBody String handleFormUpload(@RequestParam("description") String description,@RequestParam("file") MultipartFile file){
if (!file.isEmpty()) {
byte[] bytes=null;
try {
bytes=file.getBytes();
}
catch ( IOException e) {
logger.info("error processing uploaded file",e);
}
return "file upload received! Name:[" + description + "] Size:["+ bytes.length+ "]";
}
else {
return "file upload failed!";
}
}
/**
* Accepts a POST request with query parameters
* Packs the params in to an object directly, all checks need to be done at service layer
*
*
*/
@ResponseBody
@RequestMapping(value="/netx360wb/bf1", method=RequestMethod.POST)
@Roles("netx360wb.rolenameFromConfig")
@WebAudit("netx360wb.logConfig")
public JsonResponse myMethod(@RequestBody MyRequestObject myRequest){
/* Call your service */
return HtmlUtils.htmlEscape(response);
}
}
---------------------------------------------
PageController(HTTPRequest){
CheckEntitlement();
CreateView(); /* Merge default config and preferences */
RenderView();
}
page.jsp
{
view layout
entitlment check wherever necessary
tiles templating
}
/* Uses content negotiator */
DataController(HTTPRequest){
CheckEntitlement();
CallDataService();
SendRespData();
}
/* Not remotely invocable */
DataService(VO){
RequestHelper();
CallBEService();
ResponseHelper();
ApplyDataPreferences();
}
PreferencesService(){
CreateView(){
GetGBPPreference(); /* read once and store in session */
ReadDefaultConfig(Component); /* Component Config from XML */
GetPersonalizationData(ComponentName); /* component specific customization data from DB
*/
}
}
------------------------------