CalendarServiceImpl implements CalendarService { @Override public CalendarEntry createCalendarEntry(String siteShortName, CalendarEntry entry) { if (entry.getNodeRef() != null) { throw new IllegalArgumentException("Can't call create for a calendar entry that was previously persisted"); } NodeRef container = getSiteCalendarContainer(siteShortName, true); Map<QName,Serializable> properties = CalendarEntryImpl.toNodeProperties(entry); String name = (new Date()).getTime() + "-" + Math.round(Math.random()*10000) + ".ics"; properties.put(ContentModel.PROP_NAME, name); NodeRef nodeRef = nodeService.createNode( container, ContentModel.ASSOC_CONTAINS, QName.createQName(name), CalendarModel.TYPE_EVENT, properties ).getChildRef(); CalendarEntryImpl entryImpl; if (entry instanceof CalendarEntryImpl) { entryImpl = (CalendarEntryImpl)entry; entryImpl.recordStorageDetails(nodeRef, container, name); } else { entryImpl = new CalendarEntryImpl(nodeRef, container, name); entryImpl.populate(properties); entryImpl.setTags(entry.getTags()); } Date createdAt = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_CREATED); entryImpl.setCreatedAt(createdAt); entryImpl.setModifiedAt(createdAt); taggingService.setTags(nodeRef, entry.getTags()); return entryImpl; }  void setNodeDAO(NodeDAO nodeDAO); void setNodeService(NodeService nodeService); void setSiteService(SiteService siteService); void setTaggingService(TaggingService taggingService); void setPermissionService(PermissionService permissionService); void setTransactionService(TransactionService transactionService); void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry); @Override CalendarEntry getCalendarEntry(String siteShortName, String entryName); @Override CalendarEntry createCalendarEntry(String siteShortName, CalendarEntry entry); @Override CalendarEntry updateCalendarEntry(CalendarEntry entry); @Override void deleteCalendarEntry(CalendarEntry entry); @Override PagingResults<CalendarEntry> listCalendarEntries(
          String siteShortName, PagingRequest paging); @Override PagingResults<CalendarEntry> listCalendarEntries(
          String[] siteShortNames, PagingRequest paging); @Override PagingResults<CalendarEntry> listCalendarEntries(
          String[] siteShortNames, Date from, Date to, PagingRequest paging); static final String CALENDAR_COMPONENT; }
@Test public void newContainerSetup() throws Exception { final String TEST_SITE_NAME = "CalendarTestNewTestSite"; TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { if (SITE_SERVICE.getSite(TEST_SITE_NAME) != null) { SITE_SERVICE.deleteSite(TEST_SITE_NAME); } SITE_SERVICE.createSite( TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC); assertFalse(SITE_SERVICE.hasContainer(TEST_SITE_NAME, CalendarServiceImpl.CALENDAR_COMPONENT)); CalendarEntry entry = new CalendarEntryDTO( "Title", "Description", "Location", new Date(1), new Date(1234)); CALENDAR_SERVICE.createCalendarEntry(TEST_SITE_NAME, entry); assertTrue(SITE_SERVICE.hasContainer(TEST_SITE_NAME, CalendarServiceImpl.CALENDAR_COMPONENT)); NodeRef container = SITE_SERVICE.getContainer(TEST_SITE_NAME, CalendarServiceImpl.CALENDAR_COMPONENT); assertTrue(TAGGING_SERVICE.isTagScope(container)); SITE_SERVICE.deleteSite(TEST_SITE_NAME); return null; } }); }