Skip to content

Commit

Permalink
Page Actions: Add UserSession Info to Error and Warn logging
Browse files Browse the repository at this point in the history
Add logging of authUserId, username when project id not parsable or when
get exception caught at top level in Page Action.
  • Loading branch information
danjasuw committed May 12, 2020
1 parent 682a14e commit a7d26a3
Show file tree
Hide file tree
Showing 11 changed files with 590 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,31 @@
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.yeastrc.xlink.www.dao.SearchDAO;
import org.yeastrc.xlink.www.objects.ProteinSequenceVersionObject;
import org.yeastrc.xlink.www.dto.SearchDTO;
import org.yeastrc.xlink.www.linked_positions.CrosslinkLinkedPositions;
import org.yeastrc.xlink.www.linked_positions.LinkedPositions_FilterExcludeLinksWith_Param;
import org.yeastrc.xlink.www.linked_positions.LooplinkLinkedPositions;
import org.yeastrc.xlink.www.linked_positions.UnlinkedDimerPeptideProteinMapping;
import org.yeastrc.xlink.www.linked_positions.UnlinkedDimerPeptideProteinMapping.UnlinkedDimerPeptideProteinMappingResult;
import org.yeastrc.xlink.www.nav_links_image_structure.PopulateRequestDataForImageAndStructureAndQC_NavLinks;
import org.yeastrc.xlink.www.access_control.result_objects.WebSessionAuthAccessLevel;
import org.yeastrc.xlink.www.objects.MergedSearchProtein;
import org.yeastrc.xlink.www.objects.SearchProtein;
import org.yeastrc.xlink.www.objects.SearchProteinCrosslink;
import org.yeastrc.xlink.www.objects.SearchProteinCrosslinkWrapper;
import org.yeastrc.xlink.www.objects.SearchProteinDimer;
import org.yeastrc.xlink.www.objects.SearchProteinDimerWrapper;
import org.yeastrc.xlink.www.objects.SearchProteinLooplink;
import org.yeastrc.xlink.www.objects.SearchProteinLooplinkWrapper;
import org.yeastrc.xlink.www.objects.SearchProteinUnlinked;
import org.yeastrc.xlink.www.objects.SearchProteinUnlinkedWrapper;
import org.yeastrc.xlink.www.searcher.ProjectIdsForProjectSearchIdsSearcher;
import org.yeastrc.xlink.searcher_psm_peptide_cutoff_objects.SearcherCutoffValuesRootLevel;
import org.yeastrc.xlink.searcher_psm_peptide_cutoff_objects.SearcherCutoffValuesSearchLevel;
import org.yeastrc.xlink.www.user_session_management.UserSession;
import org.yeastrc.xlink.www.user_session_management.UserSessionManager;
import org.yeastrc.xlink.www.constants.StrutsGlobalForwardNames;
import org.yeastrc.xlink.www.constants.Struts_Config_Parameter_Values_Constants;
import org.yeastrc.xlink.www.constants.WebConstants;
import org.yeastrc.xlink.www.exceptions.ProxlWebappDataException;
import org.yeastrc.xlink.www.form_query_json_objects.CutoffValuesRootLevel;
import org.yeastrc.xlink.www.form_query_json_objects.ProteinQueryJSONRoot;
import org.yeastrc.xlink.www.form_query_json_objects.Z_CutoffValuesObjectsToOtherObjectsFactory;
import org.yeastrc.xlink.www.form_query_json_objects.Z_CutoffValuesObjectsToOtherObjectsFactory.Z_CutoffValuesObjectsToOtherObjects_RootResult;
import org.yeastrc.xlink.www.form_utils.GetProteinQueryJSONRootFromFormData;
import org.yeastrc.xlink.www.forms.MergedSearchViewProteinsForm;
import org.yeastrc.xlink.www.forms.PeptideProteinCommonForm;
import org.yeastrc.xlink.www.objects.ProteinCoverageData;
import org.yeastrc.xlink.www.protein_coverage.ProteinCoverageCompute;
import org.yeastrc.xlink.www.access_control.access_control_main.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId_Result;
import org.yeastrc.xlink.www.access_control.access_control_main.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId;
import org.yeastrc.xlink.www.web_utils.AnyPDBFilesForProjectId;
import org.yeastrc.xlink.www.web_utils.ExcludeLinksWith_Remove_NonUniquePSMs_Checkbox_PopRequestItems;
import org.yeastrc.xlink.www.web_utils.ExcludeOnTaxonomyForProteinSequenceVersionIdSearchId;
import org.yeastrc.xlink.www.web_utils.GetAnnotationDisplayUserSelectionDetailsData;
import org.yeastrc.xlink.www.web_utils.GetMinimumPSMsDefaultForProject_PutInRequestScope;
import org.yeastrc.xlink.www.web_utils.GetPageHeaderData;
import org.yeastrc.xlink.www.web_utils.GetSearchDetailsData;
import org.yeastrc.xlink.www.web_utils.ProjectSearchIdsSearchIds_SetRequestParameter;
import org.yeastrc.xlink.www.web_utils.ProteinListingTooltipConfigUtil;
import org.yeastrc.xlink.www.web_utils.TaxonomiesForSearchOrSearches;
import org.yeastrc.xlink.www.web_utils.URLEncodeDecodeAURL;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -83,6 +61,8 @@ public ActionForward execute( ActionMapping mapping,
HttpServletRequest request,
HttpServletResponse response ) throws Exception {

Integer projectId = null;

// Detect which Struts action mapping was called by examining the value of the "parameter" attribute
// accessed by calling mapping.getParameter()
String strutsActionMappingParameter = mapping.getParameter();
Expand Down Expand Up @@ -119,7 +99,9 @@ public ActionForward execute( ActionMapping mapping,
// Invalid request, searches across projects
return mapping.findForward( StrutsGlobalForwardNames.INVALID_REQUEST_SEARCHES_ACROSS_PROJECTS );
}
int projectId = projectIdsFromSearchIds.get( 0 );

projectId = projectIdsFromSearchIds.get( 0 );

request.setAttribute( "projectId", projectId );
request.setAttribute( "project_id", projectId );
///////////////////////
Expand Down Expand Up @@ -265,14 +247,63 @@ public int compare(SearchDTO o1, SearchDTO o2) {
PopulateRequestDataForImageAndStructureAndQC_NavLinks.getInstance()
.populateRequestDataForImageAndStructureNavLinksForProtein( proteinQueryJSONRoot, projectId, authAccessLevel, form, request );
//////////////////////////////////////

return mapping.findForward( "Success" );

} catch ( ProxlWebappDataException e ) {
String msg = "Exception processing request data";

Integer authUserId = null;
Integer userMgmtUserId = null;
String username = null;

try {
UserSession userSession = UserSessionManager.getSinglesonInstance().getUserSession(request);

if ( userSession != null ) {

authUserId = userSession.getAuthUserId();
userMgmtUserId = userSession.getUserMgmtUserId();
username = userSession.getUsername();
}
} catch ( Exception e2 ) {
log.error( "In Main } catch ( Exception e ) {: Error getting User Id and Username: ", e2 );
}

String msg = "Exception processing request data. authUserId (null if no session): "
+ authUserId
+ ", userMgmtUserId (null if no session): " + userMgmtUserId
+ ", username (null if no session): " + username
+ e.toString();
log.error( msg, e );

return mapping.findForward( StrutsGlobalForwardNames.INVALID_REQUEST_DATA );

} catch ( Exception e ) {
String msg = "Exception caught: " + e.toString();

Integer authUserId = null;
Integer userMgmtUserId = null;
String username = null;

try {
UserSession userSession = UserSessionManager.getSinglesonInstance().getUserSession(request);

if ( userSession != null ) {

authUserId = userSession.getAuthUserId();
userMgmtUserId = userSession.getUserMgmtUserId();
username = userSession.getUsername();
}
} catch ( Exception e2 ) {
log.error( "In Main } catch ( Exception e ) {: Error getting User Id and Username: ", e2 );
}

String msg = "Exception caught. authUserId (null if no session): "
+ authUserId
+ ", userMgmtUserId (null if no session): " + userMgmtUserId
+ ", username (null if no session): " + username
+ e.toString();
log.error( msg, e );

throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
import org.yeastrc.xlink.www.dao.SearchDAO;
import org.yeastrc.xlink.www.dto.SearchDTO;
import org.yeastrc.xlink.www.dao.ConfigSystemDAO;
import org.yeastrc.xlink.www.form_query_json_objects.CutoffValuesRootLevel;
import org.yeastrc.xlink.www.form_query_json_objects.ImageStructure_QC_QueryJSONRoot;
import org.yeastrc.xlink.www.forms.MergedSearchViewProteinsForm;
import org.yeastrc.xlink.www.forms.PeptideProteinCommonForm;
import org.yeastrc.xlink.www.access_control.result_objects.WebSessionAuthAccessLevel;
import org.yeastrc.xlink.www.constants.ConfigSystemsKeysConstants;
import org.yeastrc.xlink.www.constants.StrutsGlobalForwardNames;
import org.yeastrc.xlink.www.constants.WebConstants;
import org.yeastrc.xlink.www.cutoff_processing_web.GetDefaultPsmPeptideCutoffs;
import org.yeastrc.xlink.www.cutoff_processing_web.Set__A_QueryBase_JSONRoot__Defaults;
import org.yeastrc.xlink.www.searcher.ProjectIdsForProjectSearchIdsSearcher;
import org.yeastrc.xlink.www.user_session_management.UserSession;
import org.yeastrc.xlink.www.user_session_management.UserSessionManager;
import org.yeastrc.xlink.www.access_control.access_control_main.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId_Result;
import org.yeastrc.xlink.www.access_control.access_control_main.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId;
import org.yeastrc.xlink.www.web_utils.AnyPDBFilesForProjectId;
Expand All @@ -57,6 +57,9 @@ public ActionForward execute( ActionMapping mapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response ) throws Exception {

Integer projectId = null;

try {
MergedSearchViewProteinsForm form = (MergedSearchViewProteinsForm) actionForm;
int[] projectSearchIdsFromForm = form.getProjectSearchId();
Expand Down Expand Up @@ -85,7 +88,9 @@ public ActionForward execute( ActionMapping mapping,
// Invalid request, searches across projects
return mapping.findForward( StrutsGlobalForwardNames.INVALID_REQUEST_SEARCHES_ACROSS_PROJECTS );
}
int projectId = projectIdsFromSearchIds.get( 0 );

projectId = projectIdsFromSearchIds.get( 0 );

request.setAttribute( "projectId", projectId );
request.setAttribute( "project_id", projectId );
///////////////////////
Expand Down Expand Up @@ -230,8 +235,31 @@ public int compare(SearchDTO o1, SearchDTO o2) {
return mapping.findForward( "Success" );

} catch ( Exception e ) {
String msg = "Exception caught: " + e.toString();

Integer authUserId = null;
Integer userMgmtUserId = null;
String username = null;

try {
UserSession userSession = UserSessionManager.getSinglesonInstance().getUserSession(request);

if ( userSession != null ) {

authUserId = userSession.getAuthUserId();
userMgmtUserId = userSession.getUserMgmtUserId();
username = userSession.getUsername();
}
} catch ( Exception e2 ) {
log.error( "In Main } catch ( Exception e ) {: Error getting User Id and Username: ", e2 );
}

String msg = "Exception caught. authUserId (null if no session): "
+ authUserId
+ ", userMgmtUserId (null if no session): " + userMgmtUserId
+ ", username (null if no session): " + username
+ e.toString();
log.error( msg, e );

throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.yeastrc.xlink.www.access_control.result_objects.WebSessionAuthAccessLevel;
import org.yeastrc.xlink.www.searcher.ProjectIdsForProjectSearchIdsSearcher;
import org.yeastrc.xlink.www.searcher.SearchModMassDistinctSearcher;
import org.yeastrc.xlink.www.user_session_management.UserSession;
import org.yeastrc.xlink.www.user_session_management.UserSessionManager;
import org.yeastrc.xlink.www.constants.PeptideViewLinkTypesConstants;
import org.yeastrc.xlink.www.constants.StrutsGlobalForwardNames;
import org.yeastrc.xlink.www.constants.WebConstants;
Expand Down Expand Up @@ -72,6 +74,9 @@ public ActionForward execute( ActionMapping mapping,
webappTiming = WebappTiming.getInstance( log );
request.setAttribute( "webappTiming", webappTiming );
}

Integer projectId = null;

try {
// our form
MergedSearchViewPeptidesForm form = (MergedSearchViewPeptidesForm) actionForm;
Expand Down Expand Up @@ -102,7 +107,9 @@ public ActionForward execute( ActionMapping mapping,
// Invalid request, searches across projects
return mapping.findForward( StrutsGlobalForwardNames.INVALID_REQUEST_SEARCHES_ACROSS_PROJECTS );
}
int projectId = projectIdsFromSearchIds.get( 0 );

projectId = projectIdsFromSearchIds.get( 0 );

request.setAttribute( "projectId", projectId );
request.setAttribute( "project_id", projectId );
///////////////////////
Expand Down Expand Up @@ -282,14 +289,64 @@ public int compare(SearchDTO o1, SearchDTO o2) {
if ( webappTiming != null ) {
webappTiming.markPoint( "Before send to JSP" );
}

return mapping.findForward( "Success" );


} catch ( ProxlWebappDataException e ) {
String msg = "Exception processing request data";

Integer authUserId = null;
Integer userMgmtUserId = null;
String username = null;

try {
UserSession userSession = UserSessionManager.getSinglesonInstance().getUserSession(request);

if ( userSession != null ) {

authUserId = userSession.getAuthUserId();
userMgmtUserId = userSession.getUserMgmtUserId();
username = userSession.getUsername();
}
} catch ( Exception e2 ) {
log.error( "In Main } catch ( Exception e ) {: Error getting User Id and Username: ", e2 );
}

String msg = "Exception processing request data. authUserId (null if no session): "
+ authUserId
+ ", userMgmtUserId (null if no session): " + userMgmtUserId
+ ", username (null if no session): " + username
+ e.toString();
log.error( msg, e );

return mapping.findForward( StrutsGlobalForwardNames.INVALID_REQUEST_DATA );

} catch ( Exception e ) {
String msg = "Exception caught: " + e.toString();

Integer authUserId = null;
Integer userMgmtUserId = null;
String username = null;

try {
UserSession userSession = UserSessionManager.getSinglesonInstance().getUserSession(request);

if ( userSession != null ) {

authUserId = userSession.getAuthUserId();
userMgmtUserId = userSession.getUserMgmtUserId();
username = userSession.getUsername();
}
} catch ( Exception e2 ) {
log.error( "In Main } catch ( Exception e ) {: Error getting User Id and Username: ", e2 );
}

String msg = "Exception caught. authUserId (null if no session): "
+ authUserId
+ ", userMgmtUserId (null if no session): " + userMgmtUserId
+ ", username (null if no session): " + username
+ e.toString();
log.error( msg, e );

throw e;
}
}
Expand Down

0 comments on commit a7d26a3

Please sign in to comment.