org.ibisph.mvc.controller.indicator
Class UnPublishIndicator

java.lang.Object
  extended by org.ibisph.mvc.controller.indicator.UnPublishIndicator
All Implemented Interfaces:
org.springframework.web.servlet.mvc.Controller

public class UnPublishIndicator
extends java.lang.Object
implements org.springframework.web.servlet.mvc.Controller

Unpublishes Indicator Profile and associated views.

Author:
Garth Braithwaite, STG

Field Summary
protected  Document documentDAO
           
protected  FileBackupFactory fileBackupFactory
           
protected  java.io.File publishedIndicatorsFile
           
protected  java.lang.String successReturnValue
           
protected  java.lang.String xmlPath
           
 
Constructor Summary
UnPublishIndicator()
           
 
Method Summary
 org.springframework.web.servlet.ModelAndView handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Controller method called by the Spring MVC framework to handle the unpublishing.
protected  java.lang.String removeIndicatorFromPublishedIndicators(java.lang.String indicatorName)
          Helper method that removes the specified published IP from the published indicator XML file.
protected  void sendError(javax.servlet.http.HttpServletResponse response, java.lang.Exception e, java.lang.String actionsReturnMessage)
          Helper to localize error sent to requester.
protected  void sendSuccess(javax.servlet.http.HttpServletResponse response, java.lang.String actionsReturnMessage)
          Helper to localize success message sent to requester.
 void setDocumentDAO(Document documentDAO)
          Sets the DAO object that will be used to save the XML content with.
 void setFileBackupFactory(FileBackupFactory fileBackupFactory)
          Optional file backup factory that provides a file backup used to backup the current XML file.
 void setPublishedIndicatorProfilesSystemID(SystemID publishedIndicatorProfilesSystemID)
          Sets System ID to the published indicator profiles XML file.
 void setSourceXMLPath(java.lang.String xmlPath)
          Sets the base path of where to remove the XML indicator profile files from.
 void setSuccessReturnValue(java.lang.String successReturnValue)
          Sets the string value that is returned to the requester.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlPath

protected java.lang.String xmlPath

fileBackupFactory

protected FileBackupFactory fileBackupFactory

documentDAO

protected Document documentDAO

publishedIndicatorsFile

protected java.io.File publishedIndicatorsFile

successReturnValue

protected java.lang.String successReturnValue
Constructor Detail

UnPublishIndicator

public UnPublishIndicator()
Method Detail

setSourceXMLPath

public void setSourceXMLPath(java.lang.String xmlPath)
Sets the base path of where to remove the XML indicator profile files from.

Parameters:
xmlPath - Complete file path with or without trailing slash.

setDocumentDAO

public void setDocumentDAO(Document documentDAO)
Sets the DAO object that will be used to save the XML content with. This simply keeps with the pluggable Spring framework.

Parameters:
documentDAO - Standard Document DAO used to save the XML document to disk.

setSuccessReturnValue

public void setSuccessReturnValue(java.lang.String successReturnValue)
Sets the string value that is returned to the requester.

Parameters:
successReturnValue - Value that is returned to the requester if the XML is valid and if the XML document was successfully saved to the specified filename/path.

setFileBackupFactory

public void setFileBackupFactory(FileBackupFactory fileBackupFactory)
Optional file backup factory that provides a file backup used to backup the current XML file.

Parameters:
fileBackupFactory - Provides a pluggable file backup used to backup the current XML file before the new content is published.

setPublishedIndicatorProfilesSystemID

public void setPublishedIndicatorProfilesSystemID(SystemID publishedIndicatorProfilesSystemID)
                                           throws java.net.URISyntaxException
Sets System ID to the published indicator profiles XML file.

Parameters:
publishedIndicatorProfilesSystemID - Complete system ID string for the published indicator profiles XML file.
Throws:
java.net.URISyntaxException

handleRequest

public org.springframework.web.servlet.ModelAndView handleRequest(javax.servlet.http.HttpServletRequest request,
                                                                  javax.servlet.http.HttpServletResponse response)
                                                           throws java.lang.Exception
Controller method called by the Spring MVC framework to handle the unpublishing. This method handles removing the indicator profile from the published profiles XML file - effectively unpublishing it and optionally calls the file backup file.

Specified by:
handleRequest in interface org.springframework.web.servlet.mvc.Controller
Parameters:
request - HTTP Servlet Request passed from the servlet.
response - HTTP Servlet Response passed from the servlet.
Returns:
null - Handles its own error and success view responses.
Throws:
java.lang.Exception

removeIndicatorFromPublishedIndicators

protected java.lang.String removeIndicatorFromPublishedIndicators(java.lang.String indicatorName)
                                                           throws java.lang.Exception
Helper method that removes the specified published IP from the published indicator XML file.

Parameters:
indicatorName - Name of the indicator profile to be removed.
Returns:
Message that describes actions taken and their outcome/status.
Throws:
java.lang.Exception

sendError

protected void sendError(javax.servlet.http.HttpServletResponse response,
                         java.lang.Exception e,
                         java.lang.String actionsReturnMessage)
                  throws java.lang.Exception
Helper to localize error sent to requester. This is also needed so that special errors can be implemented for sub classes.

Parameters:
response - Response object used for the request.
e - Optional exception associated with the error.
actionsReturnMessage - Optional error message to send back to requester.
Throws:
java.lang.Exception

sendSuccess

protected void sendSuccess(javax.servlet.http.HttpServletResponse response,
                           java.lang.String actionsReturnMessage)
                    throws java.lang.Exception
Helper to localize success message sent to requester. This is also needed so that special messages can be implemented for sub classes.

Parameters:
response - Response object used for the request.
actionsReturnMessage - Optional message to send back to requester.
Throws:
java.lang.Exception