org.apache.pluto.portlet.admin.services
Class DeployWarService

java.lang.Object
  extended by org.apache.pluto.portlet.admin.BaseAdminObject
      extended by org.apache.pluto.portlet.admin.services.DeployWarService

public class DeployWarService
extends BaseAdminObject

This is the service that does is called by DeployWarPortlet to do the work of deploying a portlet war.

Author:
Ken Atherton, Craig Doremus

Field Summary
static java.lang.String CLASS_NAME
           
static java.lang.String ERROR_NO_FILE
           
 
Constructor Summary
DeployWarService()
          Default constructor
DeployWarService(java.lang.String logId)
          Constructor taking a String used to identify a logging record.
 
Method Summary
(package private)  java.lang.String addRecordsToWebXml(java.lang.String context, java.lang.String contents, java.lang.String[] elements, java.util.List portletData)
          Adds ServletPortlet servlet or servlet-mapping records to web.xml for new portlet deployment.
 void addToPageReg(PageTO page)
          Add a new page record to the pageregistry.xml file.
 boolean addToPortletContexts(java.lang.String context)
           
private static java.lang.String[] arrayListToStringArray(java.util.ArrayList argStringArrayList)
           
private  java.util.ArrayList createDeploymentArgs(java.lang.String serverFileName, java.lang.String tempDir, ActionRequest request, boolean appExists, java.lang.String context)
          Creates arguments (parameters) for Deploy class that does the deployment.
private  java.io.InputStream extractFile(java.lang.String zipfilename, java.lang.String filename)
           
private  java.lang.String getRootFilename(char delimiter, java.lang.String pathName)
           
private  java.lang.String getSecurityRoleRefRecord(java.lang.String context, PortletDD portletData)
          Gets the web.xml security-role-ref record for PortletServlet from portlet.xml data
private  java.lang.String getServletMappingRecord(PortletDD portletData)
          Gets the web.xml servlet-mapping record for PortletServlet from portlet.xml data
private  java.lang.String getServletRecord(java.lang.String context, PortletDD portletData)
          Gets the web.xml servlet record for PortletServlet from portlet.xml data
static java.lang.String mapToEntrySetString(java.util.Map inputMap)
           
 boolean pageExists(java.lang.String pageName)
           
 java.lang.String processFileUpload(ActionRequest request, ActionResponse response)
          Does the work of this service to deploy a portlet war file.
 java.lang.String readFileToString(java.io.File file)
          Puts the contents of a file into a String.
 void savePageLayout(ActionRequest req)
           
 void setPage(ActionRequest req)
          Sets the page information into a PageTO object that is loaded into the session.
(package private)  void updateWebXml(java.lang.String context)
          Updates web.xml with servlet and servlet-mapping records related to PortletServlet.
 void writeStringToFile(java.io.File file, java.lang.String contents)
          Writes the contents of a file into a String.
 
Methods inherited from class org.apache.pluto.portlet.admin.BaseAdminObject
logDebug, logError, logError, logMethodEnd, logMethodEnd, logMethodStart, logParam, logParam, logParam, logVar, logVar, logVar, logWarn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_NO_FILE

public static final java.lang.String ERROR_NO_FILE
See Also:
Constant Field Values

CLASS_NAME

public static final java.lang.String CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

DeployWarService

public DeployWarService()
Default constructor


DeployWarService

public DeployWarService(java.lang.String logId)
Constructor taking a String used to identify a logging record.

Parameters:
logId -
Method Detail

processFileUpload

public java.lang.String processFileUpload(ActionRequest request,
                                          ActionResponse response)
Does the work of this service to deploy a portlet war file.

Parameters:
request - DeployWarService request object.
response - DeployWarService response object.

getRootFilename

private java.lang.String getRootFilename(char delimiter,
                                         java.lang.String pathName)

arrayListToStringArray

private static java.lang.String[] arrayListToStringArray(java.util.ArrayList argStringArrayList)

extractFile

private java.io.InputStream extractFile(java.lang.String zipfilename,
                                        java.lang.String filename)

createDeploymentArgs

private java.util.ArrayList createDeploymentArgs(java.lang.String serverFileName,
                                                 java.lang.String tempDir,
                                                 ActionRequest request,
                                                 boolean appExists,
                                                 java.lang.String context)
                                          throws java.lang.Exception
Creates arguments (parameters) for Deploy class that does the deployment.

Parameters:
serverFileName - The name of the war file to be deployed
tempDir - Full path to temp dir that holds the war file to be deployed
request - ActionRequest of the portlet.
appExists - True if this is a re-deployment, else false
Returns:
ArrayList of arguments
Throws:
java.lang.Exception
See Also:
Deploy.main(java.lang.String[])

mapToEntrySetString

public static java.lang.String mapToEntrySetString(java.util.Map inputMap)

setPage

public void setPage(ActionRequest req)
Sets the page information into a PageTO object that is loaded into the session.

Parameters:
req -

savePageLayout

public void savePageLayout(ActionRequest req)

addToPageReg

public void addToPageReg(PageTO page)
Add a new page record to the pageregistry.xml file.

Parameters:
page - The new page to add

addToPortletContexts

public boolean addToPortletContexts(java.lang.String context)

pageExists

public boolean pageExists(java.lang.String pageName)

readFileToString

public java.lang.String readFileToString(java.io.File file)
Puts the contents of a file into a String. This only works with text files.

Parameters:
file - The File to read
Returns:
A String containing the contents of the file.

writeStringToFile

public void writeStringToFile(java.io.File file,
                              java.lang.String contents)
Writes the contents of a file into a String.

Parameters:
file - Te File to write.
contents - The String to add to the file.

updateWebXml

void updateWebXml(java.lang.String context)
Updates web.xml with servlet and servlet-mapping records related to PortletServlet.

Parameters:
context -

addRecordsToWebXml

java.lang.String addRecordsToWebXml(java.lang.String context,
                                    java.lang.String contents,
                                    java.lang.String[] elements,
                                    java.util.List portletData)
Adds ServletPortlet servlet or servlet-mapping records to web.xml for new portlet deployment.

Parameters:
context - Web context or directory under webapps
contents - Current contents of the web.xml file
elements - Elements in web.xml to search for. If found, new elements will be inserted to the contents String. NOTE: First element (elements[0] signals the kind of record to add (servlet or servlet-mapping).
portletData - A List of PortletDD items containing the data of portlets to be deployed.

getServletRecord

private java.lang.String getServletRecord(java.lang.String context,
                                          PortletDD portletData)
Gets the web.xml servlet record for PortletServlet from portlet.xml data

Parameters:
context - Context name
portletData - Data from portlet.xml
Returns:

getSecurityRoleRefRecord

private java.lang.String getSecurityRoleRefRecord(java.lang.String context,
                                                  PortletDD portletData)
Gets the web.xml security-role-ref record for PortletServlet from portlet.xml data

Parameters:
context - Context name
portletData - Data from portlet.xml
Returns:

getServletMappingRecord

private java.lang.String getServletMappingRecord(PortletDD portletData)
Gets the web.xml servlet-mapping record for PortletServlet from portlet.xml data

Parameters:
context - Context name
portletData - Data from portlet.xml
Returns: