protected List<OCluster> getClusters() { final ODatabaseDocumentInternal database = getDatabase(); final List<OCluster> result = new ArrayList<OCluster>(); if (clusterName.endsWith("*")) { final String toMatch = clusterName.substring(0, clusterName.length() - 1).toLowerCase(Locale.ENGLISH); for (String cl : database.getStorage().getClusterNames()) { if (cl.startsWith(toMatch)) result.add(database.getStorage().getClusterByName(cl)); } } else { if (clusterId > -1) { result.add(database.getStorage().getClusterById(clusterId)); } else { result.add(database.getStorage().getClusterById(database.getStorage().getClusterIdByName(clusterName))); } } return result; }
protected void checkForSystemClusters(final ODatabaseDocumentInternal iDatabase, final int[] iClusterIds) { for (int clId : iClusterIds) { final OCluster cl = iDatabase.getStorage().getClusterById(clId); if (cl != null && cl.isSystemCluster()) { final OSecurityUser dbUser = iDatabase.getUser(); if (dbUser == null || dbUser.allow(ORule.ResourceGeneric.SYSTEM_CLUSTERS, null, ORole.PERMISSION_READ) != null) // AUTHORIZED break; } } }
/** * Enables password-based-encryption for records of the given type. * * Can only be called when creating the schema. * * @since 3.1 */ protected void enableRecordEncryption(final ODatabaseDocumentTx db, final OClass type) { OStorage storage = db.getStorage(); for (int clusterId : type.getClusterIds()) { OCluster cluster = storage.getClusterById(clusterId); try { log.debug("Enabling PBE compression for cluster: {}", cluster.getName()); cluster.set(OCluster.ATTRIBUTES.COMPRESSION, PbeCompression.NAME); } catch (IOException e) { throw new RuntimeException(e); } catch (IllegalArgumentException | OStorageException | OSecurityException e) { log.warn("Cannot enable PBE compression for cluster: {}", cluster.getName(), e); } } }
private List<com.orientechnologies.orient.core.storage.OCluster> getClusters(OCommandContext ctx) { OStorage storage = ((ODatabaseDocumentInternal) ctx.getDatabase()).getStorage(); if (starred) { List<com.orientechnologies.orient.core.storage.OCluster> result = new ArrayList<>(); for (String clusterName : storage.getClusterNames()) { if (clusterName.startsWith(name.getStringValue())) { result.add(storage.getClusterByName(clusterName)); } } return result; } else { int clusterId = ctx.getDatabase().getClusterIdByName(name.getStringValue()); if (clusterId <= 0) { throw new OCommandExecutionException("Cannot find cluster " + name); } com.orientechnologies.orient.core.storage.OCluster cluster = storage.getClusterById(clusterId); return Collections.singletonList(cluster); } }
@Override public long getClusterRecordSizeById(final int clusterId) { checkIfActive(); try { return getStorage().getClusterById(clusterId).getRecordsSize(); } catch (Exception e) { throw OException .wrapException(new ODatabaseException("Error on reading records size for cluster with id '" + clusterId + "'"), e); } }
protected void setEncryptionInternal(ODatabaseDocumentInternal database, final String iValue) { for (int cl : getClusterIds()) { final OCluster c = database.getStorage().getClusterById(cl); if (c != null) try { c.set(OCluster.ATTRIBUTES.ENCRYPTION, iValue); } catch (IOException e) { OLogManager.instance().error(this, "Can not set value of encryption parameter to '%s'", e, iValue); } } }
@Override public long getClusterRecordSizeByName(final String clusterName) { checkIfActive(); try { return getStorage().getClusterById(getClusterIdByName(clusterName)).getRecordsSize(); } catch (Exception e) { throw OException.wrapException(new ODatabaseException("Error on reading records size for cluster '" + clusterName + "'"), e); } }
int clusterId = clusterIds[i]; try { lastClusterPositions[i] = db.getStorage().getClusterById(clusterId).getLastPosition(); } catch (Exception e) { throw new RuntimeException(e);
final String inField = OrientEdgeType.CLASS_NAME.equals(edgeClass) ? "in_" : ("in_" + edgeClass); String clusterName = perThreadDbInstance.getStorage().getClusterById(clusterId).getName();
nextVerticesToCreate[i] = i; lastClusterPositions[i] = ((ODatabaseDocumentInternal)db).getStorage().getClusterById(clusterId).getLastPosition(); } catch (Exception e) { throw new RuntimeException(e);
OCluster cl = storage.getClusterById(id); db.checkForClusterPermissions(cl.getName()); cl.truncate();
database.getStorage().getClusterById(clusterIds[i]); } catch (Exception e) { throw OException.wrapException(
final OCluster cluster = currentDatabase.getStorage().getClusterById(clusterId);
/** * 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; }
if (clazz == null) { final OStorage storage = database.getStorage(); final com.orientechnologies.orient.core.storage.OCluster cluster = storage.getClusterById(clusterId);