use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class PermissionServiceImpl method getAllSetPermissions.
@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public Set<AccessPermission> getAllSetPermissions(StoreRef storeRef) {
HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
NodePermissionEntry nodePremissionEntry = getSetPermissions(storeRef);
for (PermissionEntry pe : nodePremissionEntry.getPermissionEntries()) {
accessPermissions.add(new AccessPermissionImpl(getPermission(pe.getPermissionReference()), pe.getAccessStatus(), pe.getAuthority(), pe.getPosition()));
}
return accessPermissions;
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class LockServiceImpl method getLockStatus.
/**
* Gets the lock status for a node and a user name
*
* @param nodeRef the node reference
* @param userName the user name
* @return the lock status
*/
@Extend(traitAPI = LockServiceTrait.class, extensionAPI = LockServiceExtension.class)
public LockStatus getLockStatus(NodeRef nodeRef, String userName) {
Pair<LockState, LockStatus> stateAndStatus = getLockStateAndStatus(nodeRef, userName);
LockStatus lockStatus = stateAndStatus.getSecond();
return lockStatus;
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class LockServiceImpl method getAdditionalInfo.
@Override
@Extend(traitAPI = LockServiceTrait.class, extensionAPI = LockServiceExtension.class)
public String getAdditionalInfo(NodeRef nodeRef) {
LockState lockState = getLockState(nodeRef);
String additionalInfo = lockState.getAdditionalInfo();
return additionalInfo;
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class LockServiceImpl method lock.
/**
* @see org.alfresco.service.cmr.lock.LockService#lock(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.lock.LockType, int, Lifetime, String)
*/
@Override
@Extend(traitAPI = LockServiceTrait.class, extensionAPI = LockServiceExtension.class)
public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire, Lifetime lifetime, String additionalInfo) {
invokeBeforeLock(nodeRef, lockType);
if (lifetime.equals(Lifetime.EPHEMERAL) && (timeToExpire > MAX_EPHEMERAL_LOCK_SECONDS)) {
throw new IllegalArgumentException("Attempt to create ephemeral lock for " + timeToExpire + " seconds - exceeds maximum allowed time.");
}
if (lifetime.equals(Lifetime.EPHEMERAL) && (timeToExpire > ephemeralExpiryThreshold)) {
lifetime = Lifetime.PERSISTENT;
}
nodeRef = tenantService.getName(nodeRef);
// Get the current user name
String userName = getUserName();
// Set a default value
if (lockType == null) {
lockType = LockType.WRITE_LOCK;
}
// Get the current lock info and status for the node ref.
Pair<LockState, LockStatus> statusAndState = getLockStateAndStatus(nodeRef, userName);
LockState currentLockInfo = statusAndState.getFirst();
LockStatus currentLockStatus = statusAndState.getSecond();
if (LockStatus.LOCKED.equals(currentLockStatus) == true) {
// Error since we are trying to lock a locked node
throw new UnableToAquireLockException(nodeRef);
} else if (LockStatus.NO_LOCK.equals(currentLockStatus) == true || LockStatus.LOCK_EXPIRED.equals(currentLockStatus) == true || LockStatus.LOCK_OWNER.equals(currentLockStatus) == true) {
final Date expiryDate = makeExpiryDate(timeToExpire);
// Store the lock in the appropriate place.
if (lifetime == Lifetime.PERSISTENT) {
lockableAspectInterceptor.disableForThread();
try {
// Add lock aspect if not already present
ensureLockAspect(nodeRef);
persistLockProps(nodeRef, lockType, lifetime, userName, expiryDate, additionalInfo);
} finally {
lockableAspectInterceptor.enableForThread();
}
} else if (lifetime == Lifetime.EPHEMERAL) {
// Store the lock only in memory.
LockState lock = LockState.createLock(nodeRef, lockType, userName, expiryDate, lifetime, additionalInfo);
lockStore.set(nodeRef, lock);
// Record the NodeRef being locked and its last known lockstate. This allows
// it to be reverted to this state on rollback.
TransactionalResourceHelper.getMap(KEY_MODIFIED_NODES).put(nodeRef, currentLockInfo);
AlfrescoTransactionSupport.bindListener(this);
} else {
throw new IllegalStateException(lifetime.getClass().getSimpleName() + " is not a valid value: " + lifetime.toString());
}
}
}
use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.
the class RatingServiceImpl method getRatingRollup.
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.rating.RatingService#getRatingRollup(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String)
*/
@Extend(traitAPI = RatingServiceTrait.class, extensionAPI = RatingServiceExtension.class)
public Serializable getRatingRollup(NodeRef targetNode, String ratingSchemeName, String ratingRollupName) {
RatingScheme scheme = schemeRegistry.getRatingSchemes().get(ratingSchemeName);
if (scheme == null) {
throw new RatingServiceException("Cannot retrieve rollup. Unrecognized rating scheme " + ratingSchemeName);
}
QName rollupAspectName = ratingNamingConventions.getRollupAspectNameFor(scheme);
Serializable result = null;
// If the rated node has the rollup aspect applied
if (nodeService.hasAspect(targetNode, rollupAspectName)) {
QName rollupPropertyName = ratingNamingConventions.getRollupPropertyNameFor(scheme, ratingRollupName);
result = nodeService.getProperty(targetNode, rollupPropertyName);
}
return result;
}
Aggregations