alfresco-community-repo/source/java/org/alfresco/filesys/repo/rules/ScenarioDeleteRenameOrCreate.java
Dave Ward c21a3d2740 Merged V4.1-BUG-FIX to HEAD
44765: ALF-17164: Fix failing build in case build is not run in continuous mode
   44769: ALF-17097 60k Site Performance: Admin Console | Groups | Browse Groups (include sys groups): Results isn't appeared.
      - Group page now supports search and browse of large volumes of groups. Tested up to 300,000 sites (60k sites).
        Previously this would not return.
      - In order to support large volumes of groups it is not practical to search for all root groups.
        A functional change has taken place to fix this issue.
        [Browse] (which initially displayed only root groups) now uses the search value entered by the user and the same
        query as [Search]. It could be argued that the browse functionality was not very practical anyway if there were
        a large number of root groups as the user would have to page through all the pages one at a time to get to the
        required group in order to add a new sub group. As a result of this change it is now possible to get to the
        required group much faster. As the 'browse' function uses the search value and Include System Groups checkbox
        (it already used the checkbox value) it made little sense to revert to the Search results when either of these
        is changed. As this was taking place, this has now been changed too. The [Search] and [Browse] options both now
        use the authority canned query which has been enhanced to use the sortBy field supplied by the UI.
      - Uses the authority canned query for [Search] and [Browse] searches on the Groups page.
      - Canned query may sort on "shortName", "displayName" or "authorityName"
      - Filter on displayName uses regular expressions to support ? and * wildcards
      - Canned query returns fewer (unused) columns to speed up fetch time.
      - Canned query no longer joins to alf_store as none of the values were used.
   44772: CIFS Gedit support - rename open files.
   44776: ALF-17164: Fix failing build in case build is not run in continuous mode - move generation of version.properties out of continuous mode


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@44790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-12-18 14:43:45 +00:00

147 lines
4.3 KiB
Java

/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.filesys.repo.rules;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.alfresco.filesys.repo.rules.ScenarioInstance.Ranking;
import org.alfresco.filesys.repo.rules.operations.CloseFileOperation;
import org.alfresco.filesys.repo.rules.operations.DeleteFileOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* The DeleteOnClose rename shuffle is a delete on close of a file resulting in a file being deleted followed by a
* rename or a create
*
* First case of this is Mac Mountain Lion Preview application.
* and then a new copy of the file put into place.
*
* a) DeleteOnClose fileA
* b) Close fileA
* c) Rename whatever fileA
*
* Second case First case of this is Mac Drag and drop.
* and then a new copy of the file put into place.
*
* a) Delete fileA
* b) Close fileA
* c) Create fileA
*
* Third case Gedit.
*
* a) Delete fileA
* b) Rename .goutputstream fileA
*
*/
public class ScenarioDeleteRenameOrCreate implements Scenario
{
private static Log logger = LogFactory.getLog(ScenarioDeleteRenameOrCreate.class);
/**
* The regex pattern of a close that will trigger a new instance of
* the scenario.
*/
private Pattern pattern;
private String strPattern;
private long timeout = 30000;
@Override
public ScenarioInstance createInstance(final EvaluatorContext ctx, Operation operation)
{
/**
* This scenario is triggered by a rename of a file matching
* the pattern
*/
if(operation instanceof CloseFileOperation)
{
CloseFileOperation c = (CloseFileOperation)operation;
Matcher m = pattern.matcher(c.getName());
if(m.matches() && c.getNetworkFile().hasDeleteOnClose())
{
if(logger.isDebugEnabled())
{
logger.debug("New Scenario ScenarioDeleteRenameOrCreate strPattern:" + pattern);
}
ScenarioDeleteRenameOrCreateInstance instance = new ScenarioDeleteRenameOrCreateInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;
}
}
if(operation instanceof DeleteFileOperation)
{
DeleteFileOperation c = (DeleteFileOperation)operation;
Matcher m = pattern.matcher(c.getName());
if(m.matches())
{
if(logger.isDebugEnabled())
{
logger.debug("New Scenario ScenarioDeleteRenameOrCreate strPattern:" + pattern);
}
ScenarioDeleteRenameOrCreateInstance instance = new ScenarioDeleteRenameOrCreateInstance();
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.compile(pattern, Pattern.CASE_INSENSITIVE);
this.strPattern = pattern;
}
public String getPattern()
{
return strPattern;
}
private Ranking ranking = Ranking.HIGH;
public void setRanking(Ranking ranking)
{
this.ranking = ranking;
}
public Ranking getRanking()
{
return ranking;
}
}