10,6 → 10,8 |
import pt.estgp.estgweb.domain.dao.DaoFactory; |
import pt.estgp.estgweb.utils.RoleManager; |
import pt.estgp.estgweb.utils.Dom4jUtil; |
import pt.estgp.estgweb.utils.ConfigProperties; |
import pt.estgp.estgweb.Globals; |
import org.apache.log4j.Logger; |
import org.apache.lucene.queryParser.QueryParser; |
import org.apache.lucene.queryParser.ParseException; |
23,6 → 25,8 |
import java.util.ArrayList; |
import java.util.Map; |
import java.util.HashMap; |
import java.util.regex.Pattern; |
import java.util.regex.Matcher; |
import java.net.URLEncoder; |
import java.net.URL; |
|
186,6 → 190,10 |
defaultResult.setTitle(fileName.getText()); |
defaultResult.setSizeKb(fileSizeKB.getTextTrim()); |
defaultResult.setDirectory(relativePathStr); |
|
|
|
|
defaultResult.setDate(fileDateLastModified.getTextTrim()); |
defaultResult.setMime(fileType.getTextTrim()); |
// defaultResult.setSubTitle(courseUnit.getCourseName()); |
209,7 → 217,7 |
XPath xPathCollection = dom.createXPath("./files:collection"); |
xPathFileUrl.setNamespaceURIs(namespaces); |
Element collection = (Element) xPathCollection.selectSingleNode(doc); |
defaultResult.setSubTitle(collection.getTextTrim()); |
defaultResult.setSubTitle(formatSubtitle(relativePathStr,collection.getTextTrim())); |
|
|
XPath xPathFragment = dom.createXPath("./files:snippet/files:fragment"); |
278,8 → 286,38 |
|
|
|
static HashMap<String, Pattern> patterns = new HashMap<String,Pattern>(); |
private String formatSubtitle(String path, String collection) |
{ |
path = path.trim(); |
if(path.startsWith("\\") || path.startsWith("/")) |
path = path.substring(1); |
List<String> regexProps = ConfigProperties.getListProperties("srusource.path.condition.pattern"); |
for(String regexProp: regexProps) |
{ |
String id = regexProp.substring(regexProp.lastIndexOf(".")); |
String patternStr = ConfigProperties.getProperty(regexProp); |
|
String template = ConfigProperties.getProperty("srusource.path.condition.template" + id); |
Pattern pattern = patterns.get(patternStr); |
if(pattern == null) |
{ |
pattern = Pattern.compile(patternStr); |
patterns.put(patternStr,pattern); |
} |
Matcher matcher = pattern.matcher(path); |
if(matcher.find()) |
{ |
String[] paths = path.split("[\\\\]"); |
template = template.replace("@collection@", collection); |
return java.text.MessageFormat.format(template,paths); |
} |
} |
return "(" + collection + ")"; |
} |
|
|
|
public int countToDo(UserSession userSession) |
{ |
return 0; |