List of usage examples for org.apache.commons.logging Log warn
void warn(Object message, Throwable t);
From source file:org.rhq.plugins.www.util.WWWUtils.java
/** * Sends a HEAD request for the passed URL and returns true if the URL was reachable. * * @param httpURL a http or https URL to check * @return true if connecting to the URL succeeds, or false otherwise *///from w w w. j av a 2s.co m public static boolean isAvailable(URL httpURL) { String failMsg = "URL [" + httpURL + "] returned unavailable"; try { HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod("HEAD"); connection.setConnectTimeout(3000); connection.setReadTimeout(1000); if (connection instanceof HttpsURLConnection) { disableCertificateVerification((HttpsURLConnection) connection); } connection.connect(); // get the response code to actually trigger sending the Request. connection.getResponseCode(); } catch (SSLException e) { Log log = LogFactory.getLog(WWWUtils.class); log.warn(failMsg + " due to: " + e.getLocalizedMessage(), e); return false; } catch (IOException e) { Log log = LogFactory.getLog(WWWUtils.class); log.debug(failMsg + " due to: " + e.getLocalizedMessage(), e); return false; } return true; }
From source file:org.rhq.plugins.www.util.WWWUtils.java
private static void disableCertificateVerification(HttpsURLConnection connection) { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[] {}; }/*from w w w.j a v a2 s . co m*/ public void checkClientTrusted(X509Certificate[] certs, String authType) { return; } public void checkServerTrusted(X509Certificate[] certs, String authType) { return; } } }; try { SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); connection.setSSLSocketFactory(sslContext.getSocketFactory()); connection.setHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession sslSession) { return true; } }); } catch (Exception e) { Log log = LogFactory.getLog(WWWUtils.class); log.warn("Failed to disable certificate validation.", e); } }
From source file:org.sakaiproject.assignment.tool.AssignmentAction.java
boolean checkSubmissionStateConsistency(SessionState state, String actualGradeSubmissionId) { String stateGradeSubmissionId = (String) state.getAttribute(GRADE_SUBMISSION_SUBMISSION_ID); Log.debug("chef", "checkSubmissionStateConsistency(): stateGradeSubmissionId = " + stateGradeSubmissionId); boolean is_good = stateGradeSubmissionId.equals(actualGradeSubmissionId); if (!is_good) { Log.warn("chef", "checkSubissionStateConsistency(): State is inconsistent! Aborting grade save."); addAlert(state, rb.getString("grading.alert.multiTab")); }// w ww. j av a 2s.co m return is_good; }
From source file:org.sakaiproject.authz.tool.RealmsAction.java
/** * build the context/* ww w .j ava2s. c o m*/ */ public String buildMainPanelContext(VelocityPortlet portlet, Context context, RunData rundata, SessionState state) { context.put("tlang", rb); // if not allowed, we won't do anything if (!isAccessAllowed()) { return (String) getContext(rundata).get("template") + "_noaccess"; } String template = null; // check mode and dispatch String mode = (String) state.getAttribute("mode"); if (mode == null) { template = buildListContext(state, context); } else if ("new".equals(mode)) { template = buildNewContext(state, context); } else if ("edit".equals(mode)) { template = buildEditContext(state, context); } else if ("confirm".equals(mode)) { template = buildConfirmRemoveContext(state, context); } else if ("saveas".equals(mode)) { template = buildSaveasContext(state, context); } else if ("newRole".equals(mode)) { template = buildNewRoleContext(state, context); } else if ("editRole".equals(mode)) { template = buildEditRoleContext(state, context); } else if ("saveasRole".equals(mode)) { template = buildSaveasRoleContext(state, context); } else if ("newUser".equals(mode)) { template = buildNewUserContext(state, context); } else if ("editUser".equals(mode)) { template = buildEditUserContext(state, context); } else if ("view".equals(mode)) { template = buildViewContext(state, context); } else if ("viewRole".equals(mode)) { template = buildViewRoleContext(state, context); } else { Log.warn("chef", "RealmsAction: mode: " + mode); template = buildListContext(state, context); } String prefix = (String) getContext(rundata).get("template"); return prefix + template; }
From source file:org.sakaiproject.authz.tool.RealmsAction.java
/** * Handle a request to edit a realm.//from www . j av a 2 s . c o m */ public void doEdit(RunData data, Context context) { SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid()); String id = data.getParameters().getString("id"); // get the realm try { AuthzGroup realm = authzGroupService.getAuthzGroup(id); state.setAttribute("realm", realm); state.setAttribute("mode", "edit"); // disable auto-updates while in view mode disableObservers(state); } catch (GroupNotDefinedException e) { Log.warn("chef", "RealmsAction.doEdit: realm not found: " + id); addAlert(state, rb.getFormattedMessage("realm.notfound", new Object[] { id })); state.removeAttribute("mode"); // make sure auto-updates are enabled enableObserver(state); } // catch (AuthzPermissionException e) // { // addAlert(state, rb.getString("realm.notpermis1") + " " + id); // state.removeAttribute("mode"); // // // make sure auto-updates are enabled // enableObserver(state); // } }
From source file:org.sakaiproject.authz.tool.RealmsAction.java
/** * Handle a request to save the edit from either page or tools list mode - no form to read in. *///from w w w . j a v a 2s . c om public void doSave_edit(RunData data, Context context) { SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid()); if (!"POST".equals(data.getRequest().getMethod())) { return; } // commit the change AuthzGroup realm = (AuthzGroup) state.getAttribute("realm"); if (realm != null) { try { authzGroupService.save(realm); // Grab the list from session state and save it, if appropriate List<String[]> userAuditList = (List<String[]>) state.getAttribute("userAuditList"); if (userAuditList != null && !userAuditList.isEmpty()) { userAuditRegistration.addToUserAuditing(userAuditList); state.removeAttribute("userAuditList"); } } catch (GroupNotDefinedException e) { // TODO: GroupNotDefinedException } catch (AuthzPermissionException e) { // TODO: AuthzPermissionException } catch (Exception e) { Log.warn("chef", this + "doSave_edit(): realmId = " + realm.getId() + " " + e.getMessage()); } } // cleanup cleanState(state); // return to main mode state.removeAttribute("mode"); // make sure auto-updates are enabled enableObserver(state); // TODO: hard coding this frame id is fragile, portal dependent, and needs to be fixed -ggolden schedulePeerFrameRefresh("sitenav"); }
From source file:org.sakaiproject.authz.tool.RealmsAction.java
/** * Handle a request to view a realm./*from w ww .jav a 2s . c om*/ */ public void doView(RunData data, Context context) { SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid()); String id = data.getParameters().getString("id"); // get the realm try { AuthzGroup realm = authzGroupService.getAuthzGroup(id); state.setAttribute("realm", realm); state.setAttribute("mode", "view"); // disable auto-updates while in view mode disableObservers(state); } catch (GroupNotDefinedException e) { Log.warn("chef", "RealmsAction.doView: realm not found: " + id); addAlert(state, rb.getFormattedMessage("realm.notfound", new Object[] { id })); state.removeAttribute("mode"); // make sure auto-updates are enabled enableObserver(state); } }
From source file:org.sakaiproject.authz.tool.RealmsAction.java
/** * Edit an existing user ability grant.// w w w. jav a 2 s. co m */ public void doEdit_user(RunData data, Context context) { SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid()); // read the form - if rejected, leave things as they are if (!readRealmForm(data, state)) return; String id = data.getParameters().getString("target"); try { User user = userDirectoryService.getUser(id); state.setAttribute("user", user); state.setAttribute("mode", "editUser"); } catch (UserNotDefinedException e) { Log.warn("chef", this + "doEdit_user(): user not found: " + id); addAlert(state, rb.getString("realm.user.notfound")); } }
From source file:org.sakaiproject.site.tool.AdminSitesAction.java
/** * build the context//from w ww .j a v a2s .co m */ public String buildMainPanelContext(VelocityPortlet portlet, Context context, RunData rundata, SessionState state) { context.put("tlang", rb); // if not logged in as the super user, we won't do anything if (!SecurityService.isSuperUser()) { context.put("tlang", rb); return (String) getContext(rundata).get("template") + "_noaccess"; } String template = null; // get the Sakai session Session session = SessionManager.getCurrentSession(); // get the Tool session ToolSession toolSession = SessionManager.getCurrentToolSession(); // check mode and dispatch String mode = (String) state.getAttribute("mode"); if (mode == null) { template = buildListContext(state, context); } else if (mode.equals("new")) { template = buildNewContext(state, context); } else if (mode.equals("edit")) { template = buildEditContext(state, context); } else if (mode.equals("confirm")) { template = buildConfirmRemoveContext(state, context); } else if (mode.equals("saveas")) { template = buildSaveasContext(state, context); } else if (mode.equals("pages")) { template = buildPagesContext(state, context); } else if (mode.equals("newPage")) { template = buildNewPageContext(state, context); } else if (mode.equals("editPage")) { template = buildEditPageContext(state, context); } else if (mode.equals("properties")) { template = buildPropertiesContext(state, context); } else if (mode.equals("pageProperties")) { template = buildPagePropertiesContext(state, context); } else if (mode.equals("toolProperties")) { template = buildToolPropertiesContext(state, context); } else if (mode.equals("groups")) { template = buildGroupsContext(state, context); } else if (mode.equals("newGroup")) { template = buildNewGroupContext(state, context); } else if (mode.equals("editGroup")) { template = buildEditGroupContext(state, context); } else if (mode.equals("tools")) { template = buildToolsContext(state, context); } else if (mode.equals("newTool")) { template = buildNewToolContext(state, context); } else if (mode.equals("editTool")) { template = buildEditToolContext(state, context); } // else if (mode.equals("newMember")) // { // template = buildNewMemberContext(state, context); // } else { Log.warn("chef", "SitesAction: mode: " + mode); template = buildListContext(state, context); } String prefix = (String) getContext(rundata).get("template"); return prefix + template; }
From source file:org.sakaiproject.site.tool.AdminSitesAction.java
/** * Handle a request to edit a site.//from w w w . jav a 2 s. c o m */ public void doEdit(RunData data, Context context) { SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid()); String id = data.getParameters().getString("id"); if (SiteService.allowUpdateSite(id)) { // get the site try { Site site = SiteService.getSite(id); state.setAttribute("site", site); // RealmEdit realm = authzGroupService.editRealm("/site/" + id); // %%% use a site service call -ggolden // state.setAttribute("realm", realm); state.setAttribute("mode", "edit"); // disable auto-updates while in view mode ObservingCourier courier = (ObservingCourier) state.getAttribute(STATE_OBSERVER); if (courier != null) courier.disable(); } catch (IdUnusedException e) { Log.warn("chef", "SitesAction.doEdit: site not found: " + id); addAlert(state, rb.getFormattedMessage("siteact.site", new Object[] { id })); state.removeAttribute("mode"); // make sure auto-updates are enabled enableObserver(state); } } else { addAlert(state, rb.getFormattedMessage("youdonot1", new Object[] { id })); state.removeAttribute("mode"); // make sure auto-updates are enabled enableObserver(state); } }