diff --git a/config/alfresco/public-services-security-context.xml b/config/alfresco/public-services-security-context.xml
index 942475a3cb..c92f1f9727 100644
--- a/config/alfresco/public-services-security-context.xml
+++ b/config/alfresco/public-services-security-context.xml
@@ -517,6 +517,17 @@
+
+
+
+
+
+
+ org.alfresco.service.cmr.search.StatsService.query=ACL_ALLOW,AFTER_ACL_NODE.sys:base.Read
+ org.alfresco.service.cmr.search.StatsService.*=ACL_DENY
+
+
+
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/JSONResult.java b/source/java/org/alfresco/repo/search/impl/lucene/JSONResult.java
index 61c8431290..6dcc2c40cf 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/JSONResult.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/JSONResult.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2014 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 .
+ */
package org.alfresco.repo.search.impl.lucene;
/**
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/SolrJsonProcessor.java b/source/java/org/alfresco/repo/search/impl/lucene/SolrJsonProcessor.java
index e634c47000..e21f8cf122 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/SolrJsonProcessor.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/SolrJsonProcessor.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2014 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 .
+ */
package org.alfresco.repo.search.impl.lucene;
import org.json.JSONObject;
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/SolrStatsResult.java b/source/java/org/alfresco/repo/search/impl/lucene/SolrStatsResult.java
index a608246b06..5d49c69ebe 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/SolrStatsResult.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/SolrStatsResult.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2014 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 .
+ */
package org.alfresco.repo.search.impl.lucene;
import java.util.ArrayList;
diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java b/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java
index 54ba06161f..7a5bd7d5bb 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java
@@ -296,16 +296,12 @@ public class SolrQueryHTTPClient implements BeanFactoryAware
JSONArray tenants = new JSONArray();
tenants.put(tenant);
- //body.put("tenants", tenants);
- //TODO: Tenants
+ body.put("tenants", tenants);
JSONArray locales = new JSONArray();
locales.put(locale);
body.put("locales", locales);
- //&q=TYPE:"cm:content" AND PATH:"/app:company_home/st:sites/cm:swsdp//*"
-
- //TODO: Authorities and permissions
return body;
}
diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrStatsService.java b/source/java/org/alfresco/repo/search/impl/solr/SolrStatsService.java
index ba97f60b0c..02074b8d04 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/SolrStatsService.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/SolrStatsService.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2014 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 .
+ */
package org.alfresco.repo.search.impl.solr;
import org.alfresco.repo.search.IndexerAndSearcher;
diff --git a/source/test-java/org/alfresco/AllUnitTestsSuite.java b/source/test-java/org/alfresco/AllUnitTestsSuite.java
index c1e4d7fd00..79925c465f 100644
--- a/source/test-java/org/alfresco/AllUnitTestsSuite.java
+++ b/source/test-java/org/alfresco/AllUnitTestsSuite.java
@@ -95,5 +95,7 @@ public class AllUnitTestsSuite extends TestSuite
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class));
+ suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class));
+ suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class));
}
}
diff --git a/source/test-java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClientTest.java b/source/test-java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClientTest.java
index efbacd949d..f8cb1ef8db 100644
--- a/source/test-java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClientTest.java
+++ b/source/test-java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClientTest.java
@@ -1,6 +1,6 @@
package org.alfresco.repo.search.impl.solr;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
@@ -11,6 +11,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.search.SearchParameters.SortDefinition;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.search.StatsParameters;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
@@ -21,6 +22,7 @@ import org.junit.Test;
* Basic test of SolrQueryHTTPClient
*
* @author Gethin James
+ * @since 5.0
*/
public class SolrQueryHTTPClientTest
{
@@ -49,6 +51,10 @@ public class SolrQueryHTTPClientTest
StatsParameters params = getParameters();
String url = client.buildStatsUrl(params, "http://localhost:8080/solr/alfresco/select", Locale.CANADA_FRENCH);
assertNotNull(url);
+ assertTrue(url.contains("locale=fr_CA"));
+ assertTrue(url.contains("sort=contentsize"));
+ assertTrue(url.contains("fq=ANCESTOR"));
+
}
@Test
@@ -58,6 +64,13 @@ public class SolrQueryHTTPClientTest
StatsParameters params = getParameters();
JSONObject body = client.buildStatsBody(params, "myTenant", Locale.US);
assertNotNull(body);
+ JSONArray tenant = body.getJSONArray("tenants");
+ assertEquals("myTenant",tenant.get(0).toString());
+ JSONArray locale = body.getJSONArray("locales");
+ assertEquals("en_US",locale.get(0).toString());
+ String query = body.getString("query");
+ assertTrue(query.contains("TYPE:"));
+ assertTrue(query.contains("{http://www.alfresco.org/model/content/1.0}content"));
}
private StatsParameters getParameters() {
diff --git a/source/test-java/org/alfresco/repo/search/impl/solr/SolrStatsResultTest.java b/source/test-java/org/alfresco/repo/search/impl/solr/SolrStatsResultTest.java
index cdc0c1b670..81ded8ebd8 100644
--- a/source/test-java/org/alfresco/repo/search/impl/solr/SolrStatsResultTest.java
+++ b/source/test-java/org/alfresco/repo/search/impl/solr/SolrStatsResultTest.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2014 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 .
+ */
package org.alfresco.repo.search.impl.solr;
import static org.junit.Assert.*;
@@ -9,6 +27,12 @@ import org.json.JSONTokener;
import org.junit.Test;
import org.springframework.util.StringUtils;
+/**
+ * The results of executing a solr stats query, parsing the json
+ *
+ * @author Gethin James
+ * @since 5.0
+ */
public class SolrStatsResultTest
{