You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2010/02/28 11:49:35 UTC

svn commit: r917163 - in /incubator/wookie/trunk/src/org/apache/wookie/controller: Controller.java WidgetServicesController.java WidgetsController.java

Author: scottbw
Date: Sun Feb 28 10:49:34 2010
New Revision: 917163

URL: http://svn.apache.org/viewvc?rev=917163&view=rev
Log:
Made variable/parameter names consistent across and within controllers using "resourceId" instead of "resource_id","id","type","name" etc.

Modified:
    incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java
    incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetServicesController.java
    incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java

Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java?rev=917163&r1=917162&r2=917163&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java Sun Feb 28 10:49:34 2010
@@ -47,11 +47,11 @@
 	 */
 	protected void doGet(HttpServletRequest request, HttpServletResponse response)
 	throws ServletException, IOException {
-		String resource_id = locateRESTname(request);
+		String resourceId = getResourceId(request);
 		// If the resource identifier is not null, show otherwise index
-		if (resource_id != null && resource_id.length() > 0) {
+		if (resourceId != null && resourceId.length() > 0) {
 			try {
-				show(resource_id, request, response);
+				show(resourceId, request, response);
 				response.setStatus(HttpServletResponse.SC_OK);
 			} catch (ResourceNotFoundException e) {
 				response.sendError(HttpServletResponse.SC_NOT_FOUND);
@@ -74,9 +74,9 @@
 	@Override
 	protected void doDelete(HttpServletRequest request, HttpServletResponse response)
 			throws ServletException, IOException {
-		String id = locateRESTname(request);
+		String resourceId = getResourceId(request);
 		try {
-			remove(id,request);
+			remove(resourceId,request);
 			response.setStatus(HttpServletResponse.SC_OK);
 		} catch (ResourceNotFoundException e) {
 			response.sendError(HttpServletResponse.SC_NOT_FOUND);
@@ -93,9 +93,9 @@
 	@Override
 	protected void doPost(HttpServletRequest request, HttpServletResponse response)
 			throws ServletException, IOException {
-		String name = locateRESTname(request);
+		String resourceId = getResourceId(request);
 		try {
-			if (create(name, request)){
+			if (create(resourceId, request)){
 				response.setStatus(HttpServletResponse.SC_CREATED);
 			} else {
 				response.setStatus(HttpServletResponse.SC_OK);				
@@ -115,9 +115,9 @@
 	@Override
 	protected void doPut(HttpServletRequest request, HttpServletResponse response)
 			throws ServletException, IOException {
-		String id = locateRESTname(request);
+		String resourceId = getResourceId(request);
 		try {
-			update(id,request);
+			update(resourceId,request);
 			response.setStatus(HttpServletResponse.SC_OK);
 		} catch (ResourceNotFoundException e) {
 			response.sendError(HttpServletResponse.SC_NOT_FOUND);
@@ -136,7 +136,7 @@
 	 * @param request
 	 * @param response
 	 */
-	protected void show(String resource_id, HttpServletRequest request, HttpServletResponse response) throws ResourceNotFoundException, UnauthorizedAccessException,IOException{
+	protected void show(String resourceId, HttpServletRequest request, HttpServletResponse response) throws ResourceNotFoundException, UnauthorizedAccessException,IOException{
 	}
 
 	/**
@@ -155,7 +155,7 @@
 	 @return true if the resource was successfully created
 	 * @throws ResourceDuplicationException
 	 */
-	protected boolean create(String resource_id, HttpServletRequest request) throws ResourceDuplicationException, InvalidParametersException, UnauthorizedAccessException{return false;};
+	protected boolean create(String resourceId, HttpServletRequest request) throws ResourceDuplicationException, InvalidParametersException, UnauthorizedAccessException{return false;};
 	
 	/**
 	 * Delete a resource
@@ -163,7 +163,7 @@
 	 * @return true if the resource was successfully deleted
 	 * @throws ResourceNotFoundException
 	 */
-	protected boolean remove(String resource_id, HttpServletRequest request) throws ResourceNotFoundException,UnauthorizedAccessException,InvalidParametersException{return false;};
+	protected boolean remove(String resourceId, HttpServletRequest request) throws ResourceNotFoundException,UnauthorizedAccessException,InvalidParametersException{return false;};
 	
 	/**
 	 * Update a resource
@@ -171,7 +171,7 @@
 	 * @param request
 	 * @throws ResourceNotFoundException
 	 */
-	protected void update(String resource_id, HttpServletRequest request) throws ResourceNotFoundException,InvalidParametersException,UnauthorizedAccessException{};
+	protected void update(String resourceId, HttpServletRequest request) throws ResourceNotFoundException,InvalidParametersException,UnauthorizedAccessException{};
 	
 	// Utilities
 
@@ -181,7 +181,7 @@
 	 * @param the request
 	 * @return the resource name
 	 */
-	public static String locateRESTname(HttpServletRequest request) {
+	public static String getResourceId(HttpServletRequest request) {
 		String path = request.getPathInfo(); // may be null, plain name or name plus
 		// params
 		if (path == null) {

Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetServicesController.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetServicesController.java?rev=917163&r1=917162&r2=917163&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetServicesController.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetServicesController.java Sun Feb 28 10:49:34 2010
@@ -54,8 +54,8 @@
 	/* (non-Javadoc)
 	 * @see org.apache.wookie.controller.Controller#show(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 	 */
-	protected void show(String id, HttpServletRequest request, HttpServletResponse response) throws ResourceNotFoundException, IOException{
-		WidgetService ws = getWidgetService(id);
+	protected void show(String resourceId, HttpServletRequest request, HttpServletResponse response) throws ResourceNotFoundException, IOException{
+		WidgetService ws = getWidgetService(resourceId);
 		returnXml(WidgetServiceHelper.createXMLWidgetServiceDocument(ws, getLocalPath(request),getLocales(request)), response);
 	}
 
@@ -156,16 +156,16 @@
 	/**
 	 * Find a widget service matching the supplied parameter either as the
 	 * service name or service id
-	 * @param id
+	 * @param resourceId
 	 * @return
 	 */
-	private static WidgetService getWidgetService(String id) throws ResourceNotFoundException{
-		if (id == null) throw new ResourceNotFoundException();
+	private static WidgetService getWidgetService(String resourceId) throws ResourceNotFoundException{
+		if (resourceId == null) throw new ResourceNotFoundException();
 		WidgetService ws = null;
-		if (isAnInteger(id)){
-			ws = WidgetService.findById(Integer.valueOf(id));
+		if (isAnInteger(resourceId)){
+			ws = WidgetService.findById(Integer.valueOf(resourceId));
 		} else {
-			WidgetService[] wsa = WidgetService.findByValue("serviceName", id);
+			WidgetService[] wsa = WidgetService.findByValue("serviceName", resourceId);
 			if (wsa != null && wsa.length == 1) ws = wsa[0];
 		}
 		if (ws == null) throw new ResourceNotFoundException();

Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java?rev=917163&r1=917162&r2=917163&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java Sun Feb 28 10:49:34 2010
@@ -66,13 +66,13 @@
 	/* (non-Javadoc)
 	 * @see org.apache.wookie.controller.Controller#show(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 	 */
-	protected void show(String id, HttpServletRequest request,
+	protected void show(String resourceId, HttpServletRequest request,
 			HttpServletResponse response) throws ResourceNotFoundException, IOException {
-		if (!isAnInteger(id)){
-			index(id, request, response);
+		if (!isAnInteger(resourceId)){
+			index(resourceId, request, response);
 			return;
 		}
-		Widget widget = Widget.findById(Integer.valueOf(id));
+		Widget widget = Widget.findById(Integer.valueOf(resourceId));
 		if (widget == null) throw new ResourceNotFoundException();
 		returnXml(WidgetHelper.createXMLWidgetsDocument(widget, getLocalPath(request), getLocales(request)),response);
 	}	
@@ -88,13 +88,13 @@
 
 	/**
 	 * Returns a list of widgets
-	 * @param type
+	 * @param resourceId
 	 * @param request
 	 * @param response
 	 * @throws ServletException
 	 * @throws IOException
 	 */
-	private void index(String type, HttpServletRequest request,
+	private void index(String resourceId, HttpServletRequest request,
 			HttpServletResponse response) throws IOException {
 		Widget widget = null;
 		Widget[] widgets;
@@ -103,9 +103,9 @@
 		// If the request contains a String resource identifier
 		// such as "/chat", return all matching widgets
 		if (request.getParameter("all") != null
-				|| (type != null && !type.equals(""))) {
-			if (type != null && !type.equals("")) {
-				widgets = Widget.findByType(type);
+				|| (resourceId != null && !resourceId.equals(""))) {
+			if (resourceId != null && !resourceId.equals("")) {
+				widgets = Widget.findByType(resourceId);
 			} else {
 				widgets = Widget.findAll();
 			}