Skip to content

Commit

Permalink
Merge pull request #33 from xenit-eu/master
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
Ranecdev authored May 23, 2023
2 parents 2804061 + 4ab1cc1 commit f29ac46
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 77 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ jobs:
java-version: 11
- name: Publish
env:
XENIT_ARTIFACTORY_USERNAME: ${{ secrets.XENIT_ARTIFACTORY_USERNAME }}
XENIT_ARTIFACTORY_PASSWORD: ${{ secrets.XENIT_ARTIFACTORY_PASSWORD }}
SIGNING_PRIVATE_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }}
SIGNING_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}
ORG_GRADLE_PROJECT_sonatype_username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_sonatype_password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_sonatype_username: ${{ secrets.SONATYPE_S01_USERNAME }}
ORG_GRADLE_PROJECT_sonatype_password: ${{ secrets.SONATYPE_S01_PASSWORD }}
run: ./gradlew publish --info
22 changes: 8 additions & 14 deletions alfresco-solr-query-analytics-6x/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,15 @@ publishing {
}
}
}

repositories {
if (isReleaseVersion) {
sonatypeMavenCentral {
credentials {
username = project.findProperty('sonatype_username')
password = project.findProperty('sonatype_password')
}
}
} else {
sonatypeSnapshots {
credentials {
username = project.findProperty('sonatype_username')
password = project.findProperty('sonatype_password')
}
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

credentials {
username = project.findProperty('sonatype_username')
password = project.findProperty('sonatype_password')
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Properties;
import java.io.StringWriter;
import java.io.PrintWriter;
import org.alfresco.repo.search.impl.lucene.JSONResult;
import org.alfresco.repo.search.impl.lucene.SolrJSONResultSet;
import org.alfresco.service.cmr.search.ResultSet;
Expand Down Expand Up @@ -85,8 +87,12 @@ public Object invoke(MethodInvocation mi) throws Throwable {
}
} catch (Throwable e) {
String queryString = params.getQuery();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String sStackTrace = sw.toString(); // stack trace as a string
logger.debug(
"{\"parsedQuery\":" + queryString + ", \"debugError\":" + e.getMessage() + "}");
"{\"parsedQuery\":" + queryString + ", \"debugError\":" + DebugSolrQueryHTTPClientAdvisor.this.solrQueryParser.escapeIllegalChars(sStackTrace) + "}");
}

return resultSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class SolrQueryParserTest {

private String createSearchQuery(LinkedHashMap<String, String> propertyMap) {
String q = "";
for (String property : propertyMap.keySet()){
for (String property : propertyMap.keySet()) {
switch (property) {
case "FullText":
q += propertyMap.get(property);
q += propertyMap.get(property);
break;
case "AND":
q += property;
Expand All @@ -36,7 +36,7 @@ private String createSearchQuery(LinkedHashMap<String, String> propertyMap) {
q += property;
break;
case "TEXT":
q += propertyMap.get(property);
q += propertyMap.get(property);
propertyMap.put(FULL_TEXT_PROPERTY, propertyMap.get(property));
propertyMap.remove("TEXT");
break;
Expand All @@ -51,12 +51,12 @@ private String createSearchQuery(LinkedHashMap<String, String> propertyMap) {

private void assertExtraction(LinkedHashMap<String, String> propertyMap, Set<String> extractedProperties) {
Set<String> formattedPropertySet = new HashSet<>();
for (String property : propertyMap.keySet()){
for (String property : propertyMap.keySet()) {
if (shouldBeExtracted(property)) {
formattedPropertySet.add(removeLuceneQueryOptions(solrQueryParser.escapeIllegalChars(property)));
}
}
for (String property : extractedProperties){
for (String property : extractedProperties) {
assertTrue(shouldBeExtracted(property));
}
assertEquals(formattedPropertySet, extractedProperties);
Expand Down Expand Up @@ -96,98 +96,98 @@ private void assertTest() {

@Test
public void simpleFullTextTest() {
propertyMap.put(FULL_TEXT_PROPERTY,"test");
propertyMap.put(FULL_TEXT_PROPERTY, "test");
}

@Test
public void simplePropertyTest() {
propertyMap.put("cm:name","test");
propertyMap.put("cm:name", "test");
}

@Test
public void simpleFTSandPropertyTest() {
propertyMap.put(FULL_TEXT_PROPERTY,"test");
propertyMap.put("cm:name","test");
propertyMap.put(FULL_TEXT_PROPERTY, "test");
propertyMap.put("cm:name", "test");
}

@Test
public void simpleFTSandMultiplePropertiesTest() {
propertyMap.put(FULL_TEXT_PROPERTY,"test");
propertyMap.put("cm:name","test");
propertyMap.put("cm:description","test");
propertyMap.put(FULL_TEXT_PROPERTY, "test");
propertyMap.put("cm:name", "test");
propertyMap.put("cm:description", "test");
}

@Test
public void simpleExactQueriesTest() {
propertyMap.put("cm:name","\"test\"");
propertyMap.put("cm:description","\"test test test test \"");
propertyMap.put("cm:name", "\"test\"");
propertyMap.put("cm:description", "\"test test test test \"");
}

@Test
public void simpleAndQueryTest() {
propertyMap.put("cm:name","test");
propertyMap.put("AND","");
propertyMap.put("cm:description","test");
propertyMap.put("cm:name", "test");
propertyMap.put("AND", "");
propertyMap.put("cm:description", "test");
}

@Test
public void simpleORQueryTest() {
propertyMap.put(FULL_TEXT_PROPERTY,"test");
propertyMap.put("OR","");
propertyMap.put("cm:description","test");
propertyMap.put(FULL_TEXT_PROPERTY, "test");
propertyMap.put("OR", "");
propertyMap.put("cm:description", "test");
}

@Test
public void typeQueryTest() {
propertyMap.put("TYPE","\"cm:content\"");
propertyMap.put("TYPE", "\"cm:content\"");
}

@Test
public void textTest() {
propertyMap.put("TEXT","\"Full text search\"");
propertyMap.put("TEXT", "\"Full text search\"");
}

@Test
public void typeVariationQueryTest() {
propertyMap.put("+TYPE","\"{http://www.alfresco.org/model/site/1.0}site\"");
propertyMap.put("+TYPE", "\"{http://www.alfresco.org/model/site/1.0}site\"");
}

@Test
public void lunceneQueryOptionsTest() {
propertyMap.put("+cm:name","\" test\"");
propertyMap.put("OR","");
propertyMap.put("-cm:title","\" test*\"");
propertyMap.put("+cm:name", "\" test\"");
propertyMap.put("OR", "");
propertyMap.put("-cm:title", "\" test*\"");
}

@Test
public void typeCombinationQueryTest() {
query= "+TYPE:\"{http://www.alfresco.org/model/site/1.0}site\" AND ( cm:name:\" test\" OR cm:title: (\"test*\" ) OR cm:description:\"test\")";
propertyMap.put("+TYPE","\"{http://www.alfresco.org/model/site/1.0}site\"");
propertyMap.put("cm:name","\" test\"");
propertyMap.put("OR","");
propertyMap.put("cm:title","\" test*\"");
propertyMap.put("OR","");
propertyMap.put("cm:description","\" test*\"");
query = "+TYPE:\"{http://www.alfresco.org/model/site/1.0}site\" AND ( cm:name:\" test\" OR cm:title: (\"test*\" ) OR cm:description:\"test\")";
propertyMap.put("+TYPE", "\"{http://www.alfresco.org/model/site/1.0}site\"");
propertyMap.put("cm:name", "\" test\"");
propertyMap.put("OR", "");
propertyMap.put("cm:title", "\" test*\"");
propertyMap.put("OR", "");
propertyMap.put("cm:description", "\" test*\"");
}

@Test
public void fullContentModelURITest() {
propertyMap.put("{http://www.alfresco.org/model/content/1.0}created","(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )");
propertyMap.put("OR","");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}content.size","(\"1048576\"..\"16777216\")");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}created", "(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )");
propertyMap.put("OR", "");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}content.size", "(\"1048576\"..\"16777216\")");
}

@Test
public void fullContentModelAndFullTextTest() {
query = "(test doc ) AND ({http://www.alfresco.org/model/content/1.0}created:(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )";
propertyMap.put(FULL_TEXT_PROPERTY,"\" test\"");
propertyMap.put("AND","");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}created","(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )");
propertyMap.put(FULL_TEXT_PROPERTY, "\" test\"");
propertyMap.put("AND", "");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}created", "(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )");
}

@Test
public void pathQueryTest() {
propertyMap.put("PATH","/app:company_home/st:sites/cm:test-site//*");
propertyMap.put("PATH", "/app:company_home/st:sites/cm:test-site//*");
}

@Test
Expand All @@ -198,9 +198,9 @@ public void aspectQuery() {
@Test
public void pathCombinationTest() {
query = "((PATH:\"/app:company_home/st:sites/cm:test-site//*\" AND {http://www.alfresco.org/model/content/1.0}created:(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\") AND {http://www.alfresco.org/model/content/1.0}creator:\"admin\") AND TYPE:\"cm:content\"";
propertyMap.put("PATH","/app:company_home/st:sites/cm:test-site//*");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}created","(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}creator","\"admin\"");
propertyMap.put("PATH", "/app:company_home/st:sites/cm:test-site//*");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}created", "(\"NOW/DAY-1MONTH\"..\"NOW/DAY+1DAY\" )");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}creator", "\"admin\"");
propertyMap.put("TYPE", "\"cm:content\"");
}

Expand All @@ -209,8 +209,8 @@ public void mimeTypeTest() {
query = "{http://www.alfresco.org/model/content/1.0}creator:\"admin\" " +
"AND {http://www.alfresco.org/model/content/1.0}content.mimetype:\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\") " +
"AND TYPE:\"cm:content\"";
propertyMap.put("{http://www.alfresco.org/model/content/1.0}creator","\"admin\"");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}content.mimetype","\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}creator", "\"admin\"");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}content.mimetype", "\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"");
propertyMap.put("TYPE", "\"cm:content\"");
}

Expand All @@ -232,16 +232,16 @@ public void removeNotFunctionTest() {
@Test
public void simpleNotQueryTest() {
query = "TYPE:cm:content AND NOT cm:name: \"test\"";
propertyMap.put("TYPE","cm:content");
propertyMap.put("AND","");
propertyMap.put("NOT","");
propertyMap.put("TYPE", "cm:content");
propertyMap.put("AND", "");
propertyMap.put("NOT", "");
propertyMap.put("!cm:name", "test");
}

@Test
public void specialCaseQueryTest() {
query = "cm:id:[18 TO 30]";
propertyMap.put("cm:id","[18 TO 30]");
propertyMap.put("cm:id", "[18 TO 30]");
}

@Test
Expand Down Expand Up @@ -291,35 +291,45 @@ public void advancedQueryTest() {
"OR TYPE:\"{http://www.alfresco.org/model/calendar}ignoreEvent\" " +
"OR TYPE:\"{http://www.alfresco.org/model/calendar}calendarEvent\" " +
"OR ASPECT:\"{http://www.alfresco.org/model/system/1.0}hidden\"))";
propertyMap.put("{http://www.alfresco.org/model/content/1.0}creator","\"test\"");
propertyMap.put("TYPE","{http://www.xenit.eu/xenit/model/0.3}project");
propertyMap.put(FULL_TEXT_PROPERTY,"\"Test\"");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}creator", "\"test\"");
propertyMap.put("TYPE", "{http://www.xenit.eu/xenit/model/0.3}project");
propertyMap.put(FULL_TEXT_PROPERTY, "\"Test\"");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}content.mimetype",
"\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"");
}

@Test
public void testShareQuery(){
public void testShareQuery() {
query = "+@cm\\:modified:[2021\\-7\\-27T00\\:00\\:00.000 TO 2021\\-8\\-3T23\\:59\\:59.999] " +
"+@cm\\:modifier:\"admin\" +TYPE:\"cm:content\" -TYPE:\"cm:systemfolder\" " +
"-TYPE:\"fm:forums\" -TYPE:\"fm:forum\" -TYPE:\"fm:topic\" -TYPE:\"fm:post\" " +
"+(TYPE:\"content\" OR TYPE:\"app:filelink\" OR TYPE:\"folder\")";
propertyMap.put("cm:modified","[2021\\-7\\-27T00\\:00\\:00.000 TO 2021\\-8\\-3T23\\:59\\:59.999]");
propertyMap.put("cm:modifier","\"admin\"");
propertyMap.put("TYPE","\"cm:content\"");
propertyMap.put("cm:modified", "[2021\\-7\\-27T00\\:00\\:00.000 TO 2021\\-8\\-3T23\\:59\\:59.999]");
propertyMap.put("cm:modifier", "\"admin\"");
propertyMap.put("TYPE", "\"cm:content\"");
}

@Test
public void testLuceneQuery() {
query = "+@cm\\:modified:[NOW/DAY-7DAYS TO NOW/DAY+1DAY] +TYPE:\"cm:content\"";
propertyMap.put("cm:modified","[NOW/DAY-7DAYS TO NOW/DAY+1DAY]");
propertyMap.put("cm:modified", "[NOW/DAY-7DAYS TO NOW/DAY+1DAY]");
propertyMap.put("TYPE", "\"cm:content\"");
}

@Test
public void testEscapedQuery() {
query = "={http:\\/\\/www.alfresco.org\\/model\\/content/1.0}name:\"Out\"";
propertyMap.put("{http://www.alfresco.org/model/content/1.0}name","Out");
propertyMap.put("{http://www.alfresco.org/model/content/1.0}name", "Out");
}

}
@Test
public void testLongQuery() {
query = "((={http:\\/\\/www.xenit.eu/model\\/content}claimNumber:\"031379321\"" +
" AND ={http:\\/\\/www.xenit.eu\\/model\\/content}hiddenDocument:\"false\") " +
"AND TYPE:\"{http:\\/\\/www.xenit.eu\\/model\\/content}root\" " +
"AND NOT (TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/1.0}dictionaryModel\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/datalist\\/1.0}issue\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/datalist\\/1.0}todoList\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/linksmodel\\/1.0}link\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/download\\/1.0}download\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/datalist\\/1.0}issue\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/datalist\\/1.0}dataList\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/datalist\\/1.0}dataListItem\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/1.0}systemfolder\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/1.0}rating\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/1.0}thumbnail\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/1.0}failedThumbnail\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/bpm\\/1.0}package\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/forum\\/1.0}forum\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/forum\\/1.0}topic\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/forum\\/1.0}post\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/site\\/1.0}site\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/transfer\\/1.0}tempTransferStore\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/transfer\\/1.0}transferReportDest\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/transfer\\/1.0}transferReport\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/transfer\\/1.0}transferLock\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/transfer\\/1.0}transferRecord\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/bpm\\/1.0}workflowDefinition\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/1.0}savedquery\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/content\\/smartfolder\\/1.0}smartFolderTemplate\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/solrfacet\\/1.0}facetField\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/surf\\/1.0}amdpage\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/calendar}updateEvent\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/calendar}ignoreEvent\" OR TYPE:\"{http:\\/\\/www.alfresco.org\\/model\\/calendar}calendarEvent\" OR ASPECT:\"{http:\\/\\/www.alfresco.org\\/model\\/system\\/1.0}hidden\"))";
propertyMap.put("{http:\\/\\/www.xenit.eu/model\\/content}claimNumber", "031379321");
propertyMap.put("{http:\\/\\/www.xenit.eu\\/model\\/content}hiddenDocument", "false");
propertyMap.put("TYPE", "{http:\\/\\/www.xenit.eu\\/model\\/content}root");
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ subprojects {
description = "Alfresco solr query analytics"

group = 'eu.xenit.alfresco'
version = '1.0.0' + getVersionQualifier(ci.branch ?: 'local')
version = '1.0.1' + getVersionQualifier(ci.branch ?: 'local')
ext.isReleaseVersion = !(version.endsWith("SNAPSHOT"))

// It is not possible to set properties with a dot via GitHub Actions env variables, therefore we introduce support
Expand Down

0 comments on commit f29ac46

Please sign in to comment.