本文整理汇总了Java中javax.jcr.version.VersionException类的典型用法代码示例。如果您正苦于以下问题:Java VersionException类的具体用法?Java VersionException怎么用?Java VersionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VersionException类属于javax.jcr.version包,在下文中一共展示了VersionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remove
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
RegistryJCRItemOperationUtil.validateReadOnlyItemOpr(session);
RegistryJCRItemOperationUtil.checkRetentionPolicy(session, getNodePath());
RegistryJCRItemOperationUtil.checkRetentionHold(session, getNodePath());
try {
if (isResource) {
session.getUserRegistry().delete(path);
} else {
Resource node = session.getUserRegistry().get(path);
node.removeProperty(name);
session.getUserRegistry().put(path, node);
}
} catch (RegistryException e) {
String msg = "failed to remove the property " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
}
示例2: setProperty
import javax.jcr.version.VersionException; //导入依赖的package包/类
public Property setProperty(String s, InputStream inputStream) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
RegistryJCRItemOperationUtil.checkRetentionPolicy(registrySession,getPath());
RegistryJCRItemOperationUtil.checkRetentionHold(registrySession, getPath());
registrySession.sessionPending();
validatePropertyModifyPrivilege(s);
Resource res = null;
try {
res = registrySession.getUserRegistry().newResource();
if (inputStream != null) {
res.setContentStream(inputStream);
res.setProperty("registry.jcr.property.type", "input_stream");
registrySession.getUserRegistry().put(nodePath + "/" + s, res);
property = new RegistryProperty(nodePath + "/" + s, registrySession, s,inputStream);
}
} catch (RegistryException e) {
String msg = "failed to resolve the path of the given node or violation of repository syntax " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
isModified = true;
return property;
}
示例3: setPrimaryType
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void setPrimaryType(String s) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException {
// Check if node type already exists
registrySession.getWorkspace().getNodeTypeManager().getNodeType(s);
// if(s!= null && s.startsWith("mix")) {
// throw new ConstraintViolationException("Cannpot set mixin as primary types");
// }
try {
Resource resource = registrySession.getUserRegistry().get(nodePath);
resource.setProperty("jcr:primaryType", s);
registrySession.getUserRegistry().put(nodePath, resource);
} catch (RegistryException e) {
String msg = "failed to resolve the path of the given node or violation of repository syntax " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
}
示例4: removeMixin
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void removeMixin(String s) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException {
RegistryJCRItemOperationUtil.checkRetentionHold(registrySession, getPath());
try {
Resource resource = registrySession.getUserRegistry().get(nodePath);
if (resource.getPropertyValues("jcr:mixinTypes").contains(s)) {
resource.getPropertyValues("jcr:mixinTypes").remove(s);
} else {
throw new NoSuchNodeTypeException("No such mix node type to remove");
}
registrySession.getUserRegistry().put(nodePath, resource);
} catch (RegistryException e) {
String msg = "failed to resolve the path of the given node or violation of repository syntax " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
isModified = true;
}
示例5: remove
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
//TODO if nodetype is a mandatory one should throw ConstraintViolationException
// A read only session must not be allowed to remove a node
RegistryJCRItemOperationUtil.validateReadOnlyItemOpr(registrySession);
try {
RegistryJCRItemOperationUtil.checkRetentionPolicyWithParent(registrySession,getPath());
RegistryJCRItemOperationUtil.checkRetentionHoldWithParent(registrySession,getPath());
if (registrySession.getUserRegistry().resourceExists(nodePath)) {
registrySession.removeItem(nodePath);
} else {
throw new InvalidItemStateException("Node " + nodePath + " has already removed from another session");
}
} catch (RegistryException e) {
log.error("Error occured while removing the node at" + nodePath);
}
isRemoved = true;
}
示例6: removeItem
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void removeItem(String s) throws VersionException, LockException, ConstraintViolationException,
AccessDeniedException, RepositoryException {
try {
if (userRegistry.resourceExists(s)) {
userRegistry.delete(s);
} else {
throw new PathNotFoundException("No such path exists" + s);
}
} catch (RegistryException e) {
e.printStackTrace();
}
}
示例7: setRetentionPolicy
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void setRetentionPolicy(String s, RetentionPolicy retentionPolicy) throws PathNotFoundException, AccessDeniedException, LockException, VersionException, RepositoryException {
if(session.getWorkspace().getLockManager().holdsLock(s)) {
throw new LockException("Cannot set retention policy on a locked node");
}
if(RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(session.getUserID())){
throw new AccessDeniedException("Read-only session doesn't have " +
"sufficient privileges to retrieve retention policy.");
}
//Invalid path check
if (!isPathValid(s)) {
throw new RepositoryException("Cannot apply invalid path for retention policies " + s);
}
if (!isValidJCRName(retentionPolicy.getName())) {
throw new RepositoryException("Cannot apply invalid name for retention policies " + s);
}
if (!isPathExists(s)) {
throw new PathNotFoundException("No such Path exists for apply retention: " + s);
}
pendingRetentionPolicies.put(s, retentionPolicy);
// EffectiveRetentionUtil.setRetentionPolicyToRegistry(session,s,retentionPolicy);
}
示例8: setAction
import javax.jcr.version.VersionException; //导入依赖的package包/类
private void setAction(final Node node, Node actions, String actionName, String implClass) throws RepositoryException, PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException, ItemExistsException, AccessDeniedException {
String propName = "default" + StringUtils.capitalize(actionName);
if (node.hasProperty(propName)) {
Property defaultAction = node.getProperty(propName);
if (defaultAction.getBoolean()) {
actions.addNode(actionName, NodeTypes.ContentNode.NAME).setProperty("class", implClass);
}
defaultAction.remove();
}
}
示例9: addNode
import javax.jcr.version.VersionException; //导入依赖的package包/类
@Override
public Node addNode(String relPath, String primaryNodeTypeName) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
Node node = new NodeImpl(session, Paths.resolve(getPath(), relPath));
node.setPrimaryType(primaryNodeTypeName);
session.changeItem(this);
return node;
}
示例10: setProperty
import javax.jcr.version.VersionException; //导入依赖的package包/类
@Override
public Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
if (value == null) {
if (hasProperty(name))
getProperty(name).remove();
return null;
}
PropertyImpl property = getOrCreateProperty(name);
property.setValue(value);
session.changeItem(this);
return property;
}
示例11: PropertyImpl
import javax.jcr.version.VersionException; //导入依赖的package包/类
public PropertyImpl(@Nonnull SessionImpl session, @Nonnull String path, @Nonnull String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
this(session, path);
List<Value> stringValues = new ArrayList<>(values.length);
for (String value : values)
stringValues.add(new ValueImpl(value));
setValue(stringValues.toArray(new Value[stringValues.size()]));
}
示例12: setValue
import javax.jcr.version.VersionException; //导入依赖的package包/类
@Override
public void setValue(@Nonnull String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
List<Value> valueList = new ArrayList<>(values.length);
for (String value : values)
valueList.add(new ValueImpl(value));
setValue(valueList.toArray(new Value[valueList.size()]));
}
示例13: asRepositoryException
import javax.jcr.version.VersionException; //导入依赖的package包/类
/**
* Wraps the given {@link CommitFailedException} instance using the
* appropriate {@link javax.jcr.RepositoryException} subclass based on the
* {@link CommitFailedException#getType() type} of the given exception.
*
* @param message The exception message.
* @return matching repository exception
*/
public RepositoryException asRepositoryException(@Nonnull String message) {
if (isConstraintViolation()) {
return new ConstraintViolationException(message, this);
} else if (isOfType(NAMESPACE)) {
return new NamespaceException(message, this);
} else if (isOfType(NODE_TYPE)) {
return new NoSuchNodeTypeException(message, this);
} else if (isAccessViolation()) {
return new AccessDeniedException(message, this);
} else if (isAccessControlViolation()) {
return new AccessControlException(message, this);
} else if (isOfType(INTEGRITY)) {
return new ReferentialIntegrityException(message, this);
} else if (isOfType(STATE)) {
return new InvalidItemStateException(message, this);
} else if (isOfType(MERGE)) {
return new InvalidItemStateException(message, this);
} else if (isOfType(VERSION)) {
return new VersionException(message, this);
} else if (isOfType(LABEL_EXISTS)) {
return new LabelExistsVersionException(message, this);
} else if (isOfType(LOCK)) {
return new LockException(message, this);
} else if (isOfType(UNSUPPORTED)) {
return new UnsupportedRepositoryOperationException(message, this);
} else {
return new RepositoryException(message, this);
}
}
示例14: copy
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void copy(String s, String s1) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
// A read only session must not be allowed to copy a node
RegistryJCRItemOperationUtil.validateReadOnlyItemOpr(registrySession);
try {
if (userRegistry != null) {
userRegistry.copy(s, s1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: move
import javax.jcr.version.VersionException; //导入依赖的package包/类
public void move(String s, String s1) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
// A read only session must not be allowed to move a node
RegistryJCRItemOperationUtil.validateReadOnlyItemOpr(registrySession);
try {
if (userRegistry.resourceExists(s)) {
userRegistry.move(s, s1);
}
} catch (RegistryException e) {
throw new RepositoryException("RegistryException occurred at Registry level");
}
}