Package com.orientechnologies.orient.core.exception

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


      status = STATUS.CLOSED;
    } catch (OException e) {
      // PASS THROUGH
      throw e;
    } catch (Exception e) {
      throw new ODatabaseException("Can't delete database", e);
    }
  }
View Full Code Here


    try {
      return storage.readRecord(databaseOwner, iRid, iFetchPlan);

    } catch (Throwable t) {
      throw new ODatabaseException("Error on retrieving record " + iRid + " (cluster: "
          + storage.getPhysicalClusterNameById(iRid.clusterId) + ")", t);
    }
  }
View Full Code Here

      }
    } catch (OException e) {
      // PASS THROUGH
      throw e;
    } catch (Throwable t) {
      throw new ODatabaseException("Error on saving record " + iRid, t);
    }
  }
View Full Code Here

    return new ORecordId(clusterId, clusterPosition);
  }

  private void checkClusterLimits() {
    if (clusterId < -1)
      throw new ODatabaseException("RecordId can't support negative cluster id. You've used: " + clusterId);

    if (clusterId > CLUSTER_MAX)
      throw new ODatabaseException("RecordId can't support cluster id major than 32767. You've used: " + clusterId);
  }
View Full Code Here

    databaseOwner = this;

    try {
      recordClass = iRecordClass;
    } catch (Throwable t) {
      throw new ODatabaseException("Error on opening database '" + getName() + "'", t);
    }
    level1Cache = new OLevel1RecordCache(this);

    mvcc = OGlobalConfiguration.DB_MVCC.getValueAsBoolean();
View Full Code Here

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

      metadata = new OMetadata(this);
      metadata.create();

      user = getMetadata().getSecurity().getUser(OUser.ADMIN);
    } 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 {
      boolean wasNew = rid.isNew();

      // 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 < 0)
        rid.clusterId = iClusterName != null ? getClusterIdByName(iClusterName) : getDefaultClusterId();

      if (stream != null && stream.length > 0) {
        if (wasNew) {
          // CHECK ACCESS ON CLUSTER
          checkSecurity(ODatabaseSecurityResources.CLUSTER, ORole.PERMISSION_CREATE, iClusterName);
          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);
          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
          // ADD/UPDATE IT IN CACHE IF IT'S ACTIVE
          getLevel1Cache().updateRecord(iRecord);
          return;
        }
      }

      // GET THE LATEST VERSION. IT COULD CHANGE BECAUSE THE RECORD COULD BE BEEN LINKED FROM OTHERS
      final int realVersion = iVersion == -1 || !mvcc ? -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, stream == null || stream.length == 0);
        // NOTIFY IDENTITY HAS CHANGED
        iRecord.onAfterIdentityChanged(iRecord);
      } else {
        // UPDATE INFORMATION: VERSION
        iRecord.fill(iRecord.getDatabase(), rid, (int) result, stream, stream == null || stream.length == 0);
      }

      if (stream != null && stream.length > 0)
        callbackHooks(wasNew ? TYPE.AFTER_CREATE : TYPE.AFTER_UPDATE, iRecord);

      // ADD/UPDATE IT IN CACHE IF IT'S ACTIVE
      getLevel1Cache().updateRecord(iRecord);

    } catch (OException 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));

    try {
      callbackHooks(TYPE.BEFORE_DELETE, iRecord);

      underlying.delete(rid, iVersion);

      callbackHooks(TYPE.AFTER_DELETE, iRecord);

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

    } catch (OException 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

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.