Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2016-04-26 13:03:25 +00:00
parent 8674e2bfc8
commit dc6b2852d0
830 changed files with 142585 additions and 142585 deletions

View File

@@ -1,163 +1,163 @@
package org.alfresco.filesys.repo.rules;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.filesys.repo.rules.ScenarioInstance.Ranking;
import org.alfresco.filesys.repo.rules.operations.CreateFileOperation;
import org.alfresco.filesys.repo.rules.operations.OpenFileOperation;
import org.alfresco.filesys.repo.rules.operations.RenameFileOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* The Open File Scenario is a sequence of multiple openFile operations
*
* Only on the last close does the repo get closed. Open Files in the middle
* share the same file handle.
*
* For example:
*
* 1) open(readOnly)
* 2) open(readWrite)
* 3) open(readOnly) - does nothing.
* 4) close - does nothing
* 5) close - does nothing
* 6) close - updates the repo
*/
public class ScenarioOpenFile implements Scenario
{
private static Log logger = LogFactory.getLog(ScenarioOpenFile.class);
private String pattern;
private long timeout = 300000;
@Override
public ScenarioInstance createInstance(final EvaluatorContext ctx, Operation operation)
{
/**
* This scenario is triggered by an open or create of a new file
*/
if(operation instanceof CreateFileOperation)
{
CreateFileOperation c = (CreateFileOperation)operation;
if(c.getName() == null)
{
logger.debug("c.getName is null! - scenario not active");
return null;
}
if(c.getName().matches(pattern))
{
if(checkScenarioActive(c.getName(),ctx.getScenarioInstances()))
{
logger.debug("scenario already active for name" + c.getName());
return null;
}
if(logger.isDebugEnabled())
{
logger.debug("New Open File Instance for CreateFileOperation:" + c);
}
ScenarioOpenFileInstance instance = new ScenarioOpenFileInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;
}
}
if(operation instanceof OpenFileOperation)
{
OpenFileOperation o = (OpenFileOperation)operation;
if(o.getName() == null)
{
logger.debug("o.getName is null! - scenario not active");
return null;
}
if(o.getName().matches(pattern))
{
if(checkScenarioActive(o.getName(),ctx.getScenarioInstances()))
{
logger.debug("scenario already active for name" + o.getName());
return null;
}
if(logger.isDebugEnabled())
{
logger.debug("New Open File Instance for OpenFileOperation:" + o);
}
ScenarioOpenFileInstance instance = new ScenarioOpenFileInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;
}
}
// No not interested.
return null;
}
public void setTimeout(long timeout)
{
this.timeout = timeout;
}
public long getTimeout()
{
return timeout;
}
public void setPattern(String pattern)
{
this.pattern = pattern;
}
public String getPattern()
{
return pattern;
}
private Ranking ranking = Ranking.HIGH;
public void setRanking(Ranking ranking)
{
this.ranking = ranking;
}
public Ranking getRanking()
{
return ranking;
}
/**
* Check whether there is already an instance of the ScenarioOpenFile for the file
*/
private boolean checkScenarioActive(String name, final List<ScenarioInstance> currentInstances)
{
for(ScenarioInstance instance: currentInstances)
{
if(instance instanceof ScenarioOpenFileInstance)
{
ScenarioOpenFileInstance i = (ScenarioOpenFileInstance)instance;
if(i.getName() != null && name != null)
{
if(i.getName().equalsIgnoreCase(name))
{
return true;
}
}
}
}
return false;
}
}
package org.alfresco.filesys.repo.rules;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.filesys.repo.rules.ScenarioInstance.Ranking;
import org.alfresco.filesys.repo.rules.operations.CreateFileOperation;
import org.alfresco.filesys.repo.rules.operations.OpenFileOperation;
import org.alfresco.filesys.repo.rules.operations.RenameFileOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* The Open File Scenario is a sequence of multiple openFile operations
*
* Only on the last close does the repo get closed. Open Files in the middle
* share the same file handle.
*
* For example:
*
* 1) open(readOnly)
* 2) open(readWrite)
* 3) open(readOnly) - does nothing.
* 4) close - does nothing
* 5) close - does nothing
* 6) close - updates the repo
*/
public class ScenarioOpenFile implements Scenario
{
private static Log logger = LogFactory.getLog(ScenarioOpenFile.class);
private String pattern;
private long timeout = 300000;
@Override
public ScenarioInstance createInstance(final EvaluatorContext ctx, Operation operation)
{
/**
* This scenario is triggered by an open or create of a new file
*/
if(operation instanceof CreateFileOperation)
{
CreateFileOperation c = (CreateFileOperation)operation;
if(c.getName() == null)
{
logger.debug("c.getName is null! - scenario not active");
return null;
}
if(c.getName().matches(pattern))
{
if(checkScenarioActive(c.getName(),ctx.getScenarioInstances()))
{
logger.debug("scenario already active for name" + c.getName());
return null;
}
if(logger.isDebugEnabled())
{
logger.debug("New Open File Instance for CreateFileOperation:" + c);
}
ScenarioOpenFileInstance instance = new ScenarioOpenFileInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;
}
}
if(operation instanceof OpenFileOperation)
{
OpenFileOperation o = (OpenFileOperation)operation;
if(o.getName() == null)
{
logger.debug("o.getName is null! - scenario not active");
return null;
}
if(o.getName().matches(pattern))
{
if(checkScenarioActive(o.getName(),ctx.getScenarioInstances()))
{
logger.debug("scenario already active for name" + o.getName());
return null;
}
if(logger.isDebugEnabled())
{
logger.debug("New Open File Instance for OpenFileOperation:" + o);
}
ScenarioOpenFileInstance instance = new ScenarioOpenFileInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;
}
}
// No not interested.
return null;
}
public void setTimeout(long timeout)
{
this.timeout = timeout;
}
public long getTimeout()
{
return timeout;
}
public void setPattern(String pattern)
{
this.pattern = pattern;
}
public String getPattern()
{
return pattern;
}
private Ranking ranking = Ranking.HIGH;
public void setRanking(Ranking ranking)
{
this.ranking = ranking;
}
public Ranking getRanking()
{
return ranking;
}
/**
* Check whether there is already an instance of the ScenarioOpenFile for the file
*/
private boolean checkScenarioActive(String name, final List<ScenarioInstance> currentInstances)
{
for(ScenarioInstance instance: currentInstances)
{
if(instance instanceof ScenarioOpenFileInstance)
{
ScenarioOpenFileInstance i = (ScenarioOpenFileInstance)instance;
if(i.getName() != null && name != null)
{
if(i.getName().equalsIgnoreCase(name))
{
return true;
}
}
}
}
return false;
}
}