Package com.orientechnologies.orient.core.exception

Examples of com.orientechnologies.orient.core.exception.ODatabaseException


   * <code>doc.load( "*:3" ); // LOAD THE DOCUMENT BY EARLY FETCHING UP TO 3rd LEVEL OF CONNECTIONS</code>
   * </p>
   */
  public ODocument load(final String iFetchPlan) {
    if (_database == null)
      throw new ODatabaseException("No database assigned to current record");

    Object result = null;
    try {
      result = _database.load(this, iFetchPlan);
    } catch (Exception e) {
View Full Code Here


  }

  @Override
  protected void checkOpeness() {
    if (ownerPool == null)
      throw new ODatabaseException(
          "Database instance has been released to the pool. Get another database instance from the pool with the right username and password");

    super.checkOpeness();
  }
View Full Code Here

    databaseOwner = this;

    try {
      recordClass = iRecordClass;
    } catch (Throwable t) {
      throw new ODatabaseException("Error on opening database '" + getName() + "'", t);
    }
  }
View Full Code Here

      }

      checkSecurity(ODatabaseSecurityResources.DATABASE, ORole.PERMISSION_READ);
    } catch (Exception e) {
      close();
      throw new ODatabaseException("Can't open database", e);
    }
    return (DB) this;
  }
View Full Code Here

      registerHook(new OUserTrigger());
      registerHook(new OPropertyIndexManager());
      // }

    } catch (Exception e) {
      throw new ODatabaseException("Can't create database", e);
    }
    return (DB) this;
  }
View Full Code Here

      command.setDatabase(this);

      return command;

    } catch (Exception e) {
      throw new ODatabaseException("Error on command execution", e);
    }
  }
View Full Code Here

      return;

    final ORecordId rid = (ORecordId) iRecord.getIdentity();

    if (rid == null)
      throw new ODatabaseException(
          "Can't create record because it has no identity. Probably is not a regular record or contains projections of fields rather than a full record");

    if (iRecord.getDatabase() == null)
      iRecord.setDatabase(this);

    try {
      // STREAM.LENGTH = 0 -> RECORD IN STACK: WILL BE SAVED AFTER
      byte[] stream = iRecord.toStream();

      boolean isNew = rid.isNew();
      if (isNew)
        // NOTIFY IDENTITY HAS CHANGED
        iRecord.onBeforeIdentityChanged(rid);
      else if (stream.length == 0)
        // ALREADY CREATED AND WAITING FOR THE RIGHT UPDATE (WE'RE IN A GRAPH)
        return;

      if (isNew)
        rid.clusterId = iClusterName != null ? getClusterIdByName(iClusterName) : getDefaultClusterId();

      if (stream != null && stream.length > 0) {
        if (isNew) {
          // CHECK ACCESS ON CLUSTER
          checkSecurity(ODatabaseSecurityResources.CLUSTER, ORole.PERMISSION_CREATE, iClusterName, rid.clusterId);
          if (callbackHooks(TYPE.BEFORE_CREATE, iRecord))
            // RECORD CHANGED IN TRIGGER, REACQUIRE IT
            stream = iRecord.toStream();
        } else {
          // CHECK ACCESS ON CLUSTER
          checkSecurity(ODatabaseSecurityResources.CLUSTER, ORole.PERMISSION_UPDATE, iClusterName, rid.clusterId);
          if (callbackHooks(TYPE.BEFORE_UPDATE, iRecord))
            // RECORD CHANGED IN TRIGGER, REACQUIRE IT
            stream = iRecord.toStream();
        }

        if (!iRecord.isDirty()) {
          // RECORD SAVED DURING PREVIOUS STREAMING PHASE: THIS HAPPENS FOR CIRCULAR REFERENCED RECORDS
          if (isUseCache())
            // ADD/UPDATE IT IN CACHE
            getCache().updateRecord(iRecord);
          return;
        }
      }

      // GET THE LATEST VERSION. IT COULD CHANGE BECAUSE THE RECORD COULD BE BEEN LINKED FROM OTHERS
      final int realVersion = iVersion == -1 ? -1 : iRecord.getVersion();

      // SAVE IT
      final long result = underlying.save(rid, stream, realVersion, iRecord.getRecordType());

      if (isNew) {
        // UPDATE INFORMATION: CLUSTER ID+POSITION
        iRecord.fill(iRecord.getDatabase(), rid, 0, stream);
        if (stream != null && stream.length > 0)
          callbackHooks(TYPE.AFTER_CREATE, iRecord);

        // NOTIFY IDENTITY HAS CHANGED
        iRecord.onAfterIdentityChanged(iRecord);
      } else {
        // UPDATE INFORMATION: VERSION
        iRecord.fill(iRecord.getDatabase(), rid, (int) result, stream);
        if (stream != null && stream.length > 0)
          callbackHooks(TYPE.AFTER_UPDATE, iRecord);
      }

      if (stream != null && stream.length > 0)
        // FILLED RECORD
        iRecord.unsetDirty();

      if (isUseCache())
        // ADD/UPDATE IT IN CACHE
        getCache().updateRecord(iRecord);

    } catch (ODatabaseException e) {
      // RE-THROW THE EXCEPTION
      throw e;
    } catch (OConcurrentModificationException e) {
      // RE-THROW THE EXCEPTION
      throw e;
    } catch (Throwable t) {
      // WRAP IT AS ODATABASE EXCEPTION
      throw new ODatabaseException("Error on saving record in cluster #" + iRecord.getIdentity().getClusterId(), t);
    }
  }
View Full Code Here

  public void executeDeleteRecord(final OIdentifiable iRecord, final int iVersion) {
    checkOpeness();
    final ORecordId rid = (ORecordId) iRecord.getIdentity();

    if (rid == null)
      throw new ODatabaseException(
          "Can't delete record because it has no identity. Probably was created from scratch or contains projections of fields rather than a full record");

    if (!rid.isValid())
      return;

    checkSecurity(ODatabaseSecurityResources.CLUSTER, ORole.PERMISSION_DELETE, getClusterNameById(rid.clusterId), rid.clusterId);

    try {
      callbackHooks(TYPE.BEFORE_DELETE, iRecord);

      underlying.delete(rid, iVersion);

      callbackHooks(TYPE.AFTER_DELETE, iRecord);

      // REMOVE THE RECORD FROM 1 AND 2 LEVEL CACHES
      getCache().deleteRecord(rid);

    } catch (ODatabaseException e) {
      // RE-THROW THE EXCEPTION
      throw e;

    } catch (OConcurrentModificationException e) {
      // RE-THROW THE EXCEPTION
      throw e;

    } catch (Throwable t) {
      // WRAP IT AS ODATABASE EXCEPTION
      throw new ODatabaseException("Error on deleting record in cluster #" + iRecord.getIdentity().getClusterId(), t);
    }
  }
View Full Code Here

  }

  @Override
  protected void checkOpeness() {
    if (isClosed())
      throw new ODatabaseException("Database is closed");
  }
View Full Code Here

          break;
        case LINK:
          out.writeBoolean(value != null);
          if (value != null) {
            if (!(value instanceof ORecord<?>))
              throw new ODatabaseException("Invalid property value in '" + p.getName() + "': found " + value.getClass()
                  + " while it was expected a ORecord");

            ORID rid = ((ORecord<?>) value).getIdentity();
            out.writeInt(rid.getClusterId());
            out.writeLong(rid.getClusterPosition());
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.exception.ODatabaseException

Copyright © 2018 www.massapicom. 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.