|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.plumtree.portalpages.admin.ptutilities.diagnostic.remotehosts.RemoteHostsModel
public class RemoteHostsModel
This model initializes the Server List with the Remote Hosts.
| 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 |
|---|
public static final java.lang.String STR_MVC_CLASS_NAME
public static final int SERVER_TYPE_REMOTE
public static final java.lang.String PROTOCOL_SEPARATOR
public static final int INITIAL_TIMEOUT
public static final int REPEAT_TIMEOUT
protected AActivitySpace m_asOwner
protected boolean m_bNeedRefresh
protected XPHashtable m_htInitialPortletStatus
| Constructor Detail |
|---|
public RemoteHostsModel()
| Method Detail |
|---|
public void ResetModel()
public void StartServerList()
public void PopulateServerList()
protected java.lang.Object[][] GetHostData()
public static java.lang.String GetHostName(java.lang.String _strURL)
_strURL - The full URL.
public boolean GetNeedsRefresh()
public void SetNeedsRefresh(boolean _bNeedsRefresh)
_bNeedsRefresh - True implies that the results page needs to
be refreshed.public static boolean AreAllServersOkay(SortedMetaDataListModel _model)
_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++;
}
}
protected void AddContentServerMarkup(java.lang.Object[][] _oData,
XPHashtable _hosts)
_oData - The data to add to the ServerStatusList.
protected void AddCollabServerMarkup(java.lang.Object[][] _oData,
XPHashtable _hosts)
_oData - The data to add to the ServerStatusList.
public static java.lang.String GetServerBaseURL(java.lang.Object[][] _filter,
AActivitySpace _asOwner)
_filter - The filter for the server (UUID)._asOwner - The parent AActivitySpace.
protected HTMLAnchor GetRemoteHostAnchor(java.lang.String _strName)
_strName - The name of the server.
public void Init(AActivitySpace parent)
IModel
Init in interface IModelparent - the parent Activity SpaceIModel.Init(com.plumtree.uiinfrastructure.activityspace.AActivitySpace)public void CleanupTempData()
IModel
CleanupTempData in interface IModelIModel.CleanupTempData()public void CleanupAllData()
IModel
CleanupAllData in interface IModelIModel.CleanupAllData()public java.lang.Object Create()
IManagedObject
Create in interface IManagedObjectIManagedObject.Create()public java.lang.String GetName()
IMVCObject
GetName in interface IMVCObjectIMVCObject.GetName()
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||