com.plumtree.portalpages.admin.ptutilities.diagnostic.remotehosts
Class RemoteHostsModel

java.lang.Object
  extended by com.plumtree.portalpages.admin.ptutilities.diagnostic.remotehosts.RemoteHostsModel
All Implemented Interfaces:
IManagedObject, IModel, IModelRO, IMVCObject

public class RemoteHostsModel
extends java.lang.Object
implements IModel, IModelRO

This model initializes the Server List with the Remote Hosts.

Author:
DonH

Field Summary
static int INITIAL_TIMEOUT
           
protected  AActivitySpace m_asOwner
           
protected  boolean m_bNeedRefresh
           
protected  XPHashtable m_htInitialPortletStatus
           
static java.lang.String PROTOCOL_SEPARATOR
           
static int REPEAT_TIMEOUT
           
static int SERVER_TYPE_REMOTE
           
static java.lang.String STR_MVC_CLASS_NAME
          Class name for the activity space
 
Constructor Summary
RemoteHostsModel()
           
 
Method Summary
protected  void AddCollabServerMarkup(java.lang.Object[][] _oData, XPHashtable _hosts)
          This helper method determines which host is running Collaboration Server and adds descriptive text to it.
protected  void AddContentServerMarkup(java.lang.Object[][] _oData, XPHashtable _hosts)
          This helper method determines which host is running Content Server and adds descriptive text to it.
static boolean AreAllServersOkay(SortedMetaDataListModel _model)
          OA: Deprecated: Using ServerStatusHelper instead This method filles in the data array with String representations of int status codes, optional messages (disabled, timeout, etc..), and error messages (404, server not found, etc...).
 void CleanupAllData()
          This method is called when an ActivitySpace is removed from the cache.
 void CleanupTempData()
          This method is called at the end of every HTTP request by the Interpreter.
 java.lang.Object Create()
          This method is used by the ASManager to return new instances of managed objects.
protected  java.lang.Object[][] GetHostData()
          Helper method to generate the data for the Remote Hosts.
static java.lang.String GetHostName(java.lang.String _strURL)
          This helper method strips the URL down to just the host name (and possibly port number).
 java.lang.String GetName()
          Return the name of the MVC object.
 boolean GetNeedsRefresh()
          This method returns whether or not the results page needs refreshing because a host had connection problems.
protected  HTMLAnchor GetRemoteHostAnchor(java.lang.String _strName)
          Helper method that creates an HTML Anchor to a pop-up page viewing remote host details.
static java.lang.String GetServerBaseURL(java.lang.Object[][] _filter, AActivitySpace _asOwner)
          This helper method gets the base URL of the requested server.
 void Init(AActivitySpace parent)
          This method initializes the model.
 void PopulateServerList()
          Helper method to populate the Server List.
 void ResetModel()
          This method returns the model to it's original state before any tests have been run / lists initialized.
 void SetNeedsRefresh(boolean _bNeedsRefresh)
          This method sets whether or not the results page needs refreshing because a host had connection problems.
 void StartServerList()
          Helper method to start the Server List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STR_MVC_CLASS_NAME

public static final java.lang.String STR_MVC_CLASS_NAME
Class name for the activity space

See Also:
Constant Field Values

SERVER_TYPE_REMOTE

public static final int SERVER_TYPE_REMOTE
See Also:
Constant Field Values

PROTOCOL_SEPARATOR

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

INITIAL_TIMEOUT

public static final int INITIAL_TIMEOUT
See Also:
Constant Field Values

REPEAT_TIMEOUT

public static final int REPEAT_TIMEOUT
See Also:
Constant Field Values

m_asOwner

protected AActivitySpace m_asOwner

m_bNeedRefresh

protected boolean m_bNeedRefresh

m_htInitialPortletStatus

protected XPHashtable m_htInitialPortletStatus
Constructor Detail

RemoteHostsModel

public RemoteHostsModel()
Method Detail

ResetModel

public void ResetModel()
This method returns the model to it's original state before any tests have been run / lists initialized.


StartServerList

public void StartServerList()
Helper method to start the Server List.


PopulateServerList

public void PopulateServerList()
Helper method to populate the Server List.


GetHostData

protected java.lang.Object[][] GetHostData()
Helper method to generate the data for the Remote Hosts.

Returns:
Object[][] The Remote Host data.

GetHostName

public static java.lang.String GetHostName(java.lang.String _strURL)
This helper method strips the URL down to just the host name (and possibly port number).

Parameters:
_strURL - The full URL.
Returns:
String The host name.

GetNeedsRefresh

public boolean GetNeedsRefresh()
This method returns whether or not the results page needs refreshing because a host had connection problems.

Returns:
True implies that the results page needs to be refreshed.

SetNeedsRefresh

public void SetNeedsRefresh(boolean _bNeedsRefresh)
This method sets whether or not the results page needs refreshing because a host had connection problems.

Parameters:
_bNeedsRefresh - True implies that the results page needs to be refreshed.

AreAllServersOkay

public static boolean AreAllServersOkay(SortedMetaDataListModel _model)
OA: Deprecated: Using ServerStatusHelper instead This method filles in the data array with String representations of int status codes, optional messages (disabled, timeout, etc..), and error messages (404, server not found, etc...). The optional messages and error messages can be null. The 2 arrays must have the same length.

Parameters:
_htPortletIDs - The ids of the portlets to check.
_oData - Filled in with int status codes, optional messages, and errors. protected void SetPortletStatus(XPHashtable _htPortletIDs, Object[][] _oData) { int[] portletIDs = new int[_htPortletIDs.GetSize()]; IXPEnumerator hostNames = _htPortletIDs.GetKeys(); int i = 0; while (hostNames.MoveNext()) { portletIDs[i] = XPConvert.ToInteger(_htPortletIDs.GetElement(hostNames.GetCurrent())); i++; } // Get the temporary page used just for the diagnostic page // to query for the portlet content IPTPage diagPage = (IPTPage) ((IPTSession) m_asOwner.GetUserSession()). GetPages().Open(PT_INTRINSICS.PT_PAGE_DIAGNOSTIC, false); // Add the portlets to the page diagPage.AssignPortlets(portletIDs, 0); // Query for the page content // Create Application Data Object // 0 means not a community page IPTState state = AppDataObject.GetAppDataObject(0, PT_INTRINSICS.PT_PAGE_DIAGNOSTIC, "uri", m_asOwner, false); // Set the portlet timeout for this request to the appropriate value. int nStatusTimeout = INITIAL_TIMEOUT; if (m_bNeedRefresh) { nStatusTimeout = REPEAT_TIMEOUT; m_bNeedRefresh = false; } state.Add(PlumtreeExtensibility.PT_PORTLET_TIMEOUT_KEY, nStatusTimeout, 0, true); state.Add(PlumtreeExtensibility.PT_RETURN_URI_KEY, m_asOwner.GetCurrentNormalizedBaseURL(), 0, true); // Use Diagnostic mode here instead of runtime or preview mode, because // runtime mode will get cached content if there are errors with the portlets. // That would mask host failures forever. Preview mode does not use // the cached content if there is an error, but it does still use it normally. // Preview mode also ignores the portlet timeout. IPTMyPortalGadgetContent content = diagPage.QueryPortletContent(0, PT_INTRINSICS.PT_PAGE_DIAGNOSTIC, state, "", PT_GADGET_MODES.PT_GADGETMODES_DIAGNOSTIC, true); i = 0; hostNames = _htPortletIDs.GetKeys(); // Check the status of each portlet while (hostNames.MoveNext()) { // Initialize with null _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = null; _oData[ServerStatusListView.SERVER_STATUS_ERROR][i] = null; int nPortletID = XPConvert.ToInteger(_htPortletIDs.GetElement(hostNames.GetCurrent())); Object[][] objArrMarkup = null; // TODO: This code should be refactored so it can be reused by the // HostServicesModel as well, instead of duplicating code. try { objArrMarkup = content.GetContent(i); } catch (Exception e) { if( e instanceof PTException ) { // TODO: This switch statement shouldn't be necessary, but // some kinds of portlets throw exceptions (gadget_runtime_error) // and some use the error reporting array below. switch ( ((PTException) e).GetErrorCode() ) { case PT_RESULTCODES.PT_E_GADGET_TIMEOUT: { // Portlet timed out, might just be slow _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_RED); // "Timeout" _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3104, ResourceConstants.PORTALADMINMSGS); m_bNeedRefresh = true; break; } case PT_RESULTCODES.PT_E_GADGET_RUNTIME_ERROR: { // Portlet had a runtime error // This could be because the machine is down _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_RED); // This could be an intermittent problem. Try again with a longer timeout m_bNeedRefresh = true; break; } case PT_RESULTCODES.PT_E_GADGET_HTTP_ERROR_CODE: { // Portlet had an HTTP error // This could be because the machine is down _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_RED); // This could be an intermittent problem. Try again with a longer timeout m_bNeedRefresh = true; break; } case PT_RESULTCODES.PT_E_MYPORTAL_GADGETDISABLED: { // We display disabled WebServices for info purposes. _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // "Disabled" _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3105, ResourceConstants.PORTALADMINMSGS); break; } default: { // Inconclusive _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // Unknown _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3135, ResourceConstants.PORTALADMINMSGS); m_bNeedRefresh = true; } } } else { // Inconclusive _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_RED); // Offline _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(1443, ResourceConstants.PORTALADMINMSGS); m_bNeedRefresh = true; // TODO: Should we log this exception? } objArrMarkup = null; } if (objArrMarkup != null) { int nlength = objArrMarkup.length; if (objArrMarkup.length == PT_MARKUP_ARRAY_COLS.PT_MARKUP_ARRAY_NUM_COLS) { if (!GatewayUtils.IsErrorContentArray(objArrMarkup)) { _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_GREEN); // Online _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(1442, ResourceConstants.PORTALADMINMSGS); } else { int iErrorCode = GatewayUtils.GetErrorCode(objArrMarkup); // TODO: Do we need to check this? // if the response was received, need to make room in the array for response status, header, body // boolean bResponseReceived = GatewayUtils.ResponseReceivedForErrors(objArrMarkup); switch (iErrorCode) { case PT_RESULTCODES.PT_E_GADGET_TIMEOUT: { // Portlet timed out, might just be slow _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // "Timeout" _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3104, ResourceConstants.PORTALADMINMSGS); m_bNeedRefresh = true; break; } case PT_RESULTCODES.PT_E_GADGET_RUNTIME_ERROR: { // Portlet had a runtime error // This could be because the machine is down _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_RED); String strStatus = GatewayUtils.GetResponseStatus(objArrMarkup); if (strStatus != null) { // "HTTP {0} error" _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = XPResourceManager.FormatMessage( m_asOwner.GetString(3106, ResourceConstants.PORTALADMINMSGS), strStatus); } // We do not add the error message here, because it // is available on the detailed web services page. // This could be an intermittent problem. Try again with a longer timeout m_bNeedRefresh = true; break; } case PT_RESULTCODES.PT_E_GADGET_HTTP_ERROR_CODE: { // Portlet had an http error // This could be because the machine is down _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_RED); String strStatus = GatewayUtils.GetResponseStatus(objArrMarkup); if (strStatus != null) { // "HTTP {0} error" _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = XPResourceManager.FormatMessage( m_asOwner.GetString(3106, ResourceConstants.PORTALADMINMSGS), strStatus); } // We do not add the error message here, because it // is available on the detailed web services page. // This could be an intermittent problem. Try again with a longer timeout m_bNeedRefresh = true; break; } case PT_RESULTCODES.PT_E_MYPORTAL_GADGETDISABLED: { // We display disabled WebServices for info purposes. _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // "Disabled" _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3105, ResourceConstants.PORTALADMINMSGS); break; } default: { // Inconclusive _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // Unknown _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3135, ResourceConstants.PORTALADMINMSGS); m_bNeedRefresh = true; break; } } } } else { // Nothing in the markup - unclear what this means. _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // Unknown _oData[ServerStatusListView.SERVER_STATUS_MSG][i] = m_asOwner.GetString(3135, ResourceConstants.PORTALADMINMSGS); m_bNeedRefresh = true; } } Object oInitialStatus = m_htInitialPortletStatus.GetElement(new Integer(nPortletID)); if (null != oInitialStatus) { if (XPConvert.ToInteger(oInitialStatus) == ServerStatusListView.STATUS_RED) { if (XPConvert.ToInteger(_oData[ServerStatusListView.SERVER_STATUS][i]) == ServerStatusListView.STATUS_GREEN) { // If we were red, but are now green, that still indicates a problem. // Set to yellow _oData[ServerStatusListView.SERVER_STATUS][i] = XPConvert.ToString(ServerStatusListView.STATUS_YELLOW); // "Failed on first attempt." _oData[ServerStatusListView.SERVER_STATUS_ERROR][i] = m_asOwner.GetString(3107, ResourceConstants.PORTALADMINMSGS); } } } else { // Store the initial status for next time. m_htInitialPortletStatus.PutElement(new Integer(nPortletID), _oData[ServerStatusListView.SERVER_STATUS][i]); } i++; } }

AddContentServerMarkup

protected void AddContentServerMarkup(java.lang.Object[][] _oData,
                                      XPHashtable _hosts)
This helper method determines which host is running Content Server and adds descriptive text to it.

Parameters:
_oData - The data to add to the ServerStatusList.

AddCollabServerMarkup

protected void AddCollabServerMarkup(java.lang.Object[][] _oData,
                                     XPHashtable _hosts)
This helper method determines which host is running Collaboration Server and adds descriptive text to it.

Parameters:
_oData - The data to add to the ServerStatusList.

GetServerBaseURL

public static java.lang.String GetServerBaseURL(java.lang.Object[][] _filter,
                                                AActivitySpace _asOwner)
This helper method gets the base URL of the requested server.

Parameters:
_filter - The filter for the server (UUID).
_asOwner - The parent AActivitySpace.
Returns:
String The base URL of the requested server.

GetRemoteHostAnchor

protected HTMLAnchor GetRemoteHostAnchor(java.lang.String _strName)
Helper method that creates an HTML Anchor to a pop-up page viewing remote host details.

Parameters:
_strName - The name of the server.
Returns:
HTMLAnchor The HTML Anchor.

Init

public void Init(AActivitySpace parent)
Description copied from interface: IModel
This method initializes the model. This is called automatically when AActivitySpace.RegisterModel() is called.

Specified by:
Init in interface IModel
Parameters:
parent - the parent Activity Space
See Also:
IModel.Init(com.plumtree.uiinfrastructure.activityspace.AActivitySpace)

CleanupTempData

public void CleanupTempData()
Description copied from interface: IModel
This method is called at the end of every HTTP request by the Interpreter. The Interpreter calls AActivitySpace.CleanupTempData(), which calls this method on all IModels registered using AActivitySpace.RegisterModel(). This method is intended for cleaning up temporary data that is only used for the lifetime of a single request, like DB query results.

Specified by:
CleanupTempData in interface IModel
See Also:
IModel.CleanupTempData()

CleanupAllData

public void CleanupAllData()
Description copied from interface: IModel
This method is called when an ActivitySpace is removed from the cache. The Interpreter calls AActivitySpace.CleanupAllData(), which calls this method on all IModels registered using AActivitySpace.RegisterModel(). This method is intended for releasing data stored in the server when the activity space is no longer needed, such as search objects that need to be maintained as long as the user is clicking through the search, but should be freed when the space can no longer be used. This can be used to prevent Java references to COM memory from hanging around in the long lived Java heap without cleaning up the underlying COM memory. The Java reference will still stay in the long lived heap until it gets garbage collected (which could be a while), but the COM memory should get released here. This method will not be called if an HTTPSession times out. CleanupTempData will be called before CleanupAllData.

Specified by:
CleanupAllData in interface IModel
See Also:
IModel.CleanupAllData()

Create

public java.lang.Object Create()
Description copied from interface: IManagedObject
This method is used by the ASManager to return new instances of managed objects.

Specified by:
Create in interface IManagedObject
Returns:
A new instance of the managed class (i.e. return new Foo();)
See Also:
IManagedObject.Create()

GetName

public java.lang.String GetName()
Description copied from interface: IMVCObject
Return the name of the MVC object.

Specified by:
GetName in interface IMVCObject
Returns:
the name of the object.
See Also:
IMVCObject.GetName()



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.