* Can optionally remove the hidden and index control aspects if the name of a node no longer matches the filter. * * @param fileInfo * @param both if true, will check if the node should not be hidden and remove hidden and index control * aspects if they are present * @return */ public HiddenFileInfo checkHidden(FileInfoImpl fileInfo, boolean both) { NodeRef nodeRef = fileInfo.getNodeRef(); HiddenFileInfo hiddenFileInfo = checkHidden(nodeRef, both); if(hiddenFileInfo != null) { fileInfo.setHidden(true); } return hiddenFileInfo; } /** * Hides the node by applying the hidden and not indexed aspects. The node will be hidden from clients * according to the visibility mask. * * @see getClientVisibilityMask() * @param fileInfo, file to make hidden * @param visibilityMask */ public void hideNode(FileInfoImpl fileInfo, int visibilityMask) { hideNode(fileInfo.getNodeRef(), visibilityMask); fileInfo.setHidden(true); } /** * Checks whether the file should be hidden based upon whether its name maches a set of filters and applies the hidden * and not indexed aspects if so. *
* Can optionally remove the hidden and index control aspects if the name of a node no longer matches the filter.
*
* @param nodeRef
* @param both if true, will check both if the node should not be hidden and remove hidden and index control
* aspects if they are present, and if the node should be hidden and add hidden and index control
* aspects if they are not present.
* @return HiddenFileInfo
*/
public HiddenFileInfo checkHidden(NodeRef nodeRef, boolean both)
{
if(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))
{
Boolean isHiddenFlag = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_HIDDEN_FLAG);
if(isHiddenFlag != null && isHiddenFlag)
{
logger.debug("node has hidden flag set");
// node has hidden flag - we are not going to change anything.
return null;
}
}
HiddenFileInfo filter = findMatch(nodeRef);
if(filter != null)
{
int visibilityMask = filter.getVisibilityMask();
if(!hasHiddenAspect(nodeRef))
{
// the file matches a pattern, apply the hidden and aspect control aspects
addHiddenAspect(nodeRef, visibilityMask, false);
}
if(!hasIndexControlAspect(nodeRef))
{
addIndexControlAspect(nodeRef);
}
applyHidden(nodeRef, filter, visibilityMask);
}
else if(both)
{
// the file does not match the pattern, ensure that the hidden and index control aspects are not present
if(hasHiddenAspect(nodeRef))
{
removeHiddenAspect(nodeRef);
}
if(hasIndexControlAspect(nodeRef))
{
removeIndexControlAspect(nodeRef);
}
removeHidden(nodeRef);
}
return filter;
}
/**
* Gets the visibility constraint for the given client on the given node.
*
* @param client
* @param nodeRef
*
* @return the visibility constraint for the given client and node
*/
public Visibility getVisibility(Client client, NodeRef nodeRef)
{
Visibility ret = Visibility.Visible;
if (! AuthenticationUtil.isRunAsUserTheSystemUser())
{
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))
{
Integer visibilityMask = (Integer)nodeService.getProperty(nodeRef, ContentModel.PROP_VISIBILITY_MASK);
if (visibilityMask != null)
{
if(visibilityMask.intValue() == 0)
{
ret = Visibility.NotVisible;
}
else if(client == null)
{
ret = Visibility.NotVisible;
}
else
{
ret = getVisibility(visibilityMask.intValue(), client);
}
}
else
{
// no visibility mask property, so retain backwards compatibility with 3.4 hidden aspect behaviour
if(client == Client.cifs)
{
ret = Visibility.HiddenAttribute;
}
else if(client == Client.webdav || client == Client.nfs || client == Client.imap)
{
ret = Visibility.Visible;
}
else
{
ret = Visibility.NotVisible;
}
}
}
}
return ret;
}
private class HiddenFileInfoImpl implements HiddenFileInfo
{
private Pattern filter;
private Set