Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.jahia.services.search.jcr.JahiaJCRSearchProvider.java

private void addDateConstraint(StringBuilder constraints, SearchCriteria.DateValue dateValue, String paramName,
        boolean xpath) {
    Calendar greaterThanDate = Calendar.getInstance();
    Calendar smallerThanDate = null;

    if (DateValue.Type.TODAY == dateValue.getType()) {
        // no date adjustment needed
    } else if (DateValue.Type.LAST_WEEK == dateValue.getType()) {
        greaterThanDate.add(Calendar.DATE, -7);
    } else if (DateValue.Type.LAST_MONTH == dateValue.getType()) {
        greaterThanDate.add(Calendar.MONTH, -1);
    } else if (DateValue.Type.LAST_THREE_MONTHS == dateValue.getType()) {
        greaterThanDate.add(Calendar.MONTH, -3);
    } else if (DateValue.Type.LAST_SIX_MONTHS == dateValue.getType()) {
        greaterThanDate.add(Calendar.MONTH, -6);
    } else if (DateValue.Type.RANGE == dateValue.getType()) {
        greaterThanDate = null;/*from   w  ww  .  j  av  a2s.  com*/
        smallerThanDate = null;
        if (dateValue.getFromAsDate() != null) {
            greaterThanDate = Calendar.getInstance();
            greaterThanDate.setTime(dateValue.getFromAsDate());
        }
        if (dateValue.getToAsDate() != null) {
            smallerThanDate = Calendar.getInstance();
            smallerThanDate.setTime(dateValue.getToAsDate());
        }
    } else {
        throw new IllegalArgumentException("Unknown date value type '" + dateValue.getType() + "'");
    }

    try {
        if (greaterThanDate != null) {
            addConstraint(constraints, AND, getPropertyName(paramName, xpath) + " >= "
                    + getDateLiteral(DateUtils.dayStart(greaterThanDate), xpath));
        }
        if (smallerThanDate != null) {
            addConstraint(constraints, AND, getPropertyName(paramName, xpath) + " <= "
                    + getDateLiteral(DateUtils.dayEnd(smallerThanDate), xpath));
        }
    } catch (IllegalStateException e) {
        logger.warn(e.getMessage(), e);
    }
}

From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java

@Test
public void testProcessUserNamespaceAuthorizationChangeNotificationEventNoMessageDestination()
        throws Exception {
    // Create a user namespace authorization key.
    UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey(USER_ID,
            NAMESPACE);//  w  w  w .  j av  a 2  s .  c  om

    // Create and persist the relative database entities.
    namespaceDaoTestHelper.createNamespaceEntity(userNamespaceAuthorizationKey.getNamespace());
    userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(
            userNamespaceAuthorizationKey, SUPPORTED_NAMESPACE_PERMISSIONS);

    // Override configuration, so there will be no message definition specified in the relative notification message definition.
    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(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION,
                    MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to trigger the notification.
    try {
        // Trigger the notification.
        messageNotificationEventService
                .processUserNamespaceAuthorizationChangeNotificationEvent(userNamespaceAuthorizationKey);

        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(
                "Notification message destination must be specified. Please update \"%s\" configuration entry.",
                ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS
                        .getKey()),
                e.getMessage());
    }
}

From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java

@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageDestination()
        throws Exception {
    // Create a business object format entity.
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(
            BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION,
            PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);

    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper
            .createBusinessObjectFormat(request);

    // Get a business object data key.
    BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper
            .getBusinessObjectFormatKey(businessObjectFormatEntity);

    // Override configuration, so there will be no message definition specified in the relative notification message definition.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(//w  w  w. j av  a2 s. c  om
            ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS
                    .getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections
            .singletonList(new NotificationMessageDefinition(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION,
                    MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to trigger the notification.
    try {
        // Trigger the notification.
        messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(
                businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);

        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(
                "Notification message destination must be specified. Please update \"%s\" configuration entry.",
                ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS
                        .getKey()),
                e.getMessage());
    }
}

From source file:me.taylorkelly.mywarp.bukkit.MyWarpPlugin.java

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    // create the CommandLocals
    CommandLocals locals = new CommandLocals();
    Actor actor = wrap(sender);//from  w w w  .j  ava2  s. c  om
    locals.put(Actor.class, actor);

    // set the locale for this command session
    LocaleManager.setLocale(actor.getLocale());

    // No parent commands
    String[] parentCommands = new String[0];

    // create the command string
    StrBuilder builder = new StrBuilder();
    builder.append(label);
    for (String argument : args) {
        builder.appendSeparator(' ');
        builder.append(argument);
    }

    // call the command
    try {
        return dispatcher.call(builder.toString(), locals, parentCommands);
    } catch (IllegalStateException e) {
        log.error(String.format(
                "The command '%s' could not be executed as the underling method could not be called.",
                cmd.toString()), e);
        actor.sendError(MESSAGES.getString("exception.unknown"));
    } catch (InvocationCommandException e) {
        // An InvocationCommandException can only be thrown if a thrown
        // Exception is not covered by our ExceptionConverter and is
        // therefore unintended behavior.
        actor.sendError(MESSAGES.getString("exception.unknown"));
        log.error(String.format("The command '%s' could not be executed.", cmd), e);
    } catch (InvalidUsageException e) {
        StrBuilder error = new StrBuilder();
        error.append(e.getSimpleUsageString("/"));
        if (e.getMessage() != null) {
            error.appendNewLine();
            error.append(e.getMessage());
        }
        if (e.isFullHelpSuggested()) {
            error.appendNewLine();
            error.append(e.getCommand().getDescription().getHelp());
        }
        actor.sendError(error.toString());
    } catch (CommandException e) {
        actor.sendError(e.getMessage());
    } catch (AuthorizationException e) {
        actor.sendError(MESSAGES.getString("exception.insufficient-permission"));
    }
    return true;
}

From source file:org.apache.lucene.gdata.storage.db4o.DB4oStorage.java

/**
 * @see org.apache.lucene.gdata.storage.Storage#storeAccount(org.apache.lucene.gdata.data.GDataAccount)
 *///w w w.  j a  v  a  2s.  c om
public void storeAccount(GDataAccount account) throws StorageException {
    if (account == null)
        throw new StorageException("can not store account -- is null");
    if (account.getName() == null)
        throw new StorageException("can not store account -- name is null");
    if (account.getPassword() == null)
        throw new StorageException("can not store account -- password is null");
    try {
        getAccount(account.getName());
        throw new IllegalStateException("account with accountname: " + account.getName() + " already exists");
    } catch (IllegalStateException e) {
        throw new StorageException("Account already exists");
    } catch (StorageException e) {
        if (LOG.isDebugEnabled())
            LOG.debug("checked account for existence -- does not exist -- store account");
    }
    try {
        this.container.set(account);
        this.container.commit();
    } catch (Exception e) {
        LOG.error("Error occured on persisting changes -- rollback changes");
        this.container.rollback();
        throw new StorageException("Can not persist changes -- " + e.getMessage(), e);
    }
    if (LOG.isInfoEnabled())
        LOG.info("Stored account: " + account);
}

From source file:com.evolveum.midpoint.model.impl.lens.Clockwork.java

public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Task task, OperationResult result)
        throws SchemaException, PolicyViolationException, ExpressionEvaluationException,
        ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException,
        SecurityViolationException {//  w  w w .  j  a  v a 2 s  .c  o m

    // DO NOT CHECK CONSISTENCY of the context here. The context may not be fresh and consistent yet. Project will fix
    // that. Check consistency afterwards (and it is also checked inside projector several times).

    if (context.getDebugListener() == null) {
        context.setDebugListener(debugListener);
    }

    try {

        // We need to determine focus before auditing. Otherwise we will not know user
        // for the accounts (unless there is a specific delta for it).
        // This is ugly, but it is the easiest way now (TODO: cleanup).
        contextLoader.determineFocusContext((LensContext<? extends FocusType>) context, result);

        ModelState state = context.getState();
        if (state == ModelState.INITIAL) {
            if (debugListener != null) {
                debugListener.beforeSync(context);
            }
            XMLGregorianCalendar requestTimestamp = clock.currentTimeXMLGregorianCalendar();
            context.getStats().setRequestTimestamp(requestTimestamp);
            // We need to do this BEFORE projection. If we would do that after projection
            // there will be secondary changes that are not part of the request.
            audit(context, AuditEventStage.REQUEST, task, result);
        }

        boolean recompute = false;
        if (!context.isFresh()) {
            LOGGER.trace("Context is not fresh -- forcing cleanup and recomputation");
            recompute = true;
        } else if (context.getExecutionWave() > context.getProjectionWave()) { // should not occur
            LOGGER.warn("Execution wave is greater than projection wave -- forcing cleanup and recomputation");
            recompute = true;
        }

        if (recompute) {
            context.cleanup();
            projector.project(context, "PROJECTOR (" + state + ")", task, result);
        } else if (context.getExecutionWave() == context.getProjectionWave()) {
            LOGGER.trace("Running projector for current execution wave");
            projector.resume(context, "PROJECTOR (" + state + ")", task, result);
        } else {
            LOGGER.trace(
                    "Skipping projection because the context is fresh and projection for current wave has already run");
        }

        if (!context.isRequestAuthorized()) {
            authorizeContextRequest(context, task, result);
        }

        LensUtil.traceContext(LOGGER, "CLOCKWORK (" + state + ")", "before processing", true, context, false);
        if (InternalsConfig.consistencyChecks) {
            try {
                context.checkConsistence();
            } catch (IllegalStateException e) {
                throw new IllegalStateException(e.getMessage() + " in clockwork, state=" + state, e);
            }
        }
        if (InternalsConfig.encryptionChecks && !ModelExecuteOptions.isNoCrypt(context.getOptions())) {
            context.checkEncrypted();
        }

        //      LOGGER.info("CLOCKWORK: {}: {}", state, context);

        switch (state) {
        case INITIAL:
            processInitialToPrimary(context, task, result);
            break;
        case PRIMARY:
            processPrimaryToSecondary(context, task, result);
            break;
        case SECONDARY:
            processSecondary(context, task, result);
            break;
        case FINAL:
            HookOperationMode mode = processFinal(context, task, result);
            if (debugListener != null) {
                debugListener.afterSync(context);
            }
            return mode;
        }

        return invokeHooks(context, task, result);

    } catch (CommunicationException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (ConfigurationException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (ExpressionEvaluationException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (ObjectAlreadyExistsException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (ObjectNotFoundException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (PolicyViolationException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (SchemaException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (SecurityViolationException e) {
        processClockworkException(context, e, task, result);
        throw e;
    } catch (RuntimeException e) {
        processClockworkException(context, e, task, result);
        throw e;
    }
}

From source file:mx.edu.ittepic.AEEcommerce.ejbs.OperationCommerce.java

public String deleteCompany(String CompanyId) {
    Message m = new Message();
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();//  ww w.  java  2 s.  c  o  m
    try {
        Company r = new Company();
        Query q = entity.createNamedQuery("Company.findByCompanyid").setParameter("companyid",
                Integer.parseInt(CompanyId));
        r = (Company) q.getSingleResult();
        if (r == null) {
            m.setCode(404);
            m.setMsg("No se encontro");
            m.setDetail(":(");
        } else {
            entity.remove(r);
            m.setCode(200);
            m.setMsg("Todo bien");
            m.setDetail("OK");
        }
        return gson.toJson(m);

    } catch (IllegalArgumentException e) {
        m.setCode(404);
        m.setMsg(e.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (NoResultException ex) {
        m.setCode(404);
        m.setMsg(ex.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (IllegalStateException exx) {
        m.setCode(404);
        m.setMsg(exx.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (TransactionRequiredException exxx) {
        m.setCode(404);
        m.setMsg(exxx.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    }
}

From source file:mx.edu.ittepic.AEEcommerce.ejbs.OperationCommerce.java

public String deleteUsers(String userid) {
    Message m = new Message();
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();//  www . j a v a2s.c  om
    try {
        Users r = new Users();
        Query q = entity.createNamedQuery("Users.findByUserid").setParameter("userid",
                Integer.parseInt(userid));
        r = (Users) q.getSingleResult();
        if (r == null) {
            m.setCode(404);
            m.setMsg("No se encontro");
            m.setDetail(":(");
        } else {
            entity.remove(r);
            m.setCode(200);
            m.setMsg("Todo bien");
            m.setDetail("OK");
        }
        return gson.toJson(m);

    } catch (IllegalArgumentException e) {
        m.setCode(404);
        m.setMsg(e.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (NoResultException ex) {
        m.setCode(404);
        m.setMsg(ex.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (IllegalStateException exx) {
        m.setCode(404);
        m.setMsg(exx.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (TransactionRequiredException exxx) {
        m.setCode(404);
        m.setMsg(exxx.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    }
}

From source file:mx.edu.ittepic.AEEcommerce.ejbs.OperationCommerce.java

public String deleteCategory(String categoryid) {
    Message m = new Message();
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();// w  w  w.  j a v a2s .  co  m
    try {
        Category r = new Category();
        Query q = entity.createNamedQuery("Category.findByCategoryid").setParameter("categoryid",
                Integer.parseInt(categoryid));
        r = (Category) q.getSingleResult();
        if (r == null) {
            m.setCode(404);
            m.setMsg("No se encontro");
            m.setDetail(":(");
        } else {
            entity.remove(r);
            m.setCode(200);
            m.setMsg("Todo bien");
            m.setDetail("OK");
        }
        return gson.toJson(m);

    } catch (IllegalArgumentException e) {
        m.setCode(404);
        m.setMsg(e.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (NoResultException ex) {
        m.setCode(404);
        m.setMsg(ex.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (IllegalStateException exx) {
        m.setCode(404);
        m.setMsg(exx.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    } catch (TransactionRequiredException exxx) {
        m.setCode(404);
        m.setMsg(exxx.getMessage());
        m.setDetail("error");
        return gson.toJson(m);
    }
}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

private void save() {
    try {// www  . j a v  a 2  s  . c  om
        if (notificationHolderId == null) {
            // workaround the bug with re-launching and stale scheduleTime.
            // How - if there isn't a notificationHolder waiting, then this is not a response
            // to a notification.
            scheduledTime = 0L;
        }
        Event event = createEvent(experiment, scheduledTime);
        gatherResponses(event);
        experimentProviderUtil.insertEvent(event);

        deleteNotification();

        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            extras.clear();
        }
        updateAlarms();
        notifySyncService();
        showFeedback();
        finish();
    } catch (IllegalStateException ise) {
        new AlertDialog.Builder(this).setIcon(R.drawable.paco64).setTitle(R.string.required_answers_missing)
                .setMessage(ise.getMessage()).show();
    }
}