mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.9 to HEAD
10531: Merged V2.2 to V2.9 9928: Optimise & consolidate get web project user role (ETWOTWO-568) 9962: Reverted rev 9902 of RuleServiceImpl 9964: Fixed transaction read-only declaration 9979: ETWOTWO-572: Allow OpenOffice to be called remotely 9987: Second attempt at fixing ETWOTWO-438: versionable aspect and invite user 10096: Fix for ETWOTWO-507 FSR Service Port 10224: Fix for ETWOTWO-507 (inconsistent results with add and delete together) 10225: Adding logging and making FSR work with absolute directories (ETWOTWO-70 and ETWOONE-81) 10254: ALFCOM-242, ALFCOM-230, ETWOTWO-437 10283: Fixed deployment installer builder to use IJ v1.2.7 10359: Add Display Group for deployment servers to JSF client (ETWOTWO-474) 10536: MT - simple setup/system test 10553: Hid domain objects completely within the UsageDeltaDAO git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10613 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,80 +24,43 @@
|
||||
*/
|
||||
package org.alfresco.repo.usage;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.node.db.NodeDaoService;
|
||||
import org.alfresco.repo.usage.hibernate.UsageDeltaImpl;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.usage.UsageService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* The implementation of the UsageService for tracking usages.
|
||||
*
|
||||
* @author Jan Vonka
|
||||
* @since 2.9
|
||||
*/
|
||||
public class UsageServiceImpl implements UsageService
|
||||
{
|
||||
private UsageDeltaDAO usageDeltaDao;
|
||||
private NodeDaoService nodeDaoService;
|
||||
|
||||
public void setUsageDeltaDao(UsageDeltaDAO usageDeltaDao)
|
||||
{
|
||||
this.usageDeltaDao = usageDeltaDao;
|
||||
}
|
||||
|
||||
public void setNodeDaoService(NodeDaoService nodeDaoService)
|
||||
{
|
||||
this.nodeDaoService = nodeDaoService;
|
||||
}
|
||||
|
||||
|
||||
public void insertDelta(NodeRef usageNodeRef, long deltaSize)
|
||||
{
|
||||
UsageDelta delta = new UsageDeltaImpl();
|
||||
|
||||
// delta properties
|
||||
delta.setNode(getNodeNotNull(usageNodeRef));
|
||||
delta.setDeltaSize(deltaSize);
|
||||
|
||||
usageDeltaDao.insertDelta(delta);
|
||||
usageDeltaDao.insertDelta(usageNodeRef, deltaSize);
|
||||
}
|
||||
|
||||
public long getTotalDeltaSize(NodeRef usageNodeRef)
|
||||
{
|
||||
return usageDeltaDao.getTotalDeltaSize(getNodeNotNull(usageNodeRef));
|
||||
return usageDeltaDao.getTotalDeltaSize(usageNodeRef);
|
||||
}
|
||||
|
||||
public Set<NodeRef> getUsageDeltaNodes()
|
||||
{
|
||||
Set<Node> nodes = usageDeltaDao.getUsageDeltaNodes();
|
||||
|
||||
// convert nodes to nodeRefs (tenant-specific)
|
||||
Set<NodeRef> results = new HashSet<NodeRef>(nodes.size());
|
||||
for (Node node : nodes)
|
||||
{
|
||||
results.add(node.getNodeRef());
|
||||
}
|
||||
return results;
|
||||
return usageDeltaDao.getUsageDeltaNodes();
|
||||
}
|
||||
|
||||
public int deleteDeltas(NodeRef usageNodeRef)
|
||||
{
|
||||
return usageDeltaDao.deleteDeltas(getNodeNotNull(usageNodeRef));
|
||||
}
|
||||
|
||||
private Node getNodeNotNull(NodeRef nodeRef) throws InvalidNodeRefException
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
|
||||
Node unchecked = nodeDaoService.getNode(nodeRef);
|
||||
if (unchecked == null)
|
||||
{
|
||||
throw new InvalidNodeRefException("Node does not exist: " + nodeRef, nodeRef);
|
||||
}
|
||||
return unchecked;
|
||||
return usageDeltaDao.deleteDeltas(usageNodeRef);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user