mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9156 Switch the Calender basic listing to using a canned query directly, and start on a permissions check for it (currently disabled)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28986 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
<idref local="CalendarService_transaction" />
|
<idref local="CalendarService_transaction" />
|
||||||
<idref bean="AuditMethodInterceptor" />
|
<idref bean="AuditMethodInterceptor" />
|
||||||
<idref bean="exceptionTranslator" />
|
<idref bean="exceptionTranslator" />
|
||||||
<idref local="CalendarService_security" />
|
<idref bean="CalendarService_security" />
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
@@ -34,9 +34,23 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Calendar service security bean -->
|
<!-- List of Calendar Canned queries -->
|
||||||
<bean id="CalendarService_security"
|
<bean id="calendarCannedQueryRegistry" class="org.alfresco.util.registry.NamedObjectRegistry">
|
||||||
class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
<property name="storageType" value="org.alfresco.query.CannedQueryFactory"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- The regular GetChildren Canned Query Factory -->
|
||||||
|
<bean name="calendarGetChildrenCannedQueryFactory" class="org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory">
|
||||||
|
<property name="registry" ref="calendarCannedQueryRegistry"/>
|
||||||
|
<property name="dictionaryService" ref="dictionaryService"/>
|
||||||
|
<property name="tenantService" ref="tenantService"/>
|
||||||
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
|
<property name="qnameDAO" ref="qnameDAO"/>
|
||||||
|
<property name="localeDAO" ref="localeDAO"/>
|
||||||
|
<property name="contentDataDAO" ref="contentDataDAO"/>
|
||||||
|
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
||||||
|
<property name="methodSecurity" ref="CalendarService_security_listCalendarEntries"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Calendar Service base bean -->
|
<!-- Calendar Service base bean -->
|
||||||
<bean id="calendarService" class="org.alfresco.repo.calendar.CalendarServiceImpl">
|
<bean id="calendarService" class="org.alfresco.repo.calendar.CalendarServiceImpl">
|
||||||
@@ -44,9 +58,9 @@
|
|||||||
<property name="siteService" ref="SiteService"/>
|
<property name="siteService" ref="SiteService"/>
|
||||||
<property name="searchService" ref="SearchService" /> <!-- TODO Temp -->
|
<property name="searchService" ref="SearchService" /> <!-- TODO Temp -->
|
||||||
<property name="taggingService" ref="TaggingService"/>
|
<property name="taggingService" ref="TaggingService"/>
|
||||||
<property name="fileFolderService" ref="FileFolderService" /> <!-- TODO Temp -->
|
|
||||||
<property name="permissionService" ref="PermissionService"/>
|
<property name="permissionService" ref="PermissionService"/>
|
||||||
<property name="transactionService" ref="transactionService" />
|
<property name="transactionService" ref="transactionService" />
|
||||||
|
<property name="cannedQueryRegistry" ref="calendarCannedQueryRegistry" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -962,6 +962,33 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ==================== -->
|
||||||
|
<!-- The Calendar Service -->
|
||||||
|
<!-- ==================== -->
|
||||||
|
|
||||||
|
<!-- The calendar service itself does not require any security restrictions, -->
|
||||||
|
<!-- they are imposed by the node and site services it uses to do its work. -->
|
||||||
|
<bean id="CalendarService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
||||||
|
|
||||||
|
<!-- The canned queries that the calendar service uses do however need to check -->
|
||||||
|
<bean id="CalendarService_CannedQuery_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.calendar.CalendarService.listCalendarEntries=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="CalendarService_security_listCalendarEntries" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="CalendarService_CannedQuery_security" />
|
||||||
|
<property name="service" value="org.alfresco.service.cmr.calendar.CalendarService" />
|
||||||
|
<property name="methodName" value="listCalendarEntries" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<!-- ======================== -->
|
<!-- ======================== -->
|
||||||
<!-- Repository Admin Service -->
|
<!-- Repository Admin Service -->
|
||||||
<!-- ======================== -->
|
<!-- ======================== -->
|
||||||
|
@@ -28,14 +28,16 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.query.CannedQueryFactory;
|
||||||
|
import org.alfresco.query.CannedQueryResults;
|
||||||
import org.alfresco.query.PagingRequest;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
|
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
||||||
|
import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||||
import org.alfresco.service.cmr.calendar.CalendarService;
|
import org.alfresco.service.cmr.calendar.CalendarService;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
@@ -45,6 +47,7 @@ import org.alfresco.service.cmr.tagging.TaggingService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -63,6 +66,8 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
*/
|
*/
|
||||||
private static final int MAX_QUERY_ENTRY_COUNT = 10000;
|
private static final int MAX_QUERY_ENTRY_COUNT = 10000;
|
||||||
|
|
||||||
|
private static final String CANNED_QUERY_GET_CHILDREN = "calendarGetChildrenCannedQueryFactory";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
*/
|
*/
|
||||||
@@ -72,9 +77,9 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private SearchService searchService; // TODO Temp only
|
private SearchService searchService; // TODO Temp only
|
||||||
private TaggingService taggingService;
|
private TaggingService taggingService;
|
||||||
private FileFolderService fileFolderService; // TODO Temp only
|
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
|
private NamedObjectRegistry<CannedQueryFactory<NodeRef>> cannedQueryRegistry;
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
@@ -99,14 +104,6 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
this.taggingService = taggingService;
|
this.taggingService = taggingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Temp only
|
|
||||||
*/
|
|
||||||
public void setFileFolderService(FileFolderService fileFolderService)
|
|
||||||
{
|
|
||||||
this.fileFolderService = fileFolderService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPermissionService(PermissionService permissionService)
|
public void setPermissionService(PermissionService permissionService)
|
||||||
{
|
{
|
||||||
this.permissionService = permissionService;
|
this.permissionService = permissionService;
|
||||||
@@ -117,6 +114,14 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
this.transactionService = transactionService;
|
this.transactionService = transactionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the registry of {@link CannedQueryFactory canned queries}
|
||||||
|
*/
|
||||||
|
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<NodeRef>> cannedQueryRegistry)
|
||||||
|
{
|
||||||
|
this.cannedQueryRegistry = cannedQueryRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the Calendar Container on a site, creating as required if requested.
|
* Fetches the Calendar Container on a site, creating as required if requested.
|
||||||
*/
|
*/
|
||||||
@@ -362,9 +367,6 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
public PagingResults<CalendarEntry> listCalendarEntries(
|
public PagingResults<CalendarEntry> listCalendarEntries(
|
||||||
String siteShortName, PagingRequest paging)
|
String siteShortName, PagingRequest paging)
|
||||||
{
|
{
|
||||||
// TODO Switch to this
|
|
||||||
//return listCalendarEntries(new String[] { siteShortName }, paging);
|
|
||||||
|
|
||||||
NodeRef container = getSiteCalendarContainer(siteShortName, false);
|
NodeRef container = getSiteCalendarContainer(siteShortName, false);
|
||||||
if(container == null)
|
if(container == null)
|
||||||
{
|
{
|
||||||
@@ -372,11 +374,22 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask the file folder service
|
// Build our sorting, by date
|
||||||
List<Pair<QName,Boolean>> sort = new ArrayList<Pair<QName, Boolean>>();
|
List<Pair<QName,Boolean>> sort = new ArrayList<Pair<QName, Boolean>>();
|
||||||
sort.add(new Pair<QName, Boolean>(CalendarModel.PROP_FROM_DATE, true));
|
sort.add(new Pair<QName, Boolean>(CalendarModel.PROP_FROM_DATE, true));
|
||||||
sort.add(new Pair<QName, Boolean>(CalendarModel.PROP_TO_DATE, true));
|
sort.add(new Pair<QName, Boolean>(CalendarModel.PROP_TO_DATE, true));
|
||||||
PagingResults<FileInfo> results = fileFolderService.list(container, true, false, null, sort, paging);
|
|
||||||
|
// We only want calendar entries
|
||||||
|
Set<QName> types = new HashSet<QName>();
|
||||||
|
types.add(CalendarModel.TYPE_EVENT);
|
||||||
|
|
||||||
|
// Run the canned query
|
||||||
|
GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
|
||||||
|
GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
|
||||||
|
container, types, null, sort, paging);
|
||||||
|
|
||||||
|
// Execute the canned query
|
||||||
|
CannedQueryResults<NodeRef> results = cq.execute();
|
||||||
return wrap(results);
|
return wrap(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,6 +397,12 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
public PagingResults<CalendarEntry> listCalendarEntries(
|
public PagingResults<CalendarEntry> listCalendarEntries(
|
||||||
String[] siteShortNames, PagingRequest paging)
|
String[] siteShortNames, PagingRequest paging)
|
||||||
{
|
{
|
||||||
|
// If we only have the one site, use the list above
|
||||||
|
if(siteShortNames != null && siteShortNames.length == 1)
|
||||||
|
{
|
||||||
|
return listCalendarEntries(siteShortNames[0], paging);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Use search for now
|
// TODO Use search for now
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -397,9 +416,10 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Temp hack!
|
* Our class to wrap up paged results of NodeRefs as
|
||||||
|
* CalendarEntry instances
|
||||||
*/
|
*/
|
||||||
private PagingResults<CalendarEntry> wrap(final PagingResults<FileInfo> results)
|
private PagingResults<CalendarEntry> wrap(final PagingResults<NodeRef> results)
|
||||||
{
|
{
|
||||||
return new PagingResults<CalendarEntry>()
|
return new PagingResults<CalendarEntry>()
|
||||||
{
|
{
|
||||||
@@ -412,11 +432,13 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
public List<CalendarEntry> getPage()
|
public List<CalendarEntry> getPage()
|
||||||
{
|
{
|
||||||
List<CalendarEntry> entries = new ArrayList<CalendarEntry>();
|
List<CalendarEntry> entries = new ArrayList<CalendarEntry>();
|
||||||
for(FileInfo file : results.getPage())
|
for(NodeRef nodeRef : results.getPage())
|
||||||
{
|
{
|
||||||
CalendarEntryImpl entry = new CalendarEntryImpl(file.getNodeRef(), file.getName());
|
String entryName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
entry.populate(nodeService.getProperties(file.getNodeRef()));
|
|
||||||
entry.setTags(taggingService.getTags(file.getNodeRef()));
|
CalendarEntryImpl entry = new CalendarEntryImpl(nodeRef, entryName);
|
||||||
|
entry.populate(nodeService.getProperties(nodeRef));
|
||||||
|
entry.setTags(taggingService.getTags(nodeRef));
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
|
@@ -42,7 +42,9 @@ import org.alfresco.service.cmr.calendar.CalendarService;
|
|||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
@@ -75,8 +77,10 @@ public class CalendarServiceImplTest
|
|||||||
private static CalendarService CALENDAR_SERVICE;
|
private static CalendarService CALENDAR_SERVICE;
|
||||||
private static DictionaryService DICTIONARY_SERVICE;
|
private static DictionaryService DICTIONARY_SERVICE;
|
||||||
private static NodeService NODE_SERVICE;
|
private static NodeService NODE_SERVICE;
|
||||||
|
private static NodeService PUBLIC_NODE_SERVICE;
|
||||||
private static PersonService PERSON_SERVICE;
|
private static PersonService PERSON_SERVICE;
|
||||||
private static RetryingTransactionHelper TRANSACTION_HELPER;
|
private static RetryingTransactionHelper TRANSACTION_HELPER;
|
||||||
|
private static PermissionService PERMISSION_SERVICE;
|
||||||
private static SiteService SITE_SERVICE;
|
private static SiteService SITE_SERVICE;
|
||||||
private static TaggingService TAGGING_SERVICE;
|
private static TaggingService TAGGING_SERVICE;
|
||||||
|
|
||||||
@@ -84,6 +88,7 @@ public class CalendarServiceImplTest
|
|||||||
private static final String ADMIN_USER = AuthenticationUtil.getAdminUserName();
|
private static final String ADMIN_USER = AuthenticationUtil.getAdminUserName();
|
||||||
|
|
||||||
private static SiteInfo CALENDAR_SITE;
|
private static SiteInfo CALENDAR_SITE;
|
||||||
|
private static SiteInfo ALTERNATE_CALENDAR_SITE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary test nodes (created during a test method) that need deletion after the test method.
|
* Temporary test nodes (created during a test method) that need deletion after the test method.
|
||||||
@@ -101,8 +106,10 @@ public class CalendarServiceImplTest
|
|||||||
CALENDAR_SERVICE = (CalendarService)testContext.getBean("CalendarService");
|
CALENDAR_SERVICE = (CalendarService)testContext.getBean("CalendarService");
|
||||||
DICTIONARY_SERVICE = (DictionaryService)testContext.getBean("dictionaryService");
|
DICTIONARY_SERVICE = (DictionaryService)testContext.getBean("dictionaryService");
|
||||||
NODE_SERVICE = (NodeService)testContext.getBean("nodeService");
|
NODE_SERVICE = (NodeService)testContext.getBean("nodeService");
|
||||||
|
PUBLIC_NODE_SERVICE = (NodeService)testContext.getBean("NodeService");
|
||||||
PERSON_SERVICE = (PersonService)testContext.getBean("personService");
|
PERSON_SERVICE = (PersonService)testContext.getBean("personService");
|
||||||
TRANSACTION_HELPER = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
|
TRANSACTION_HELPER = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
|
||||||
|
PERMISSION_SERVICE = (PermissionService)testContext.getBean("permissionService");
|
||||||
SITE_SERVICE = (SiteService)testContext.getBean("siteService");
|
SITE_SERVICE = (SiteService)testContext.getBean("siteService");
|
||||||
TAGGING_SERVICE = (TaggingService)testContext.getBean("TaggingService");
|
TAGGING_SERVICE = (TaggingService)testContext.getBean("TaggingService");
|
||||||
|
|
||||||
@@ -111,7 +118,7 @@ public class CalendarServiceImplTest
|
|||||||
|
|
||||||
// We need to create the test site as the test user so that they can contribute content to it in tests below.
|
// We need to create the test site as the test user so that they can contribute content to it in tests below.
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
|
AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
|
||||||
createTestSite();
|
createTestSites();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void createNewEntry() throws Exception
|
@Test public void createNewEntry() throws Exception
|
||||||
@@ -468,6 +475,15 @@ public class CalendarServiceImplTest
|
|||||||
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
assertEquals(1, results.getPage().size());
|
assertEquals(1, results.getPage().size());
|
||||||
assertEquals("TitleC", results.getPage().get(0).getTitle());
|
assertEquals("TitleC", results.getPage().get(0).getTitle());
|
||||||
|
|
||||||
|
|
||||||
|
// Tidy
|
||||||
|
paging = new PagingRequest(10);
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
for(CalendarEntry entry : results.getPage())
|
||||||
|
{
|
||||||
|
testNodesToTidy.add(entry.getNodeRef());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void calendarMultiSiteListing() throws Exception
|
@Test public void calendarMultiSiteListing() throws Exception
|
||||||
@@ -475,19 +491,139 @@ public class CalendarServiceImplTest
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createTestSite() throws Exception
|
/**
|
||||||
|
* Checks that the correct permission checking occurs on fetching
|
||||||
|
* calendar listings (which go through canned queries)
|
||||||
|
* TODO FIX
|
||||||
|
*/
|
||||||
|
public void DISABLEDcalendarListingPermissionsChecking() throws Exception
|
||||||
|
{
|
||||||
|
PagingRequest paging = new PagingRequest(10);
|
||||||
|
PagingResults<CalendarEntry> results;
|
||||||
|
|
||||||
|
// TODO This shouldn't be needed...
|
||||||
|
PERMISSION_SERVICE.clearPermission(ALTERNATE_CALENDAR_SITE.getNodeRef(), TEST_USER);
|
||||||
|
System.err.println(PERMISSION_SERVICE.getPermissions(ALTERNATE_CALENDAR_SITE.getNodeRef()));
|
||||||
|
System.err.println(PERMISSION_SERVICE.getAllSetPermissions(ALTERNATE_CALENDAR_SITE.getNodeRef()));
|
||||||
|
System.err.println(NODE_SERVICE.getChildAssocs(ALTERNATE_CALENDAR_SITE.getNodeRef()));
|
||||||
|
System.err.println(PUBLIC_NODE_SERVICE.getChildAssocs(ALTERNATE_CALENDAR_SITE.getNodeRef()));
|
||||||
|
|
||||||
|
|
||||||
|
// Nothing to start with in either site
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
// assertEquals(0, results.getPage().size());
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(0, results.getPage().size());
|
||||||
|
|
||||||
|
// Double check that we're only allowed to see the 1st site
|
||||||
|
assertEquals(true, SITE_SERVICE.isMember(CALENDAR_SITE.getShortName(), TEST_USER));
|
||||||
|
assertEquals(false, SITE_SERVICE.isMember(ALTERNATE_CALENDAR_SITE.getShortName(), TEST_USER));
|
||||||
|
assertEquals(AccessStatus.ALLOWED, PERMISSION_SERVICE.hasReadPermission(CALENDAR_SITE.getNodeRef()));
|
||||||
|
assertEquals(AccessStatus.DENIED, PERMISSION_SERVICE.hasReadPermission(ALTERNATE_CALENDAR_SITE.getNodeRef()));
|
||||||
|
|
||||||
|
|
||||||
|
// Add two events to one site and three to the other
|
||||||
|
CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO(
|
||||||
|
"TitleA", "Description", "Location", new Date(1302431400), new Date(1302435000)
|
||||||
|
));
|
||||||
|
CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO(
|
||||||
|
"TitleB", "Description", "Location", new Date(1302431400), new Date(1302442200)
|
||||||
|
));
|
||||||
|
|
||||||
|
CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO(
|
||||||
|
"PrivateTitleA", "Description", "Location", new Date(1302431400), new Date(1302435000)
|
||||||
|
));
|
||||||
|
CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO(
|
||||||
|
"PrivateTitleB", "Description", "Location", new Date(1302431400), new Date(1302442200)
|
||||||
|
));
|
||||||
|
NodeRef priv3 = CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO(
|
||||||
|
"PrivateTitleC", "Description", "Location", new Date(1302431400), new Date(1302442200)
|
||||||
|
)).getNodeRef();
|
||||||
|
|
||||||
|
|
||||||
|
// Check again, as we're not in the 2nd site won't see any there
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(2, results.getPage().size());
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(0, results.getPage().size());
|
||||||
|
|
||||||
|
|
||||||
|
// Join the site, now we can see both
|
||||||
|
SITE_SERVICE.setMembership(ALTERNATE_CALENDAR_SITE.getShortName(), TEST_USER, SiteModel.SITE_CONTRIBUTOR);
|
||||||
|
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(2, results.getPage().size());
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(3, results.getPage().size());
|
||||||
|
|
||||||
|
|
||||||
|
// Explicitly remove their permissions from one node, check it vanishes from the list
|
||||||
|
PERMISSION_SERVICE.setInheritParentPermissions(priv3, false);
|
||||||
|
PERMISSION_SERVICE.clearPermission(priv3, TEST_USER);
|
||||||
|
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(2, results.getPage().size());
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(2, results.getPage().size());
|
||||||
|
|
||||||
|
|
||||||
|
// Leave, they go away again
|
||||||
|
SITE_SERVICE.removeMembership(ALTERNATE_CALENDAR_SITE.getShortName(), TEST_USER);
|
||||||
|
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(2, results.getPage().size());
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging);
|
||||||
|
assertEquals(0, results.getPage().size());
|
||||||
|
|
||||||
|
|
||||||
|
// Tidy
|
||||||
|
paging = new PagingRequest(10);
|
||||||
|
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||||
|
for(CalendarEntry entry : results.getPage())
|
||||||
|
{
|
||||||
|
testNodesToTidy.add(entry.getNodeRef());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createTestSites() throws Exception
|
||||||
{
|
{
|
||||||
CALENDAR_SITE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>()
|
CALENDAR_SITE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public SiteInfo execute() throws Throwable
|
public SiteInfo execute() throws Throwable
|
||||||
{
|
{
|
||||||
SiteInfo site = SITE_SERVICE.createSite(TEST_SITE_PREFIX, CalendarServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(),
|
SiteInfo site = SITE_SERVICE.createSite(
|
||||||
"test site title", "test site description", SiteVisibility.PUBLIC);
|
TEST_SITE_PREFIX,
|
||||||
|
CalendarServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(),
|
||||||
|
"test site title", "test site description",
|
||||||
|
SiteVisibility.PUBLIC
|
||||||
|
);
|
||||||
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
|
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
|
||||||
return site;
|
return site;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create the alternate site as admin
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
||||||
|
ALTERNATE_CALENDAR_SITE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public SiteInfo execute() throws Throwable
|
||||||
|
{
|
||||||
|
SiteInfo site = SITE_SERVICE.createSite(
|
||||||
|
TEST_SITE_PREFIX,
|
||||||
|
CalendarServiceImplTest.class.getSimpleName() + "_testAltSite" + System.currentTimeMillis(),
|
||||||
|
"alternate site title", "alternate site description",
|
||||||
|
SiteVisibility.PRIVATE
|
||||||
|
);
|
||||||
|
SITE_SERVICE.createContainer(
|
||||||
|
site.getShortName(), CalendarServiceImpl.CALENDAR_COMPONENT, null, null
|
||||||
|
);
|
||||||
|
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
|
||||||
|
return site;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user