List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private synchronized void scheduleTooltipDisplay(final double x) { if (tooltipTimerTask != null) { tooltipTimerTask.cancel();/* ww w . ja v a 2 s . com*/ } tooltipTimerTask = new TimerTask() { @Override public void run() { tooltipTimerTask = null; enableTooltip(x); } }; try { GlobalTimer.getTimer().schedule(tooltipTimerTask, TOOLTIP_DISPLAY_DELAY); } catch (IllegalStateException e) { System.err.println(this + ": " + e.getMessage()); } }
From source file:nl.mpi.lamus.workspace.exporting.implementation.LamusVersioningHandlerTest.java
@Test public void moveFileToOrphansFolder_ResourceNodeWithArchiveURI_FileNull() throws MalformedURLException, URISyntaxException { final String testNodeStrippedHandle = UUID.randomUUID().toString(); final String testNodeFullHandle = "hdl:12345/" + testNodeStrippedHandle; final URI testNodeFullArchiveURI = URI.create(testNodeFullHandle); final String expectedMessage = "No valid file location was found."; context.checking(new Expectations() { {/*from w w w. j a va 2 s . c om*/ allowing(mockWorkspaceNode).getArchiveURI(); will(returnValue(testNodeFullArchiveURI)); oneOf(mockNodeUtil).isNodeMetadata(mockWorkspaceNode); will(returnValue(Boolean.FALSE)); oneOf(mockCorpusStructureProvider).getNode(testNodeFullArchiveURI); will(returnValue(mockCorpusNode)); oneOf(mockNodeResolver).getLocalFile(mockCorpusNode); will(returnValue(null)); } }); try { versioningHandler.moveFileToOrphansFolder(mockWorkspace, mockWorkspaceNode); fail("should have thrown exception"); } catch (IllegalStateException ex) { assertEquals("Exception message different from expected", expectedMessage, ex.getMessage()); } }
From source file:org.lockss.crawljax.DefLockssConfigurationBuilder.java
/** * install any plugins defined in the config file. If at least one isn't * specified we install the default one. * * @param builder the CrawljaxConfigurationBuilder we add to *///from w w w . j a v a 2 s . c o m protected boolean configurePlugins(CrawljaxConfigurationBuilder builder) { boolean has_one_plugin = false; String[] plugin_names = m_config.getStringArray(PLUGINS_PARAM); for (String plugin_name : plugin_names) { try { Plugin plugin = instantiate(plugin_name, Plugin.class); builder.addPlugin(plugin); has_one_plugin = true; } catch (IllegalStateException e) { System.out.println("Failed to install plugin '" + plugin_name + "' -" + e.getMessage()); } } return has_one_plugin; }
From source file:org.everit.authentication.cas.CasAuthentication.java
/** * Processes the CAS (back channel) logout requests. It retrieves the invalidated service ticket * from the logout request and invalidates the {@link HttpSession} assigned to that service * ticket.//from ww w . j a v a 2s . c o m */ private void processBackChannelLogout(final HttpServletRequest httpServletRequest) throws IOException { String logoutRequest = httpServletRequest.getParameter(requestParamNameLogoutRequest); String sessionIndex = getTextForElement(logoutRequest, SESSION_INDEX); ServletContext servletContext = httpServletRequest.getServletContext(); CasHttpSessionRegistry casHttpSessionRegistry = CasHttpSessionRegistry.getInstance(servicePid, servletContext); casHttpSessionRegistry.removeByServiceTicket(sessionIndex).ifPresent((httpSession) -> { try { httpSession.invalidate(); } catch (IllegalStateException e) { LOGGER.debug(e.getMessage(), e); } }); }
From source file:com.vmware.identity.samlservice.impl.LogoutStateValidator.java
/** * Validate LogoutResponse//from ww w. jav a2 s .c o m * * @param vr * @param accessor * @param response * @return */ private com.vmware.identity.samlservice.SamlValidator.ValidationResult validateLogoutResponse( com.vmware.identity.samlservice.SamlValidator.ValidationResult vr, IdmAccessor accessor, LogoutResponse response, SessionManager sm) { Validate.notNull(response.getIssuer()); // Validate single logout service first, if that is valid, we can send // SAML replies try { @SuppressWarnings("unused") String acsUrl = accessor.getSloForRelyingParty(response.getIssuer().getValue(), OasisNames.HTTP_REDIRECT); } catch (IllegalStateException e) { // set validation result to 400 log.debug("Caught illegal state exception while Validating " + e.toString() + ", returning 400"); vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null); } // Validate ID if (vr == null && response.getID() == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Request ID is missing"); } // Validate version if (vr == null) { SAMLVersion version = response.getVersion(); if ((version.getMajorVersion() > Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() > Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too high vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_HIGH); log.debug("Validation FAILED - Version is too high"); } else if ((version.getMajorVersion() < Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() < Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too low vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_LOW); log.debug("Validation FAILED - Version is too low"); } } // Validate IssueInstant if (vr == null) { DateTime dtPlus = response.getIssueInstant(); DateTime dtMinus = response.getIssueInstant(); DateTime instant = new DateTime(); long clockTolerance = accessor.getClockTolerance(); if (dtPlus == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant is missing"); } else { dtPlus = dtPlus.plus(clockTolerance); dtMinus = dtMinus.minus(clockTolerance); // dtPlus must be after now and dtMinus must be before now // in order to satisfy clock tolerance if (dtPlus.isBefore(instant) || dtMinus.isAfter(instant)) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant outside of clock tolerance"); log.debug("clockTolerance {} ", clockTolerance); log.debug("now {}", instant); log.debug("dtPlus {}", dtPlus.toString()); log.debug("dtMinus {}", dtMinus.toString()); } } } // Destination URL skipped, this is already done by OpenSAML when // parsing // validate inResponseTo (which is the corresponding SLO request ID that // this response is targetting at) if (vr == null) { String inResponseTo = response.getInResponseTo(); if (inResponseTo == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - inResponseTo is missing"); } else { // try to find a session by LogoutRequest id that we have Session session = sm.getByLogoutRequestId(inResponseTo); if (session == null) { // No session found using the SLO request ID. This could // happen due to // fail-over (node switch). So here we ignore rather than // throw error at browser log.info( "Unable to identify a session the SLO response is referring to. This could be caused by site-affinity switch."); } } } // check response status code if (vr == null) { Status status = null; StatusCode statusCode = null; if (vr == null) { // check LogoutResponse status code here status = response.getStatus(); if (status == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - unable to find status code"); } } if (vr == null) { statusCode = status.getStatusCode(); if (statusCode == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - unable to find status code"); } } if (vr == null) { String code = statusCode.getValue(); if (!OasisNames.SUCCESS.equals(code)) { vr = new ValidationResult(OasisNames.SUCCESS, OasisNames.PARTIAL_LOGOUT); log.debug("Validation FAILED - partially logged out session"); } } } // validation done if (vr == null) { vr = new ValidationResult(); // success } return vr; }
From source file:org.dspace.app.webui.discovery.DiscoverySearchRequestProcessor.java
public void doSimpleSearch(Context context, HttpServletRequest request, HttpServletResponse response) throws SearchProcessorException, IOException, ServletException { Item[] resultsItems;/*from w w w . ja va 2 s .c o m*/ Collection[] resultsCollections; Community[] resultsCommunities; DSpaceObject scope; try { scope = DiscoverUtility.getSearchScope(context, request); } catch (IllegalStateException e) { throw new SearchProcessorException(e.getMessage(), e); } catch (SQLException e) { throw new SearchProcessorException(e.getMessage(), e); } DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(scope); List<DiscoverySortFieldConfiguration> sortFields = discoveryConfiguration.getSearchSortConfiguration() .getSortFields(); List<String> sortOptions = new ArrayList<String>(); for (DiscoverySortFieldConfiguration sortFieldConfiguration : sortFields) { String sortField = SearchUtils.getSearchService() .toSortFieldIndex(sortFieldConfiguration.getMetadataField(), sortFieldConfiguration.getType()); sortOptions.add(sortField); } request.setAttribute("sortOptions", sortOptions); DiscoverQuery queryArgs = DiscoverUtility.getDiscoverQuery(context, request, scope, true); queryArgs.setSpellCheck(discoveryConfiguration.isSpellCheckEnabled()); List<DiscoverySearchFilterFacet> availableFacet = discoveryConfiguration.getSidebarFacets(); request.setAttribute("facetsConfig", availableFacet != null ? availableFacet : new ArrayList<DiscoverySearchFilterFacet>()); int etal = UIUtil.getIntParameter(request, "etal"); if (etal == -1) { etal = ConfigurationManager.getIntProperty("webui.itemlist.author-limit"); } request.setAttribute("etal", etal); String query = queryArgs.getQuery(); request.setAttribute("query", query); request.setAttribute("queryArgs", queryArgs); List<DiscoverySearchFilter> availableFilters = discoveryConfiguration.getSearchFilters(); request.setAttribute("availableFilters", availableFilters); List<String[]> appliedFilters = DiscoverUtility.getFilters(request); request.setAttribute("appliedFilters", appliedFilters); List<String> appliedFilterQueries = new ArrayList<String>(); for (String[] filter : appliedFilters) { appliedFilterQueries.add(filter[0] + "::" + filter[1] + "::" + filter[2]); } request.setAttribute("appliedFilterQueries", appliedFilterQueries); List<DSpaceObject> scopes = new ArrayList<DSpaceObject>(); if (scope == null) { Community[] topCommunities; try { topCommunities = Community.findAllTop(context); } catch (SQLException e) { throw new SearchProcessorException(e.getMessage(), e); } for (Community com : topCommunities) { scopes.add(com); } } else { try { DSpaceObject pDso = scope.getParentObject(); while (pDso != null) { // add to the available scopes in reverse order scopes.add(0, pDso); pDso = pDso.getParentObject(); } scopes.add(scope); if (scope instanceof Community) { Community[] comms = ((Community) scope).getSubcommunities(); for (Community com : comms) { scopes.add(com); } Collection[] colls = ((Community) scope).getCollections(); for (Collection col : colls) { scopes.add(col); } } } catch (SQLException e) { throw new SearchProcessorException(e.getMessage(), e); } } request.setAttribute("scope", scope); request.setAttribute("scopes", scopes); // Perform the search DiscoverResult qResults = null; try { qResults = SearchUtils.getSearchService().search(context, scope, queryArgs); List<Community> resultsListComm = new ArrayList<Community>(); List<Collection> resultsListColl = new ArrayList<Collection>(); List<Item> resultsListItem = new ArrayList<Item>(); for (DSpaceObject dso : qResults.getDspaceObjects()) { if (dso instanceof Item) { resultsListItem.add((Item) dso); } else if (dso instanceof Collection) { resultsListColl.add((Collection) dso); } else if (dso instanceof Community) { resultsListComm.add((Community) dso); } } // Make objects from the handles - make arrays, fill them out resultsCommunities = new Community[resultsListComm.size()]; resultsCollections = new Collection[resultsListColl.size()]; resultsItems = new Item[resultsListItem.size()]; resultsCommunities = resultsListComm.toArray(resultsCommunities); resultsCollections = resultsListColl.toArray(resultsCollections); resultsItems = resultsListItem.toArray(resultsItems); // Log log.info(LogManager.getHeader(context, "search", "scope=" + scope + ",query=\"" + query + "\",results=(" + resultsCommunities.length + "," + resultsCollections.length + "," + resultsItems.length + ")")); // Pass in some page qualities // total number of pages long pageTotal = 1 + ((qResults.getTotalSearchResults() - 1) / qResults.getMaxResults()); // current page being displayed long pageCurrent = 1 + (qResults.getStart() / qResults.getMaxResults()); // pageLast = min(pageCurrent+3,pageTotal) long pageLast = ((pageCurrent + 3) > pageTotal) ? pageTotal : (pageCurrent + 3); // pageFirst = max(1,pageCurrent-3) long pageFirst = ((pageCurrent - 3) > 1) ? (pageCurrent - 3) : 1; // Pass the results to the display JSP request.setAttribute("items", resultsItems); request.setAttribute("communities", resultsCommunities); request.setAttribute("collections", resultsCollections); request.setAttribute("pagetotal", new Long(pageTotal)); request.setAttribute("pagecurrent", new Long(pageCurrent)); request.setAttribute("pagelast", new Long(pageLast)); request.setAttribute("pagefirst", new Long(pageFirst)); request.setAttribute("spellcheck", qResults.getSpellCheckQuery()); request.setAttribute("queryresults", qResults); try { if (AuthorizeManager.isAdmin(context)) { // Set a variable to create admin buttons request.setAttribute("admin_button", new Boolean(true)); } } catch (SQLException e) { throw new SearchProcessorException(e.getMessage(), e); } if ("submit_export_metadata".equals(UIUtil.getSubmitButton(request, "submit"))) { exportMetadata(context, response, resultsItems); } } catch (SearchServiceException e) { log.error(LogManager.getHeader(context, "search", "query=" + queryArgs.getQuery() + ",scope=" + scope + ",error=" + e.getMessage()), e); request.setAttribute("search.error", true); request.setAttribute("search.error.message", e.getMessage()); } JSPManager.showJSP(request, response, "/search/discovery.jsp"); }
From source file:org.ow2.chameleon.core.activators.DirectoryMonitor.java
/** * {@inheritDoc}/*www . j a v a 2 s. co m*/ * <p/> * If the directory is watched, stop it. */ @Override public boolean removeAndStopIfNeeded(File directory) { try { acquireWriteLockIfNotHeld(); FileAlterationMonitor monitor = monitors.remove(directory); if (monitor != null) { try { monitor.stop(); } catch (IllegalStateException e) { LOGGER.warn("Stopping an already stopped file monitor on {}.", directory.getAbsolutePath()); LOGGER.debug(e.getMessage(), e); } catch (Exception e) { LOGGER.error("Something bad happened while trying to stop the file monitor on {}", directory, e); } return true; } return false; } finally { releaseWriteLockIfHeld(); } }
From source file:org.apache.syncope.core.sync.impl.AbstractSubjectSyncResultHandler.java
/** * Look into SyncDelta and take necessary profile.getActions() (create / update / delete) on user(s)/role(s). * * @param delta returned by the underlying profile.getConnector() * @throws JobExecutionException in case of synchronization failure. *//*from w w w .j a va2 s. co m*/ protected final void doHandle(final SyncDelta delta, final Collection<SyncResult> syncResults) throws JobExecutionException { final AttributableUtil attrUtil = getAttributableUtil(); LOG.debug("Process {} for {} as {}", delta.getDeltaType(), delta.getUid().getUidValue(), delta.getObject().getObjectClass()); final String uid = delta.getPreviousUid() == null ? delta.getUid().getUidValue() : delta.getPreviousUid().getUidValue(); try { List<Long> subjectIds = syncUtilities.findExisting(uid, delta.getObject(), profile.getSyncTask().getResource(), attrUtil); if (subjectIds.size() > 1) { switch (profile.getResAct()) { case IGNORE: throw new IllegalStateException("More than one match " + subjectIds); case FIRSTMATCH: subjectIds = subjectIds.subList(0, 1); break; case LASTMATCH: subjectIds = subjectIds.subList(subjectIds.size() - 1, subjectIds.size()); break; default: // keep subjectIds as is } } if (SyncDeltaType.CREATE_OR_UPDATE == delta.getDeltaType()) { if (subjectIds.isEmpty()) { switch (profile.getSyncTask().getUnmatchingRule()) { case ASSIGN: profile.getResults().addAll(assign(delta, attrUtil)); break; case PROVISION: profile.getResults().addAll(create(delta, attrUtil)); break; default: // do nothing } } else { switch (profile.getSyncTask().getMatchingRule()) { case UPDATE: profile.getResults().addAll(update(delta, subjectIds, attrUtil)); break; case DEPROVISION: profile.getResults().addAll(deprovision(delta, subjectIds, attrUtil, false)); break; case UNASSIGN: profile.getResults().addAll(deprovision(delta, subjectIds, attrUtil, true)); break; case LINK: profile.getResults().addAll(link(delta, subjectIds, attrUtil, false)); break; case UNLINK: profile.getResults().addAll(link(delta, subjectIds, attrUtil, true)); break; default: // do nothing } } } else if (SyncDeltaType.DELETE == delta.getDeltaType()) { if (subjectIds.isEmpty()) { LOG.debug("No match found for deletion"); } else { profile.getResults().addAll(delete(delta, subjectIds, attrUtil)); } } } catch (IllegalStateException e) { LOG.warn(e.getMessage()); } }
From source file:org.finra.herd.service.helper.notification.UserNamespaceAuthorizationChangeMessageBuilderTest.java
@Test public void testBuildUserNamespaceAuthorizationChangeMessagesJsonPayloadInvalidMessageType() throws Exception { // Create a user namespace authorization key. UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey(USER_ID, BDEF_NAMESPACE);/*from ww w. j a v a2s.co m*/ // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity .setKey(ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(INVALID_VALUE, MESSAGE_DESTINATION, USER_NAMESPACE_AUTHORIZATION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Try to build a notification message. try { userNamespaceAuthorizationChangeMessageBuilder.buildNotificationMessages( new UserNamespaceAuthorizationChangeNotificationEvent(userNamespaceAuthorizationKey)); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Only \"%s\" notification message type is supported. Please update \"%s\" configuration entry.", MESSAGE_TYPE_SNS, ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.everit.osgi.authentication.cas.internal.CasAuthenticationComponent.java
/** * Processes the CAS (back channel) logout requests. It retrieves the invalidated service ticket from the logout * request and invalidates the {@link HttpSession} assigned to that service ticket. */// w ww . ja va 2s .c o m private void processBackChannelLogout(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws IOException { String logoutRequest = httpServletRequest.getParameter(requestParamNameLogoutRequest); String sessionIndex = getTextForElement(logoutRequest, SESSION_INDEX); ServletContext servletContext = httpServletRequest.getServletContext(); CasHttpSessionRegistry casHttpSessionRegistry = CasHttpSessionRegistry.getInstance(servicePid, servletContext); casHttpSessionRegistry.removeByServiceTicket(sessionIndex).ifPresent((httpSession) -> { try { httpSession.invalidate(); } catch (IllegalStateException e) { logService.log(LogService.LOG_DEBUG, e.getMessage(), e); } }); }