use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.
the class Checkin method persisted.
/**
* Invalidate the target <code>NodeState</code>.
*
* @see Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
try {
NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
if (vhe != null) {
vhe.invalidate(true);
}
} catch (RepositoryException e) {
log.debug("Failed to access Version history entry -> skip invalidation.", e);
}
Iterator<PropertyEntry> entries = ((NodeEntry) nodeState.getHierarchyEntry()).getPropertyEntries();
while (entries.hasNext()) {
PropertyEntry pe = entries.next();
pe.invalidate(false);
}
nodeState.getHierarchyEntry().invalidate(false);
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.
the class Checkout method persisted.
/**
* Invalidate the target <code>NodeState</code>.
*
* @see Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
try {
NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
if (vhe != null) {
vhe.invalidate(true);
}
} catch (RepositoryException e) {
log.warn("Failed to access Version history entry -> skip invalidation.", e);
}
// non-recursive invalidation (but including all properties)
NodeEntry nodeEntry = (NodeEntry) nodeState.getHierarchyEntry();
Iterator<PropertyEntry> entries = nodeEntry.getPropertyEntries();
while (entries.hasNext()) {
PropertyEntry pe = entries.next();
pe.invalidate(false);
}
nodeEntry.invalidate(false);
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.
the class Checkpoint method persisted.
/**
* Invalidate the target <code>NodeState</code>.
*
* @see org.apache.jackrabbit.jcr2spi.operation.Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
try {
NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
if (vhe != null) {
vhe.invalidate(true);
}
} catch (RepositoryException e) {
log.warn("Failed to access Version history entry -> skip invalidation.", e);
}
// non-recursive invalidation (but including all properties)
NodeEntry nodeEntry = (NodeEntry) nodeState.getHierarchyEntry();
Iterator<PropertyEntry> entries = nodeEntry.getPropertyEntries();
while (entries.hasNext()) {
PropertyEntry pe = entries.next();
pe.invalidate(false);
}
nodeEntry.invalidate(false);
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.
the class LockRelease method persisted.
/**
* Invalidates the <code>NodeState</code> that has been unlocked and all its
* child properties.
*
* @see Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
// non-recursive invalidation but including all properties
NodeEntry nodeEntry = nodeState.getNodeEntry();
Iterator<PropertyEntry> entries = nodeEntry.getPropertyEntries();
while (entries.hasNext()) {
PropertyEntry pe = entries.next();
pe.invalidate(false);
}
nodeEntry.invalidate(false);
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.
the class SessionImporter method importProperty.
/**
*
* @param pi
* @param parentState
* @param resolver
* @throws RepositoryException
* @throws ConstraintViolationException
*/
private void importProperty(PropInfo pi, NodeState parentState, NamePathResolver resolver) throws RepositoryException, ConstraintViolationException {
Name propName = pi.getName();
TextValue[] tva = pi.getValues();
int infoType = pi.getType();
PropertyState propState = null;
QPropertyDefinition def = null;
NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
PropertyEntry pEntry = parentEntry.getPropertyEntry(propName);
if (pEntry != null) {
// a property with that name already exists...
try {
PropertyState existing = pEntry.getPropertyState();
def = existing.getDefinition();
if (def.isProtected()) {
// skip protected property
log.debug("skipping protected property " + LogUtil.safeGetJCRPath(existing, session.getPathResolver()));
return;
}
if (def.isAutoCreated() && (existing.getType() == infoType || infoType == PropertyType.UNDEFINED) && def.isMultiple() == existing.isMultiValued()) {
// this property has already been auto-created, no need to create it
propState = existing;
} else {
throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getPathResolver()));
}
} catch (ItemNotFoundException e) {
// property doesn't exist any more
// -> ignore
}
}
Name[] parentNtNames = parentState.getAllNodeTypeNames();
if (def == null) {
// there's no property with that name, find applicable definition
if (tva.length == 1) {
// could be single- or multi-valued (n == 1)
def = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, propName, infoType);
} else {
// can only be multi-valued (n == 0 || n > 1)
def = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, propName, infoType, true);
}
if (def.isProtected()) {
// skip protected property
log.debug("skipping protected property " + propName);
return;
}
}
// retrieve the target property type needed for creation of QValue(s)
// including an eventual conversion. the targetType is then needed for
// setting/updating the type of the property-state.
int targetType = def.getRequiredType();
if (targetType == PropertyType.UNDEFINED) {
if (infoType == PropertyType.UNDEFINED) {
targetType = PropertyType.STRING;
} else {
targetType = infoType;
}
}
QValue[] values = getPropertyValues(pi, targetType, def.isMultiple(), resolver);
if (propState == null) {
// create new property
Operation ap = AddProperty.create(parentState, propName, targetType, def, values);
stateMgr.execute(ap);
propState = parentEntry.getPropertyEntry(propName).getPropertyState();
} else {
// modify value of existing property
Operation sp = SetPropertyValue.create(propState, values, targetType);
stateMgr.execute(sp);
}
// store reference for later resolution
if (propState.getType() == PropertyType.REFERENCE) {
refTracker.processedReference(propState);
}
}
Aggregations