Examples of InvalidStateException


Examples of org.apache.openjpa.util.InvalidStateException

        boolean clean = false;
        try {
            FieldMetaData fmd = _meta.getField(field);
            if (!isNew() || isFlushed()) {
                if (fmd.getUpdateStrategy() == UpdateStrategies.RESTRICT)
                    throw new InvalidStateException(_loc.get
                        ("update-restrict", fmd));
                if (fmd.getUpdateStrategy() == UpdateStrategies.IGNORE)
                    return Boolean.FALSE;
            }

            if (isEmbedded()) {
                if (isEmbeddedNotUpdatable())
                    throw new UserException(_loc.get
                        ("cant-update-embed-in-query-result")).setFailedObject
                        (getManagedInstance());
                else
                    // notify owner of change
                    _owner.dirty(_ownerIndex, Boolean.TRUE, loadFetchGroup);
            }

            // is this a direct mutation of an sco field?
            if (mutate == null) {
                switch (fmd.getDeclaredTypeCode()) {
                    case JavaTypes.COLLECTION:
                    case JavaTypes.MAP:
                    case JavaTypes.ARRAY:
                    case JavaTypes.DATE:
                    case JavaTypes.CALENDAR:
                    case JavaTypes.OBJECT:
                        mutate = Boolean.TRUE;
                        break;
                    case JavaTypes.PC:
                        mutate =
                            (fmd.isEmbedded()) ? Boolean.TRUE : Boolean.FALSE;
                        break;
                    default:
                        mutate = Boolean.FALSE; // not sco
                }
            }

            // possibly change state
            boolean active = _broker.isActive();
            clean = !_state.isDirty(); // intentional direct access

            // fire event fast before state change.
            if (clean)
                fireLifecycleEvent(LifecycleEvent.BEFORE_DIRTY);
            if (active) {
                if (_broker.getOptimistic())
                    setPCState(_state.beforeOptimisticWrite(this, field,
                        mutate.booleanValue()));
                else
                    setPCState(_state.beforeWrite(this, field,
                        mutate.booleanValue()));
            } else if (fmd.getManagement() == FieldMetaData.MANAGE_PERSISTENT) {
                if (isPersistent() && !_broker.getNontransactionalWrite())
                    throw new InvalidStateException(_loc.get
                        ("non-trans-write")).setFailedObject
                        (getManagedInstance());

                setPCState(_state.beforeNontransactionalWrite(this, field,
                    mutate.booleanValue()));
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

    /**
     * Disallows changing primary key fields for instances.
     */
    private void assertNoPrimaryKeyChange(int field) {
        if (_oid != null && _meta.getField(field).isPrimaryKey())
            throw translate(new InvalidStateException(_loc.get
                ("change-identity")).setFailedObject(getManagedInstance()));
    }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

     */
    void assertNotManagedObjectId(Object val) {
        if (val != null
            && (ImplHelper.toPersistenceCapable(val,
                 getContext().getConfiguration())).pcGetGenericContext()!= null)
            throw translate(new InvalidStateException(_loc.get
                ("managed-oid", Exceptions.toString(val),
                    Exceptions.toString(getManagedInstance()))).
                setFailedObject(getManagedInstance()));
    }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

    }

    public void setOptimistic(boolean val) {
        assertOpen();
        if ((_flags & FLAG_ACTIVE) != 0)
            throw new InvalidStateException(_loc.get("trans-active",
                "Optimistic"));

        // make sure the runtime supports it
        if (val && !_conf.supportedOptions().contains(OpenJPAConfiguration.OPTION_OPTIMISTIC))
            throw new UnsupportedException(_loc.get
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

    }

    public void setRestoreState(int val) {
        assertOpen();
        if ((_flags & FLAG_ACTIVE) != 0)
            throw new InvalidStateException(_loc.get("trans-active",
                "Restore"));

        _restoreState = val;
    }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

    public void begin() {
        beginOperation(true);
        try {
            if ((_flags & FLAG_ACTIVE) != 0)
                throw new InvalidStateException(_loc.get("active"));
            _factory.syncWithManagedTransaction(this, true);
            beginInternal();
        } finally {
            endOperation();
        }
View Full Code Here

Examples of org.fcrepo.server.errors.InvalidStateException

     * attempt to use the Management API.
     *
     * @throws ServerException
     */
    private ServerException rejectCallsFromOutsideWhileInRecoveryMode() {
        return new InvalidStateException("Server is in Journal Recovery mode.");
    }
View Full Code Here

Examples of org.hibernate.validator.InvalidStateException

      for ( InvalidValue invalidValue : invalidValues ) {
        consolidatedInvalidValues.add( invalidValue );
      }
    }
    if ( consolidatedInvalidValues.size() > 0 ) {
      throw new InvalidStateException(
          consolidatedInvalidValues.toArray( new InvalidValue[consolidatedInvalidValues.size()] ),
          entity.getClass().getName()
      );
    }
  }
View Full Code Here

Examples of org.impalaframework.exception.InvalidStateException

       //TODO introduce constants for bean names
    ModuleManagementFacade facade = ObjectUtils.cast(applicationContext.getBean("moduleManagementFacade"),
        ModuleManagementFacade.class);
   
    if (facade == null) {
      throw new InvalidStateException("Application context '" + applicationContext.getDisplayName()
          + "' does not contain bean named 'moduleManagementFacade'");
    }
   
    setNewOperationsFacade(facade);
    bundleContext.registerService(OperationsFacade.class.getName(), operations, null);
View Full Code Here

Examples of org.jboss.dna.graph.session.InvalidStateException

    /**
     * @throws InvalidStateException if session is not active
     */
    void checkSession() throws InvalidStateException {
        if (!this.session.isLive()) {
            throw new InvalidStateException(JcrI18n.sessionIsNotActive.text(this.session.sessionId()));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.