private static void notifyInvolvedClasses(int[] clusterIdsToIndex) { if (clusterIdsToIndex == null || clusterIdsToIndex.length == 0) return; final ODatabaseDocumentInternal database = getDatabase(); // UPDATE INVOLVED CLASSES final Set<String> classes = new HashSet<>(); for (int clusterId : clusterIdsToIndex) { final OClass cls = database.getMetadata().getSchema().getClassByClusterId(clusterId); if (cls instanceof OClassImpl && !classes.contains(cls.getName())) { ((OClassImpl) cls).onPostIndexManagement(); classes.add(cls.getName()); } } }
return getDatabase().getMetadata().getSchema().getClassByClusterId(new ORecordId(iTarget).getClusterId()); return null; OClass aClass = db.getMetadata().getSchema().getClassByClusterId(aCluster.getId()); if(aClass == null){ return null; OCluster cluster = db.getStorage().getClusterByName(clusterName); if (cluster != null) { return db.getMetadata().getSchema().getClassByClusterId(cluster.getId());
OClass oClass = db.getMetadata().getSchema().getClassByClusterId(clusterId); if (oClass != null) { long upperBound;
public static int[] readableClusters(final ODatabaseDocument db, final int[] iClusterIds) { List<Integer> listOfReadableIds = new ArrayList<Integer>(); boolean all = true; for (int clusterId : iClusterIds) { try { ////////// // This will exclude (filter out) any specific classes without explicit read permission. // getMetadata().getImmutableSchemaSnapshot()? final OClass clazz = db.getMetadata().getSchema().getClassByClusterId(clusterId); if (clazz != null) db.checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_READ, clazz.getName()); ////////// final String clusterName = db.getClusterNameById(clusterId); db.checkSecurity(ORule.ResourceGeneric.CLUSTER, ORole.PERMISSION_READ, clusterName); listOfReadableIds.add(clusterId); } catch (OSecurityAccessException ignore) { all = false; // if the cluster is inaccessible it's simply not processed in the list.add } } if (all) // JUST RETURN INPUT ARRAY (FASTER) return iClusterIds; final int[] readableClusterIds = new int[listOfReadableIds.size()]; int index = 0; for (int clusterId : listOfReadableIds) { readableClusterIds[index++] = clusterId; } return readableClusterIds; }
/** * Creates a new instance in memory of the specified class, linked by the Record Id to the persistent one. New instances are not * persistent until {@link #save()} is called. * * @param iClassName Class name * @param iRID Record Id */ public ODocument(final String iClassName, final ORID iRID) { this(iClassName); _recordId = (ORecordId) iRID; final ODatabaseDocumentInternal database = getDatabaseInternal(); if (_recordId.getClusterId() > -1) { final OSchema schema = database.getMetadata().getImmutableSchemaSnapshot(); final OClass cls = schema.getClassByClusterId(_recordId.getClusterId()); if (cls != null && !cls.getName().equals(iClassName)) throw new IllegalArgumentException( "Cluster id does not correspond class name should be " + iClassName + " but found " + cls.getName()); } _dirty = false; _contentChanged = false; _status = STATUS.NOT_LOADED; }
OCluster cluster = db.getStorage().getClusterByName(clusterName); if(cluster != null){ clazz = db.getMetadata().getSchema().getClassByClusterId(cluster.getId()); if(clazz != null){ className = clazz.getName();
OClass clazz = db.getMetadata().getSchema().getClassByClusterId(clusterId); if (clazz == null) { tryByIndex = false;
private void fetchClassName() { final ODatabaseDocumentInternal database = getDatabaseIfDefinedInternal(); if (database != null && database.getStorageVersions() != null) { if (_recordId.getClusterId() < 0) { checkForLoading(); checkForFields(ODocumentHelper.ATTRIBUTE_CLASS); } else { final OSchema schema = database.getMetadata().getImmutableSchemaSnapshot(); if (schema != null) { OClass _clazz = schema.getClassByClusterId(_recordId.getClusterId()); if (_clazz != null) _className = _clazz.getName(); } } } else { // CLASS NOT FOUND: CHECK IF NEED LOADING AND UNMARSHALLING checkForLoading(); checkForFields(ODocumentHelper.ATTRIBUTE_CLASS); } }
targetClass = new OIdentifier("E"); } else { OClass clazz = db.getMetadata().getSchema().getClassByClusterId(db.getClusterIdByName(targetClusterName.getStringValue())); if (clazz != null) { targetClass = new OIdentifier(clazz.getName());
totalTombstones += tombstones; final OClass cls = currentDatabase.getMetadata().getSchema().getClassByClusterId(clusterId); final String className = cls != null ? cls.getName() : null;
/** * Execute the command. */ public Object execute(final Map<Object, Object> iArgs) { if (clusterName == null) throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); final ODatabaseDocumentInternal database = getDatabase(); final int clusterId = database.getClusterIdByName(clusterName); if (clusterId < 0) { throw new ODatabaseException("Cluster with name " + clusterName + " does not exist"); } final OSchema schema = database.getMetadata().getSchema(); final OClass clazz = schema.getClassByClusterId(clusterId); if (clazz == null) { final OStorage storage = database.getStorage(); final OCluster cluster = storage.getClusterById(clusterId); if (cluster == null) { throw new ODatabaseException("Cluster with name " + clusterName + " does not exist"); } try { database.checkForClusterPermissions(cluster.getName()); cluster.truncate(); } catch (IOException ioe) { throw OException.wrapException(new ODatabaseException("Error during truncation of cluster with name " + clusterName), ioe); } } else { clazz.truncateCluster(clusterName); } return true; }
final OClass clazz = schema.getClassByClusterId(clusterId); if (clazz == null) { final OStorage storage = database.getStorage();