use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.
the class NodeImpl method removeChildProperty.
protected void removeChildProperty(Name propName) throws RepositoryException {
// modify the state of 'this', i.e. the parent node
NodeState thisState = (NodeState) getOrCreateTransientItemState();
// remove the property entry
if (!thisState.removePropertyName(propName)) {
String msg = "failed to remove property " + propName + " of " + this;
log.debug(msg);
throw new RepositoryException(msg);
}
// remove property
PropertyId propId = new PropertyId(thisState.getNodeId(), propName);
itemMgr.getItem(propId).setRemoved();
}
use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.
the class NodeImpl method isCheckedOut.
// ------------------------------< versioning support: public Node methods >
/**
* {@inheritDoc}
*/
public boolean isCheckedOut() throws RepositoryException {
// check state of this instance
sanityCheck();
// otherwise it would had been impossible to add it in the first place
if (isNew()) {
return true;
}
// this would have a negative impact on performance though...
try {
NodeState state = getNodeState();
while (!state.hasPropertyName(JCR_ISCHECKEDOUT)) {
ItemId parentId = state.getParentId();
if (parentId == null) {
// root reached or out of hierarchy
return true;
}
state = (NodeState) sessionContext.getItemStateManager().getItemState(parentId);
}
PropertyId id = new PropertyId(state.getNodeId(), JCR_ISCHECKEDOUT);
PropertyState ps = (PropertyState) sessionContext.getItemStateManager().getItemState(id);
InternalValue[] values = ps.getValues();
if (values == null || values.length != 1) {
// in which case it's probably not mix:versionable
return true;
}
return values[0].getBoolean();
} catch (ItemStateException e) {
throw new RepositoryException(e);
}
}
use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.
the class ItemManager method propertyExists.
/**
* Checks whether a property exists at the specified path.
*
* @param path path to the property to be checked
* @return true if a property exists at the specified path
*/
public boolean propertyExists(Path path) {
try {
sanityCheck();
PropertyId id = hierMgr.resolvePropertyPath(path);
return (id != null) && itemExists(id, path);
} catch (RepositoryException re) {
return false;
}
}
use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.
the class ItemManager method hasChildProperties.
/**
* @param parentId
* @return
* @throws ItemNotFoundException
* @throws AccessDeniedException
* @throws RepositoryException
*/
synchronized boolean hasChildProperties(NodeId parentId) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
sanityCheck();
ItemData data = getItemData(parentId);
if (!data.isNode()) {
String msg = "can't list child properties of property " + parentId;
log.debug(msg);
throw new RepositoryException(msg);
}
Iterator<Name> iter = ((NodeState) data.getState()).getPropertyNames().iterator();
while (iter.hasNext()) {
Name propName = iter.next();
// make sure any of the properties can be read.
if (canRead(data, new PropertyId(parentId, propName))) {
return true;
}
}
return false;
}
use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.
the class GarbageCollector method scanPersistenceManagersByNodeInfos.
private void scanPersistenceManagersByNodeInfos() throws RepositoryException, ItemStateException {
int pmCount = 0;
for (IterablePersistenceManager pm : pmList) {
pmCount++;
int count = 0;
Map<NodeId, NodeInfo> batch = pm.getAllNodeInfos(null, NODESATONCE);
while (!batch.isEmpty()) {
NodeId lastId = null;
for (NodeInfo info : batch.values()) {
count++;
if (count % 1000 == 0) {
LOG.debug(pm.toString() + " (" + pmCount + "/" + pmList.length + "): analyzed " + count + " nodes...");
}
lastId = info.getId();
if (callback != null) {
callback.beforeScanning(null);
}
if (info.hasBlobsInDataStore()) {
try {
NodeState state = pm.load(info.getId());
Set<Name> propertyNames = state.getPropertyNames();
for (Name name : propertyNames) {
PropertyId pid = new PropertyId(info.getId(), name);
PropertyState ps = pm.load(pid);
if (ps.getType() == PropertyType.BINARY) {
for (InternalValue v : ps.getValues()) {
// getLength will update the last modified date
// if the persistence manager scan is running
v.getLength();
}
}
}
} catch (NoSuchItemStateException ignored) {
// the node may have been deleted in the meantime
}
}
}
batch = pm.getAllNodeInfos(lastId, NODESATONCE);
}
}
NodeInfo.clearPool();
}
Aggregations