Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

75011: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      70370: Cleaned up the solr stats code, added security check and tenants


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75339 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Will Abson
2014-07-01 15:00:02 +00:00
parent ceeee50b22
commit 9aaca71a50
9 changed files with 124 additions and 6 deletions

View File

@@ -517,6 +517,17 @@
</property> </property>
</bean> </bean>
<bean id="StasService_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor">
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
<property name="accessDecisionManager"><ref local="accessDecisionManager"/></property>
<property name="afterInvocationManager"><ref local="afterInvocationManager"/></property>
<property name="objectDefinitionSource">
<value>
org.alfresco.service.cmr.search.StatsService.query=ACL_ALLOW,AFTER_ACL_NODE.sys:base.Read
org.alfresco.service.cmr.search.StatsService.*=ACL_DENY
</value>
</property>
</bean>
<!-- ================ --> <!-- ================ -->
<!-- Category Service --> <!-- Category Service -->
<!-- ================ --> <!-- ================ -->

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.lucene; package org.alfresco.repo.search.impl.lucene;
/** /**

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.lucene; package org.alfresco.repo.search.impl.lucene;
import org.json.JSONObject; import org.json.JSONObject;

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.lucene; package org.alfresco.repo.search.impl.lucene;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -296,16 +296,12 @@ public class SolrQueryHTTPClient implements BeanFactoryAware
JSONArray tenants = new JSONArray(); JSONArray tenants = new JSONArray();
tenants.put(tenant); tenants.put(tenant);
//body.put("tenants", tenants); body.put("tenants", tenants);
//TODO: Tenants
JSONArray locales = new JSONArray(); JSONArray locales = new JSONArray();
locales.put(locale); locales.put(locale);
body.put("locales", locales); body.put("locales", locales);
//&q=TYPE:"cm:content" AND PATH:"/app:company_home/st:sites/cm:swsdp//*"
//TODO: Authorities and permissions
return body; return body;
} }

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.solr; package org.alfresco.repo.search.impl.solr;
import org.alfresco.repo.search.IndexerAndSearcher; import org.alfresco.repo.search.IndexerAndSearcher;

View File

@@ -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.SchemaVersionValidatorTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.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.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));
} }
} }

View File

@@ -1,6 +1,6 @@
package org.alfresco.repo.search.impl.solr; package org.alfresco.repo.search.impl.solr;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.*;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.HashMap; 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.SearchParameters.SortDefinition;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.search.StatsParameters; import org.alfresco.service.cmr.search.StatsParameters;
import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.junit.Before; import org.junit.Before;
@@ -21,6 +22,7 @@ import org.junit.Test;
* Basic test of SolrQueryHTTPClient * Basic test of SolrQueryHTTPClient
* *
* @author Gethin James * @author Gethin James
* @since 5.0
*/ */
public class SolrQueryHTTPClientTest public class SolrQueryHTTPClientTest
{ {
@@ -49,6 +51,10 @@ public class SolrQueryHTTPClientTest
StatsParameters params = getParameters(); StatsParameters params = getParameters();
String url = client.buildStatsUrl(params, "http://localhost:8080/solr/alfresco/select", Locale.CANADA_FRENCH); String url = client.buildStatsUrl(params, "http://localhost:8080/solr/alfresco/select", Locale.CANADA_FRENCH);
assertNotNull(url); assertNotNull(url);
assertTrue(url.contains("locale=fr_CA"));
assertTrue(url.contains("sort=contentsize"));
assertTrue(url.contains("fq=ANCESTOR"));
} }
@Test @Test
@@ -58,6 +64,13 @@ public class SolrQueryHTTPClientTest
StatsParameters params = getParameters(); StatsParameters params = getParameters();
JSONObject body = client.buildStatsBody(params, "myTenant", Locale.US); JSONObject body = client.buildStatsBody(params, "myTenant", Locale.US);
assertNotNull(body); 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() { private StatsParameters getParameters() {

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.solr; package org.alfresco.repo.search.impl.solr;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@@ -9,6 +27,12 @@ import org.json.JSONTokener;
import org.junit.Test; import org.junit.Test;
import org.springframework.util.StringUtils; 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 public class SolrStatsResultTest
{ {