diff --git a/source/java/org/alfresco/repo/blog/BlogServiceImpl.java b/source/java/org/alfresco/repo/blog/BlogServiceImpl.java index 5bb3c5576a..0d95eb5364 100644 --- a/source/java/org/alfresco/repo/blog/BlogServiceImpl.java +++ b/source/java/org/alfresco/repo/blog/BlogServiceImpl.java @@ -40,7 +40,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.blog.BlogService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; diff --git a/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java b/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java index 89efdd02ea..4ebe827449 100644 --- a/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java +++ b/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java @@ -101,8 +101,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,10), date(2011,7,15), - true, 1 - ); + true, 1); assertEquals(0, dates.size()); dates.clear(); @@ -110,8 +109,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,10), date(2011,7,15), - false, 1 - ); + false, 1); assertEquals(0, dates.size()); @@ -121,8 +119,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,19), date(2011,7,25), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-19", dateFmt.format(dates.get(0))); @@ -131,8 +128,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,19), date(2011,7,25), - false, 1 - ); + false, 1); assertEquals(6, dates.size()); assertEquals("2011-07-19", dateFmt.format(dates.get(0))); assertEquals("2011-07-24", dateFmt.format(dates.get(5))); @@ -144,8 +140,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,20), date(2011,7,30), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-20", dateFmt.format(dates.get(0))); @@ -154,8 +149,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,20), date(2011,7,30), - false, 1 - ); + false, 1); assertEquals(10, dates.size()); assertEquals("2011-07-20", dateFmt.format(dates.get(0))); assertEquals("2011-07-29", dateFmt.format(dates.get(9))); @@ -167,8 +161,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,19), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-19", dateFmt.format(dates.get(0))); @@ -177,8 +170,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildDailyRecurrences( currentDate, dates, null, date(2011,7,20), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-20", dateFmt.format(dates.get(0))); } @@ -198,8 +190,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,10), date(2011,7,15), - true, 1 - ); + true, 1); assertEquals(0, dates.size()); dates.clear(); @@ -207,8 +198,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,10), date(2011,7,15), - false, 1 - ); + false, 1); assertEquals(0, dates.size()); @@ -218,8 +208,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,17), date(2011,7,26), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thursday @@ -228,8 +217,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,19), date(2011,7,26), - false, 1 - ); + false, 1); assertEquals(2, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thu assertEquals("2011-07-25", dateFmt.format(dates.get(1))); // Mon @@ -241,8 +229,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,19), date(2011,7,26), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thursday @@ -251,8 +238,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,19), date(2011,7,26), - false, 1 - ); + false, 1); assertEquals(2, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thu assertEquals("2011-07-25", dateFmt.format(dates.get(1))); // Mon @@ -264,8 +250,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,7,30), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thu @@ -274,8 +259,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,7,30), - false, 1 - ); + false, 1); assertEquals(3, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); assertEquals("2011-07-25", dateFmt.format(dates.get(1))); @@ -288,8 +272,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,8,30), - true, 3 - ); + true, 3); assertEquals(1, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thu @@ -298,8 +281,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,8,30), - false, 3 - ); + false, 3); assertEquals(4, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Not the 25th or 28th @@ -317,8 +299,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,19), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-21", dateFmt.format(dates.get(0))); // Thu @@ -327,8 +308,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildWeeklyRecurrences( currentDate, dates, params, date(2011,7,22), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-25", dateFmt.format(dates.get(0))); } @@ -351,8 +331,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,10), date(2011,7,15), - true, 1 - ); + true, 1); assertEquals(0, dates.size()); dates.clear(); @@ -360,8 +339,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,10), date(2011,7,15), - false, 1 - ); + false, 1); assertEquals(0, dates.size()); @@ -371,8 +349,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,1), date(2011,7,26), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-02", dateFmt.format(dates.get(0))); @@ -381,8 +358,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,1), date(2011,7,26), - false, 1 - ); + false, 1); assertEquals(1, dates.size()); assertEquals("2011-07-02", dateFmt.format(dates.get(0))); @@ -393,8 +369,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,2), date(2011,7,26), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-02", dateFmt.format(dates.get(0))); @@ -403,8 +378,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,2), date(2011,7,26), - false, 1 - ); + false, 1); assertEquals(1, dates.size()); assertEquals("2011-07-02", dateFmt.format(dates.get(0))); @@ -415,8 +389,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,9,20), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-08-02", dateFmt.format(dates.get(0))); @@ -425,8 +398,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,9,20), - false, 1 - ); + false, 1); assertEquals(2, dates.size()); assertEquals("2011-08-02", dateFmt.format(dates.get(0))); assertEquals("2011-09-02", dateFmt.format(dates.get(1))); @@ -438,8 +410,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,1), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-02", dateFmt.format(dates.get(0))); @@ -448,8 +419,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,19), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-08-02", dateFmt.format(dates.get(0))); } @@ -472,8 +442,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,10), date(2011,7,15), - true, 1 - ); + true, 1); assertEquals(0, dates.size()); dates.clear(); @@ -481,8 +450,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,10), date(2011,7,15), - false, 1 - ); + false, 1); assertEquals(0, dates.size()); @@ -492,8 +460,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,1), date(2011,7,26), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-05", dateFmt.format(dates.get(0))); // Tuesday 5th @@ -502,8 +469,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,1), date(2011,7,26), - false, 1 - ); + false, 1); assertEquals(1, dates.size()); assertEquals("2011-07-05", dateFmt.format(dates.get(0))); // Tuesday 5th @@ -514,8 +480,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,2), date(2011,7,26), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-05", dateFmt.format(dates.get(0))); // Tuesday 5th @@ -524,8 +489,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,2), date(2011,7,26), - false, 1 - ); + false, 1); assertEquals(1, dates.size()); assertEquals("2011-07-05", dateFmt.format(dates.get(0))); // Tuesday 5th @@ -536,8 +500,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,9,20), - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-08-02", dateFmt.format(dates.get(0))); // Tuesday 2nd @@ -546,8 +509,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,20), date(2011,9,20), - false, 1 - ); + false, 1); assertEquals(2, dates.size()); assertEquals("2011-08-02", dateFmt.format(dates.get(0))); // Tuesday 2nd assertEquals("2011-09-06", dateFmt.format(dates.get(1))); // Tuesday 6th @@ -559,8 +521,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,1), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-07-05", dateFmt.format(dates.get(0))); @@ -569,8 +530,7 @@ public class CalendarHelpersTest RecurrenceHelper.buildMonthlyRecurrences( currentDate, dates, params, date(2011,7,19), null, - true, 1 - ); + true, 1); assertEquals(1, dates.size()); assertEquals("2011-08-02", dateFmt.format(dates.get(0))); } @@ -610,6 +570,7 @@ public class CalendarHelpersTest { return date(year, month, day, 0, 0); } + private static Date date(int year, int month, int day, int hour, int minute) { Calendar c = Calendar.getInstance(); diff --git a/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java b/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java index 0536ac3eb0..59d9d38003 100644 --- a/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java +++ b/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java @@ -136,14 +136,14 @@ public class CalendarServiceImpl implements CalendarService public CalendarEntry getCalendarEntry(String siteShortName, String entryName) { NodeRef container = getSiteCalendarContainer(siteShortName, false); - if(container == null) + if (container == null) { // No events return null; } NodeRef event = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, entryName); - if(event != null) + if (event != null) { CalendarEntryImpl entry = new CalendarEntryImpl(event, container, entryName); entry.populate(nodeService.getProperties(event)); @@ -156,7 +156,7 @@ public class CalendarServiceImpl implements CalendarService @Override public CalendarEntry createCalendarEntry(String siteShortName, CalendarEntry entry) { - if(entry.getNodeRef() != null) + if (entry.getNodeRef() != null) { throw new IllegalArgumentException("Can't call create for a calendar entry that was previously persisted"); } @@ -184,7 +184,7 @@ public class CalendarServiceImpl implements CalendarService // Record it's details CalendarEntryImpl entryImpl; - if(entry instanceof CalendarEntryImpl) + if (entry instanceof CalendarEntryImpl) { entryImpl = (CalendarEntryImpl)entry; entryImpl.recordStorageDetails(nodeRef, container, name); @@ -204,9 +204,10 @@ public class CalendarServiceImpl implements CalendarService } @Override - public CalendarEntry updateCalendarEntry(CalendarEntry entry) { + public CalendarEntry updateCalendarEntry(CalendarEntry entry) + { // Sanity check what we were given - if(entry.getNodeRef() == null) + if (entry.getNodeRef() == null) { throw new IllegalArgumentException("Can't update a calendar entry that was never persisted, call create instead"); } @@ -215,9 +216,9 @@ public class CalendarServiceImpl implements CalendarService Map properties = CalendarEntryImpl.toNodeProperties(entry); // Merge in the non calendar ones - for(Map.Entry prop : nodeService.getProperties(entry.getNodeRef()).entrySet()) + for (Map.Entry prop : nodeService.getProperties(entry.getNodeRef()).entrySet()) { - if(! prop.getKey().getNamespaceURI().equals(CalendarModel.CALENDAR_MODEL_URL)) + if (! prop.getKey().getNamespaceURI().equals(CalendarModel.CALENDAR_MODEL_URL)) { properties.put(prop.getKey(), prop.getValue()); } @@ -234,8 +235,9 @@ public class CalendarServiceImpl implements CalendarService } @Override - public void deleteCalendarEntry(CalendarEntry entry) { - if(entry.getNodeRef() == null) + public void deleteCalendarEntry(CalendarEntry entry) + { + if (entry.getNodeRef() == null) { throw new IllegalArgumentException("Can't delete a calendar entry that was never persisted"); } @@ -248,7 +250,7 @@ public class CalendarServiceImpl implements CalendarService String siteShortName, PagingRequest paging) { NodeRef container = getSiteCalendarContainer(siteShortName, false); - if(container == null) + if (container == null) { // No events return new EmptyPagingResults(); @@ -280,7 +282,7 @@ public class CalendarServiceImpl implements CalendarService String[] siteShortNames, PagingRequest paging) { // If we only have the one site, use the list above - if(siteShortNames != null && siteShortNames.length == 1) + if (siteShortNames != null && siteShortNames.length == 1) { return listCalendarEntries(siteShortNames[0], paging); } @@ -295,11 +297,11 @@ public class CalendarServiceImpl implements CalendarService { // Get the containers List containersL = new ArrayList(); - for(String siteShortName : siteShortNames) + for (String siteShortName : siteShortNames) { // Grab the container for this site NodeRef container = getSiteCalendarContainer(siteShortName, false); - if(container != null) + if (container != null) { containersL.add(container); } @@ -307,7 +309,7 @@ public class CalendarServiceImpl implements CalendarService NodeRef[] containers = containersL.toArray(new NodeRef[containersL.size()]); // Check we have some sites to look for - if(containers.length == 0) + if (containers.length == 0) { // No sites, so no events return new EmptyPagingResults(); @@ -316,8 +318,7 @@ public class CalendarServiceImpl implements CalendarService // Run the canned query GetCalendarEntriesCannedQueryFactory cqFactory = (GetCalendarEntriesCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_ENTRIES); GetCalendarEntriesCannedQuery cq = (GetCalendarEntriesCannedQuery)cqFactory.getCannedQuery( - containers, from, to, paging - ); + containers, from, to, paging); // Execute the canned query return cq.execute(); @@ -340,6 +341,7 @@ public class CalendarServiceImpl implements CalendarService { return results.getQueryExecutionId(); } + @Override public List getPage() { @@ -355,11 +357,13 @@ public class CalendarServiceImpl implements CalendarService } return entries; } + @Override public boolean hasMoreItems() { return results.hasMoreItems(); } + @Override public Pair getTotalResultCount() { diff --git a/source/java/org/alfresco/repo/calendar/CalendarServiceImplTest.java b/source/java/org/alfresco/repo/calendar/CalendarServiceImplTest.java index e81f1ddcc9..9f6963e183 100644 --- a/source/java/org/alfresco/repo/calendar/CalendarServiceImplTest.java +++ b/source/java/org/alfresco/repo/calendar/CalendarServiceImplTest.java @@ -31,7 +31,6 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.query.CannedQueryFactory; -import org.alfresco.query.CannedQueryResults; import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingResults; import org.alfresco.repo.calendar.cannedqueries.CalendarEntity; @@ -156,8 +155,7 @@ public class CalendarServiceImplTest // Create one entry = new CalendarEntryDTO( - "Title", "Description", "Location", new Date(1), new Date(1234) - ); + "Title", "Description", "Location", new Date(1), new Date(1234)); entry.setOutlook(true); entry.setOutlookUID("12345LookOut!"); @@ -224,8 +222,7 @@ public class CalendarServiceImplTest // Create an entry entry = new CalendarEntryDTO( - "Title", "Description", "Location", new Date(1), new Date(1234) - ); + "Title", "Description", "Location", new Date(1), new Date(1234)); entry.setOutlook(true); entry.setOutlookUID("12345LookOut!"); entry = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), entry); @@ -308,21 +305,19 @@ public class CalendarServiceImplTest @Override public Void execute() throws Throwable { - if(SITE_SERVICE.getSite(TEST_SITE_NAME) != null) + 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 - ); + TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC); // Won't have the container to start with assertFalse(SITE_SERVICE.hasContainer(TEST_SITE_NAME, CalendarServiceImpl.CALENDAR_COMPONENT)); // Create a calendar entry CalendarEntry entry = new CalendarEntryDTO( - "Title", "Description", "Location", new Date(1), new Date(1234) - ); + "Title", "Description", "Location", new Date(1), new Date(1234)); CALENDAR_SERVICE.createCalendarEntry(TEST_SITE_NAME, entry); // It will now exist @@ -348,8 +343,7 @@ public class CalendarServiceImplTest // Create one without tagging entry = new CalendarEntryDTO( - "Title", "Description", "Location", new Date(1), new Date(1234) - ); + "Title", "Description", "Location", new Date(1), new Date(1234)); entry = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), entry); testNodesToTidy.add(entry.getNodeRef()); @@ -423,8 +417,7 @@ public class CalendarServiceImplTest // Create an event with tags entry = new CalendarEntryDTO( - "Title", "Description", "Location", new Date(1), new Date(1234) - ); + "Title", "Description", "Location", new Date(1), new Date(1234)); entry.getTags().add(TAG_1); entry.getTags().add(TAG_1); entry.getTags().add(TAG_2); @@ -469,14 +462,11 @@ public class CalendarServiceImplTest // Add a few CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "TitleA", "Description", "Location", new Date(1302431400), new Date(1302435000) - )); + "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) - )); + "TitleB", "Description", "Location", new Date(1302431400), new Date(1302442200))); CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "TitleC", "Description", "Location", new Date(1302435000), new Date(1302442200) - )); + "TitleC", "Description", "Location", new Date(1302435000), new Date(1302442200))); // Check now results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging); @@ -487,8 +477,7 @@ public class CalendarServiceImplTest // Add one more, before those, and drop the page size CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "TitleD", "Description", "Location", new Date(1302417000), new Date(1302420600) - )); + "TitleD", "Description", "Location", new Date(1302417000), new Date(1302420600))); paging = new PagingRequest(3); results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging); @@ -536,19 +525,15 @@ public class CalendarServiceImplTest // Note - add the events as a different user for the site that the // test user isn't a member of! CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "TitleA", "Description", "Location", new Date(1302431400), new Date(1302435000) - )); + "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) - )); + "TitleB", "Description", "Location", new Date(1302431400), new Date(1302442200))); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "PrivateTitleA", "Description", "Location", new Date(1302431400), new Date(1302435000) - )); + "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) - )); + "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(); @@ -614,12 +599,12 @@ public class CalendarServiceImplTest AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); paging = new PagingRequest(10); results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging); - for(CalendarEntry entry : results.getPage()) + for (CalendarEntry entry : results.getPage()) { testNodesToTidy.add(entry.getNodeRef()); } results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging); - for(CalendarEntry entry : results.getPage()) + for (CalendarEntry entry : results.getPage()) { testNodesToTidy.add(entry.getNodeRef()); } @@ -855,7 +840,8 @@ public class CalendarServiceImplTest { @Override public void notifyComplete(List fullList, - List filteredList) { + List filteredList) + { full.clear(); filtered.clear(); full.addAll(fullList); @@ -877,20 +863,16 @@ public class CalendarServiceImplTest // Add some events, with a mixture of repeating and non CalendarEntry c1 = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "SiteNormal", "Description", "Location", new Date(1302431400), new Date(1302442200) - )); + "SiteNormal", "Description", "Location", new Date(1302431400), new Date(1302442200))); CalendarEntry c2 = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "SiteRepeating", "Description", "Location", new Date(1302435000), new Date(1302435000) - )); + "SiteRepeating", "Description", "Location", new Date(1302435000), new Date(1302435000))); CalendarEntry c3 = CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO( - "AltSiteNormal", "Description", "Location", new Date(1302431400), new Date(1302435000) - )); + "AltSiteNormal", "Description", "Location", new Date(1302431400), new Date(1302435000))); // Do a fetch that'll include all of them cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, from, to, paging - ); + containers, from, to, paging); cq.setTestHook(hook); cq.execute(); @@ -921,8 +903,7 @@ public class CalendarServiceImplTest from = new Date(1302431400-10); to = new Date(1302431400+10); cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, from, to, paging - ); + containers, from, to, paging); cq.setTestHook(hook); cq.execute(); @@ -940,8 +921,7 @@ public class CalendarServiceImplTest CALENDAR_SERVICE.updateCalendarEntry(c3); cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, from, to, paging - ); + containers, from, to, paging); cq.setTestHook(hook); cq.execute(); assertEquals(3, full.size()); @@ -980,8 +960,7 @@ public class CalendarServiceImplTest // Monday-Tuesday will find it for itself cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, c20110718mon.getTime(), c20110719tue.getTime(), paging - ); + containers, c20110718mon.getTime(), c20110719tue.getTime(), paging); cq.setTestHook(hook); cq.execute(); assertEquals(3, full.size()); @@ -990,8 +969,7 @@ public class CalendarServiceImplTest // Monday-Wednesday will find it for itself cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, c20110718mon.getTime(), c20110720wed.getTime(), paging - ); + containers, c20110718mon.getTime(), c20110720wed.getTime(), paging); cq.setTestHook(hook); cq.execute(); assertEquals(3, full.size()); @@ -1000,8 +978,7 @@ public class CalendarServiceImplTest // Wednesday-Friday will find it as a repeating event on the Thursday cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, c20110720wed.getTime(), c20110722fri.getTime(), paging - ); + containers, c20110720wed.getTime(), c20110722fri.getTime(), paging); cq.setTestHook(hook); cq.execute(); assertEquals(3, full.size()); @@ -1013,8 +990,7 @@ public class CalendarServiceImplTest CALENDAR_SERVICE.updateCalendarEntry(c3); cq = (GetCalendarEntriesCannedQuery)CALENDAR_CQ_FACTORY.getCannedQuery( - containers, c20110720wed.getTime(), c20110722fri.getTime(), paging - ); + containers, c20110720wed.getTime(), c20110722fri.getTime(), paging); cq.setTestHook(hook); cq.execute(); assertEquals(3, full.size()); @@ -1038,8 +1014,7 @@ public class CalendarServiceImplTest TEST_SITE_PREFIX, CalendarServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(), "test site title", "test site description", - SiteVisibility.PUBLIC - ); + SiteVisibility.PUBLIC); privateCalendarService.getSiteCalendarContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; @@ -1057,8 +1032,7 @@ public class CalendarServiceImplTest TEST_SITE_PREFIX, CalendarServiceImplTest.class.getSimpleName() + "_testAltSite" + System.currentTimeMillis(), "alternate site title", "alternate site description", - SiteVisibility.PRIVATE - ); + SiteVisibility.PRIVATE); privateCalendarService.getSiteCalendarContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; diff --git a/source/java/org/alfresco/repo/calendar/cannedqueries/GetCalendarEntriesCannedQuery.java b/source/java/org/alfresco/repo/calendar/cannedqueries/GetCalendarEntriesCannedQuery.java index d12d0dc6a2..39dfb2baa4 100644 --- a/source/java/org/alfresco/repo/calendar/cannedqueries/GetCalendarEntriesCannedQuery.java +++ b/source/java/org/alfresco/repo/calendar/cannedqueries/GetCalendarEntriesCannedQuery.java @@ -100,7 +100,7 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission Date fromDate = DefaultTypeConverter.INSTANCE.convert(Date.class, result.getFromDate()); Date toDate = DefaultTypeConverter.INSTANCE.convert(Date.class, result.getToDate()); - if(toDate == null) + if (toDate == null) { toDate = fromDate; } @@ -109,7 +109,7 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission Date recurringLastDate = DefaultTypeConverter.INSTANCE.convert(Date.class, result.getRecurrenceLastMeeting()); // Only return entries in the right period - if(entriesFromDate != null) + if (entriesFromDate != null) { // Needs to end on or after the Filter From date if(toDate == null || toDate.before(entriesFromDate)) @@ -117,7 +117,7 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission nextNodeIsAcceptable = false; } } - if(entriesToDate != null) + if (entriesToDate != null) { // Needs have started by the Filter To date if(fromDate == null || fromDate.after(entriesToDate)) @@ -127,53 +127,52 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission } // Handle recurring events specially - if(recurringRule != null && !nextNodeIsAcceptable) + if (recurringRule != null && !nextNodeIsAcceptable) { - if(entriesToDate != null || recurringLastDate != null) + if (entriesToDate != null || recurringLastDate != null) { Date searchFrom = entriesFromDate; - if(searchFrom == null) + if (searchFrom == null) { searchFrom = fromDate; } Date searchTo = entriesToDate; - if(searchTo == null) + if (searchTo == null) { searchTo = recurringLastDate; } List dates = CalendarRecurrenceHelper.getRecurrencesOnOrAfter( recurringRule, fromDate, toDate, recurringLastDate, - searchFrom, searchTo, false - ); - if(dates != null && dates.size() > 0) + searchFrom, searchTo, false); + if (dates != null && dates.size() > 0) { // Do any of these fit? - for(Date date : dates) + for (Date date : dates) { - if(entriesFromDate != null && entriesToDate != null) + if (entriesFromDate != null && entriesToDate != null) { // From and To date given, needs to sit between them - if(entriesFromDate.getTime() <= date.getTime() && + if (entriesFromDate.getTime() <= date.getTime() && date.getTime() <= entriesToDate.getTime()) { nextNodeIsAcceptable = true; break; } } - else if(entriesFromDate != null) + else if (entriesFromDate != null) { // From date but no end date, needs to be after the from - if(entriesFromDate.getTime() <= date.getTime()) + if (entriesFromDate.getTime() <= date.getTime()) { nextNodeIsAcceptable = true; break; } } - else if(entriesToDate != null) + else if (entriesToDate != null) { // End date but no start date, needs to be before the from - if(date.getTime() <= entriesToDate.getTime()) + if (date.getTime() <= entriesToDate.getTime()) { nextNodeIsAcceptable = true; break; @@ -198,7 +197,7 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission { List, SortOrder>> comparators = new ArrayList,SortOrder>>(); - for(Pair sortPair : sortPairs) + for (Pair sortPair : sortPairs) { final QName sortProperty = (QName)sortPair.getFirst(); final CalendarEntityComparator comparator = new CalendarEntityComparator(sortProperty); @@ -221,7 +220,7 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission logger.debug("Base query: "+calendarEntries.size()+" in "+(System.currentTimeMillis()-start)+" msecs"); } - if(testHook != null) + if (testHook != null) { testHook.notifyComplete(results, filtered); } @@ -246,12 +245,10 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission private static final long serialVersionUID = 5717119409619436964L; private CalendarEntryImpl(CalendarEntity entity) { - super( - entity.getNodeRef(), + super(entity.getNodeRef(), // TODO Fetch this from the database layer when querying nodeService.getPrimaryParent(entity.getNodeRef()).getParentRef(), - entity.getName() - ); + entity.getName()); super.populate(nodeService.getProperties(entity.getNodeRef())); super.setTags(taggingService.getTags(entity.getNodeRef())); } @@ -275,7 +272,8 @@ public class GetCalendarEntriesCannedQuery extends AbstractCannedQueryPermission @SuppressWarnings("unchecked") @Override - protected Comparable getProperty(CalendarEntity entity) { + protected Comparable getProperty(CalendarEntity entity) + { if (comparableProperty.equals(CalendarModel.PROP_FROM_DATE)) { return entity.getFromDate(); diff --git a/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java b/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java index 1b0370b308..b9cc7e3a73 100644 --- a/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java +++ b/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java @@ -192,11 +192,11 @@ public class DiscussionServiceImpl implements DiscussionService // Title is special - in older cases from share it was set on the // First Post but not on the Topic String title = (String)props.get(ContentModel.PROP_TITLE); - if(title == null) + if (title == null) { // Try the first child PostInfo primaryPost = getPrimaryPost(topic); - if(primaryPost != null) + if (primaryPost != null) { title = primaryPost.getTitle(); } @@ -229,10 +229,10 @@ public class DiscussionServiceImpl implements DiscussionService // Finally, do the content String contents = preLoadedContents; - if(contents == null) + if (contents == null) { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); - if(reader != null) + if (reader != null) { contents = reader.getContentString(); } @@ -248,7 +248,7 @@ public class DiscussionServiceImpl implements DiscussionService public TopicInfo getTopic(String siteShortName, String topicName) { NodeRef container = getSiteDiscussionsContainer(siteShortName, false); - if(container == null) + if (container == null) { // No discussions return null; @@ -262,7 +262,7 @@ public class DiscussionServiceImpl implements DiscussionService public TopicInfo getTopic(NodeRef parentNodeRef, String topicName) { NodeRef topic = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, topicName); - if(topic != null) + if (topic != null) { return buildTopic(topic, parentNodeRef, topicName); } @@ -273,14 +273,14 @@ public class DiscussionServiceImpl implements DiscussionService public PostInfo getPost(TopicInfo topic, String postName) { // Sanity check what we were given - if(topic.getNodeRef() == null) + if (topic.getNodeRef() == null) { throw new IllegalArgumentException("Can't get posts for a topic that was never persisted!"); } // Fetch NodeRef post = nodeService.getChildByName(topic.getNodeRef(), ContentModel.ASSOC_CONTAINS, postName); - if(post != null) + if (post != null) { return buildPost(post, topic, postName, null); } @@ -321,7 +321,7 @@ public class DiscussionServiceImpl implements DiscussionService // We require that the parent container of the topic // is always a tag scope. This should always be the case // for site containers, but perhaps not others - if(! taggingService.isTagScope(parentNodeRef)) + if (! taggingService.isTagScope(parentNodeRef)) { AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { public Void doWork() throws Exception @@ -342,14 +342,14 @@ public class DiscussionServiceImpl implements DiscussionService public PostInfo createPost(TopicInfo topic, String contents) { // Sanity check what we were given - if(topic.getNodeRef() == null) + if (topic.getNodeRef() == null) { throw new IllegalArgumentException("Can't create posts for a topic that was never persisted!"); } // Are we going to be the primary post? boolean isPrimary = false; - if(getPrimaryPost(topic) == null) + if (getPrimaryPost(topic) == null) { isPrimary = true; } @@ -357,7 +357,7 @@ public class DiscussionServiceImpl implements DiscussionService // Decide on the name. If this is the first post in a topic, // it should share the topic's name, otherwise needs a new one String name = generateName(); - if(isPrimary) + if (isPrimary) { name = topic.getSystemName(); } @@ -372,7 +372,7 @@ public class DiscussionServiceImpl implements DiscussionService // Do we want a title? By default, primary posts share a title // with the topic, but replies are title-free - if(isPrimary) + if (isPrimary) { props.put(ContentModel.PROP_TITLE, topic.getTitle()); } @@ -400,11 +400,11 @@ public class DiscussionServiceImpl implements DiscussionService public PostInfo createReply(PostInfo parentPost, String contents) { // Sanity check what we were given - if(parentPost.getNodeRef() == null) + if (parentPost.getNodeRef() == null) { throw new IllegalArgumentException("Can't reply to a post that was never persisted"); } - if(parentPost.getTopic() == null) + if (parentPost.getTopic() == null) { throw new IllegalArgumentException("Can't reply to a post with no attached topic"); } @@ -414,8 +414,7 @@ public class DiscussionServiceImpl implements DiscussionService // Now make it a reply nodeService.createAssociation( - reply.getNodeRef(), parentPost.getNodeRef(), ContentModel.ASSOC_REFERENCES - ); + reply.getNodeRef(), parentPost.getNodeRef(), ContentModel.ASSOC_REFERENCES); // All done return reply; @@ -426,7 +425,7 @@ public class DiscussionServiceImpl implements DiscussionService public TopicInfo updateTopic(TopicInfo topic) { // Sanity check what we were given - if(topic.getNodeRef() == null) + if (topic.getNodeRef() == null) { throw new IllegalArgumentException("Can't update a topic that was never persisted, call create instead"); } @@ -443,9 +442,10 @@ public class DiscussionServiceImpl implements DiscussionService } @Override - public PostInfo updatePost(PostInfo post) { + public PostInfo updatePost(PostInfo post) + { // Sanity check what we were given - if(post.getNodeRef() == null) + if (post.getNodeRef() == null) { throw new IllegalArgumentException("Can't update a post that was never persisted, call create instead"); } @@ -462,7 +462,7 @@ public class DiscussionServiceImpl implements DiscussionService // Mark it as having been updated Date updatedAt = new Date(); nodeService.setProperty(nodeRef, ContentModel.PROP_UPDATED, updatedAt); - if(post instanceof PostInfoImpl) + if (post instanceof PostInfoImpl) { ((PostInfoImpl)post).setUpdatedAt(updatedAt); ((PostInfoImpl)post).setModifiedAt(updatedAt); @@ -479,8 +479,9 @@ public class DiscussionServiceImpl implements DiscussionService @Override - public void deleteTopic(TopicInfo topic) { - if(topic.getNodeRef() == null) + public void deleteTopic(TopicInfo topic) + { + if (topic.getNodeRef() == null) { throw new IllegalArgumentException("Can't delete a topic that was never persisted"); } @@ -489,15 +490,15 @@ public class DiscussionServiceImpl implements DiscussionService } @Override - public void deletePost(PostInfo post) { - if(post.getNodeRef() == null) + public void deletePost(PostInfo post) + { + if (post.getNodeRef() == null) { throw new IllegalArgumentException("Can't delete a post that was never persisted"); } nodeService.deleteNode(post.getNodeRef()); } - @Override public Pair getForNodeRef(NodeRef nodeRef) @@ -506,13 +507,13 @@ public class DiscussionServiceImpl implements DiscussionService TopicInfo topic = null; PostInfo post = null; - if(type.equals(ForumModel.TYPE_TOPIC)) + if (type.equals(ForumModel.TYPE_TOPIC)) { ChildAssociationRef ref = nodeService.getPrimaryParent(nodeRef); String topicName = ref.getQName().getLocalName(); topic = getTopic(ref.getParentRef(), topicName); } - else if(type.equals(ForumModel.TYPE_POST)) + else if (type.equals(ForumModel.TYPE_POST)) { ChildAssociationRef toTopic = nodeService.getPrimaryParent(nodeRef); String postName = toTopic.getQName().getLocalName(); @@ -539,14 +540,14 @@ public class DiscussionServiceImpl implements DiscussionService // First up, see if there is a post with the same name as the topic // (That's the normal Share case) PostInfo post = getPost(topic, topic.getSystemName()); - if(post != null) + if (post != null) { return post; } // Cater for the explorer case, we want the first child List children = nodeService.getChildAssocs(topic.getNodeRef()); - if(children.size() == 0) + if (children.size() == 0) { // No child posts yet return null; @@ -568,7 +569,7 @@ public class DiscussionServiceImpl implements DiscussionService listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, null, null, false, paging); // Bail if the topic lacks posts - if(results.getPage().size() == 0) + if (results.getPage().size() == 0) { // No posts in the topic return null; @@ -584,9 +585,10 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults listTopics(String siteShortName, - boolean sortAscending, PagingRequest paging) { + boolean sortAscending, PagingRequest paging) + { NodeRef container = getSiteDiscussionsContainer(siteShortName, false); - if(container == null) + if (container == null) { // No topics return new EmptyPagingResults(); @@ -598,7 +600,8 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults listTopics(NodeRef nodeRef, - boolean sortAscending, PagingRequest paging) { + boolean sortAscending, PagingRequest paging) + { // Do the listing, oldest first CannedQueryResults nodes = listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, null, null, sortAscending, paging); @@ -609,9 +612,10 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults listTopics(String siteShortName, - String username, boolean sortAscending, PagingRequest paging) { + String username, boolean sortAscending, PagingRequest paging) + { NodeRef container = getSiteDiscussionsContainer(siteShortName, false); - if(container == null) + if (container == null) { // No topics return new EmptyPagingResults(); @@ -623,7 +627,8 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults listTopics(NodeRef nodeRef, - String username, boolean sortAscending, PagingRequest paging) { + String username, boolean sortAscending, PagingRequest paging) + { // Do the listing, oldest first CannedQueryResults nodes = listEntries(nodeRef, ForumModel.TYPE_TOPIC, username, null, null, sortAscending, paging); @@ -634,9 +639,10 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults listTopics(String siteShortName, - Date from, Date to, boolean sortAscending, PagingRequest paging) { + Date from, Date to, boolean sortAscending, PagingRequest paging) + { NodeRef container = getSiteDiscussionsContainer(siteShortName, false); - if(container == null) + if (container == null) { // No topics return new EmptyPagingResults(); @@ -648,7 +654,8 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults listTopics(NodeRef nodeRef, - Date from, Date to, boolean sortAscending, PagingRequest paging) { + Date from, Date to, boolean sortAscending, PagingRequest paging) + { // Do the listing, with the sort order as requested CannedQueryResults nodes = listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, from, to, sortAscending, paging); @@ -660,9 +667,10 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults> listHotTopics( - String siteShortName, Date since, PagingRequest paging) { + String siteShortName, Date since, PagingRequest paging) + { NodeRef container = getSiteDiscussionsContainer(siteShortName, false); - if(container == null) + if (container == null) { // No topics return new EmptyPagingResults>(); @@ -674,9 +682,11 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults> listHotTopics( - NodeRef nodeRef, Date since, PagingRequest paging) { + NodeRef nodeRef, Date since, PagingRequest paging) + { // Do the query - GetDiscussionTopcisWithPostsCannedQueryFactory getCQFactory = (GetDiscussionTopcisWithPostsCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_TOPICS_WITH_POSTS); + GetDiscussionTopcisWithPostsCannedQueryFactory getCQFactory = + (GetDiscussionTopcisWithPostsCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_TOPICS_WITH_POSTS); GetDiscussionTopcisWithPostsCannedQuery cq = (GetDiscussionTopcisWithPostsCannedQuery)getCQFactory.getCannedQuery( nodeRef, null, since, true, null, paging); @@ -687,12 +697,12 @@ public class DiscussionServiceImpl implements DiscussionService return wrapWithCount(results, nodeRef); } - @Override public PagingResults findTopics(String siteShortName, - String username, String tag, boolean sortAscending, PagingRequest paging) { + String username, String tag, boolean sortAscending, PagingRequest paging) + { NodeRef container = getSiteDiscussionsContainer(siteShortName, false); - if(container == null) + if (container == null) { // No topics return new EmptyPagingResults(); @@ -704,27 +714,20 @@ public class DiscussionServiceImpl implements DiscussionService @Override public PagingResults findTopics(NodeRef nodeRef, - String username, String tag, boolean sortAscending, PagingRequest paging) { + String username, String tag, boolean sortAscending, PagingRequest paging) + { // Build the query StringBuilder luceneQuery = new StringBuilder(); - luceneQuery.append( - " +TYPE:\"" + ForumModel.TYPE_TOPIC + "\"" - ); - luceneQuery.append( - " +PATH:\"" + nodeService.getPath(nodeRef).toPrefixString(namespaceService) + "/*\"" - ); + luceneQuery.append(" +TYPE:\"" + ForumModel.TYPE_TOPIC + "\""); + luceneQuery.append(" +PATH:\"" + nodeService.getPath(nodeRef).toPrefixString(namespaceService) + "/*\""); - if(username != null) + if (username != null) { - luceneQuery.append( - " +@cm\\:creator:\"" + username + "\"" - ); + luceneQuery.append(" +@cm\\:creator:\"" + username + "\""); } - if(tag != null) + if (tag != null) { - luceneQuery.append( - " +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"" - ); + luceneQuery.append(" +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"" ); } String sortOn = "@{http://www.alfresco.org/model/content/1.0}created"; @@ -757,7 +760,7 @@ public class DiscussionServiceImpl implements DiscussionService } finally { - if(results != null) + if (results != null) { results.close(); } @@ -783,7 +786,7 @@ public class DiscussionServiceImpl implements DiscussionService public PostWithReplies listPostReplies(TopicInfo topic, int levels) { PostInfo primaryPost = getPrimaryPost(topic); - if(primaryPost == null) + if (primaryPost == null) { return null; } @@ -794,7 +797,8 @@ public class DiscussionServiceImpl implements DiscussionService public PostWithReplies listPostReplies(PostInfo primaryPost, int levels) { // Grab the factory - GetChildrenWithTargetAssocsAuditableCannedQueryFactory cqFactory = (GetChildrenWithTargetAssocsAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN_TARGETS); + GetChildrenWithTargetAssocsAuditableCannedQueryFactory cqFactory = + (GetChildrenWithTargetAssocsAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN_TARGETS); // Sort by date CannedQuerySortDetails sorting = cqFactory.createDateAscendingCQSortDetails(); @@ -815,23 +819,23 @@ public class DiscussionServiceImpl implements DiscussionService } Map> idToReplies = new HashMap>(); - for(NodeWithTargetsEntity e : results.getPage()) + for (NodeWithTargetsEntity e : results.getPage()) { - for(TargetAndTypeId idP : e.getTargetIds()) + for (TargetAndTypeId idP : e.getTargetIds()) { Long id = idP.getTargetId(); NodeRef nodeRef = idToNodeRef.get(id); - if(nodeRef == null) + if (nodeRef == null) { // References a node outside of this topic continue; } - if(id.equals(e.getId())) + if (id.equals(e.getId())) { // Self reference continue; } - if(! idToReplies.containsKey(nodeRef)) + if (! idToReplies.containsKey(nodeRef)) { idToReplies.put(nodeRef, new ArrayList()); } @@ -847,31 +851,33 @@ public class DiscussionServiceImpl implements DiscussionService // Wrap return wrap(primaryPost, idToReplies, levels); } + private void calculateRepliesPreLoad(NodeRef nodeRef, List preLoad, Map> idToReplies, int levels) { preLoad.add(nodeRef); - if(levels > 0) + if (levels > 0) { List replies = idToReplies.get(nodeRef); - if(replies != null && replies.size() > 0) + if (replies != null && replies.size() > 0) { - for(NodeWithTargetsEntity entity : replies) + for (NodeWithTargetsEntity entity : replies) { calculateRepliesPreLoad(entity.getNodeRef(), preLoad, idToReplies, levels-1); } } } } + private PostWithReplies wrap(PostInfo post, Map> idToReplies, int levels) { List replies = new ArrayList(); - if(levels > 0) + if (levels > 0) { List replyEntities = idToReplies.get(post.getNodeRef()); - if(replyEntities != null && replyEntities.size() > 0) + if (replyEntities != null && replyEntities.size() > 0) { - for(NodeWithTargetsEntity entity : replyEntities) + for (NodeWithTargetsEntity entity : replyEntities) { PostInfo replyPost = buildPost(entity.getNodeRef(), post.getTopic(), entity.getName(), null); replies.add(wrap(replyPost, idToReplies, levels-1)); @@ -892,7 +898,7 @@ public class DiscussionServiceImpl implements DiscussionService { // The Canned Query system doesn't allow for zero sized pages // If they asked for that (bits of share sometimes do), bail out now - if(paging != null && paging.getMaxItems() == 0) + if (paging != null && paging.getMaxItems() == 0) { return new EmptyCannedQueryResults(null); } @@ -902,7 +908,7 @@ public class DiscussionServiceImpl implements DiscussionService // Do the sorting, newest first or last by created date (as requested) CannedQuerySortDetails sorting = null; - if(oldestFirst) + if (oldestFirst) { sorting = getChildrenCannedQueryFactory.createDateAscendingCQSortDetails(); } @@ -929,23 +935,25 @@ public class DiscussionServiceImpl implements DiscussionService private PagingResults wrap(final ResultSet finalLuceneResults, final NodeRef container) { final List topics = new ArrayList(); - for(ResultSetRow row : finalLuceneResults) + for (ResultSetRow row : finalLuceneResults) { TopicInfo topic = buildTopic( - row.getNodeRef(), container, row.getQName().getLocalName() - ); + row.getNodeRef(), container, row.getQName().getLocalName()); topics.add(topic); } // Wrap - return new PagingResults() { + return new PagingResults() + { @Override - public boolean hasMoreItems() { + public boolean hasMoreItems() + { return finalLuceneResults.hasMore(); } @Override - public Pair getTotalResultCount() { + public Pair getTotalResultCount() + { int skipCount = 0; int itemsRemainingAfterThisPage = 0; try @@ -960,12 +968,14 @@ public class DiscussionServiceImpl implements DiscussionService } @Override - public List getPage() { + public List getPage() + { return topics; } @Override - public String getQueryExecutionId() { + public String getQueryExecutionId() + { return null; } }; @@ -979,7 +989,7 @@ public class DiscussionServiceImpl implements DiscussionService { // Pre-load the nodes before we create them List ids = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { ids.add(node.getId()); } @@ -993,11 +1003,12 @@ public class DiscussionServiceImpl implements DiscussionService { return results.getQueryExecutionId(); } + @Override public List getPage() { List topics = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { NodeRef nodeRef = node.getNodeRef(); String name = node.getName(); @@ -1005,11 +1016,13 @@ public class DiscussionServiceImpl implements DiscussionService } return topics; } + @Override public boolean hasMoreItems() { return results.hasMoreItems(); } + @Override public Pair getTotalResultCount() { @@ -1026,7 +1039,7 @@ public class DiscussionServiceImpl implements DiscussionService { // Pre-load the nodes before we create them List ids = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { ids.add(node.getId()); } @@ -1040,11 +1053,12 @@ public class DiscussionServiceImpl implements DiscussionService { return results.getQueryExecutionId(); } + @Override public List getPage() { List posts = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { NodeRef nodeRef = node.getNodeRef(); String name = node.getName(); @@ -1052,11 +1066,13 @@ public class DiscussionServiceImpl implements DiscussionService } return posts; } + @Override public boolean hasMoreItems() { return results.hasMoreItems(); } + @Override public Pair getTotalResultCount() { @@ -1073,7 +1089,7 @@ public class DiscussionServiceImpl implements DiscussionService { // Pre-load the nodes before we create them List ids = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { ids.add(node.getId()); } @@ -1087,11 +1103,12 @@ public class DiscussionServiceImpl implements DiscussionService { return results.getQueryExecutionId(); } + @Override public List> getPage() { List> topics = new ArrayList>(); - for(NodeWithChildrenEntity node : results.getPage()) + for (NodeWithChildrenEntity node : results.getPage()) { NodeRef nodeRef = node.getNodeRef(); String name = node.getName(); @@ -1102,11 +1119,13 @@ public class DiscussionServiceImpl implements DiscussionService } return topics; } + @Override public boolean hasMoreItems() { return results.hasMoreItems(); } + @Override public Pair getTotalResultCount() { diff --git a/source/java/org/alfresco/repo/discussion/DiscussionServiceImplTest.java b/source/java/org/alfresco/repo/discussion/DiscussionServiceImplTest.java index 4b06c67ff5..3fecc5d7bc 100644 --- a/source/java/org/alfresco/repo/discussion/DiscussionServiceImplTest.java +++ b/source/java/org/alfresco/repo/discussion/DiscussionServiceImplTest.java @@ -235,7 +235,7 @@ public class DiscussionServiceImplTest // Check these actions in turn - for(TopicInfo topic : new TopicInfo[] {siteTopic, nodeTopic}) + for (TopicInfo topic : new TopicInfo[] {siteTopic, nodeTopic}) { AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); @@ -429,7 +429,7 @@ public class DiscussionServiceImplTest // For each, create and edit some posts - for(TopicInfo topic : new TopicInfo[] {siteTopic, nodeTopic}) + for (TopicInfo topic : new TopicInfo[] {siteTopic, nodeTopic}) { // Create a post and a reply String contents = "This Is Some Content"; @@ -810,7 +810,7 @@ public class DiscussionServiceImplTest // For both site and node based topics, check adding and // removing posts correctly affects counts - for(TopicInfo topic : new TopicInfo[] {siteT1, nodeT1}) + for (TopicInfo topic : new TopicInfo[] {siteT1, nodeT1}) { // None to start with posts = DISCUSSION_SERVICE.listPosts(topic, new PagingRequest(10)); @@ -886,7 +886,7 @@ public class DiscussionServiceImplTest testNodesToTidy.add(siteT1.getNodeRef()); testNodesToTidy.add(nodeT1.getNodeRef()); - for(TopicInfo topic : new TopicInfo[] {siteT1, nodeT1}) + for (TopicInfo topic : new TopicInfo[] {siteT1, nodeT1}) { // Listing initially gives nothing PostWithReplies pr = DISCUSSION_SERVICE.listPostReplies(topic, 1); @@ -1108,13 +1108,12 @@ public class DiscussionServiceImplTest @Override public Void execute() throws Throwable { - if(SITE_SERVICE.getSite(TEST_SITE_NAME) != null) + 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 - ); + TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC); // Won't have the container to start with assertFalse(SITE_SERVICE.hasContainer(TEST_SITE_NAME, DiscussionServiceImpl.DISCUSSION_COMPONENT)); @@ -1239,20 +1238,16 @@ public class DiscussionServiceImplTest // Create some topics TopicInfo topicSA = DISCUSSION_SERVICE.createTopic( - DISCUSSION_SITE.getShortName(), "Title1A" - ); + DISCUSSION_SITE.getShortName(), "Title1A"); TopicInfo topicSB = DISCUSSION_SERVICE.createTopic( - DISCUSSION_SITE.getShortName(), "Title1B" - ); + DISCUSSION_SITE.getShortName(), "Title1B"); testNodesToTidy.add(topicSA.getNodeRef()); testNodesToTidy.add(topicSB.getNodeRef()); TopicInfo topicNA = DISCUSSION_SERVICE.createTopic( - FORUM_NODE, "TitleNA" - ); + FORUM_NODE, "TitleNA"); TopicInfo topicNB = DISCUSSION_SERVICE.createTopic( - FORUM_NODE, "TitleNB" - ); + FORUM_NODE, "TitleNB"); testNodesToTidy.add(topicNA.getNodeRef()); testNodesToTidy.add(topicNB.getNodeRef()); @@ -1471,36 +1466,29 @@ public class DiscussionServiceImplTest // Note - add the events as a different user for the site that the // test user isn't a member of! TopicInfo topicSA = DISCUSSION_SERVICE.createTopic( - DISCUSSION_SITE.getShortName(), "Title1A" - ); + DISCUSSION_SITE.getShortName(), "Title1A"); TopicInfo topicSB = DISCUSSION_SERVICE.createTopic( - DISCUSSION_SITE.getShortName(), "Title1B" - ); + DISCUSSION_SITE.getShortName(), "Title1B"); testNodesToTidy.add(topicSA.getNodeRef()); testNodesToTidy.add(topicSB.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); TopicInfo topicPrivA = DISCUSSION_SERVICE.createTopic( - ALTERNATE_DISCUSSION_SITE.getShortName(), "PrivTitleA" - ); + ALTERNATE_DISCUSSION_SITE.getShortName(), "PrivTitleA"); TopicInfo topicPrivB = DISCUSSION_SERVICE.createTopic( - ALTERNATE_DISCUSSION_SITE.getShortName(), "PrivTitleB" - ); + ALTERNATE_DISCUSSION_SITE.getShortName(), "PrivTitleB"); TopicInfo topicPrivC = DISCUSSION_SERVICE.createTopic( - ALTERNATE_DISCUSSION_SITE.getShortName(), "PrivTitleC" - ); + ALTERNATE_DISCUSSION_SITE.getShortName(), "PrivTitleC"); testNodesToTidy.add(topicPrivA.getNodeRef()); testNodesToTidy.add(topicPrivB.getNodeRef()); testNodesToTidy.add(topicPrivC.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER); TopicInfo topicNA = DISCUSSION_SERVICE.createTopic( - FORUM_NODE, "TitleNA" - ); + FORUM_NODE, "TitleNA"); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); TopicInfo topicNB = DISCUSSION_SERVICE.createTopic( - FORUM_NODE, "TitleNB" - ); + FORUM_NODE, "TitleNB"); AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER); testNodesToTidy.add(topicNA.getNodeRef()); testNodesToTidy.add(topicNB.getNodeRef()); @@ -1635,17 +1623,17 @@ public class DiscussionServiceImplTest paging = new PagingRequest(10); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); topics = DISCUSSION_SERVICE.listTopics(DISCUSSION_SITE.getShortName(), true, paging); - for(TopicInfo topic : topics.getPage()) + for (TopicInfo topic : topics.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(topic.getNodeRef()); } topics = DISCUSSION_SERVICE.listTopics(ALTERNATE_DISCUSSION_SITE.getShortName(), true, paging); - for(TopicInfo topic : topics.getPage()) + for (TopicInfo topic : topics.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(topic.getNodeRef()); } topics = DISCUSSION_SERVICE.listTopics(FORUM_NODE, true, paging); - for(TopicInfo topic : topics.getPage()) + for (TopicInfo topic : topics.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(topic.getNodeRef()); } @@ -1661,15 +1649,15 @@ public class DiscussionServiceImplTest private void pushAuditableDatesBack(final Object thing, final int createdDaysAgo, final int modifiedDaysAgo) throws Exception { NodeRef tmpNodeRef; - if(thing instanceof NodeRef) + if (thing instanceof NodeRef) { tmpNodeRef = (NodeRef)thing; } - else if(thing instanceof TopicInfo) + else if (thing instanceof TopicInfo) { tmpNodeRef = ((TopicInfo)thing).getNodeRef(); } - else if(thing instanceof PostInfo) + else if (thing instanceof PostInfo) { tmpNodeRef = ((PostInfo)thing).getNodeRef(); } @@ -1685,19 +1673,24 @@ public class DiscussionServiceImplTest final Date newModified = new Date(modified.getTime() - modifiedDaysAgo*ONE_DAY_MS); // Update the created date - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { BEHAVIOUR_FILTER.disableBehaviour(ContentModel.ASPECT_AUDITABLE); NODE_SERVICE.setProperty(node, ContentModel.PROP_CREATED, newCreated); NODE_SERVICE.setProperty(node, ContentModel.PROP_MODIFIED, newModified); return null; } }, false, true); + // Change something else too in the public nodeservice, to force a re-index - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { BEHAVIOUR_FILTER.disableBehaviour(ContentModel.ASPECT_AUDITABLE); PUBLIC_NODE_SERVICE.setProperty(node, ContentModel.PROP_CREATED, newCreated); PUBLIC_NODE_SERVICE.setProperty(node, ContentModel.PROP_MODIFIED, newModified); @@ -1705,10 +1698,13 @@ public class DiscussionServiceImplTest return null; } }, false, true); + // Check it was taken - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { assertEquals(newCreated, NODE_SERVICE.getProperty(node, ContentModel.PROP_CREATED)); assertEquals(newCreated, PUBLIC_NODE_SERVICE.getProperty(node, ContentModel.PROP_CREATED)); assertEquals(newModified, NODE_SERVICE.getProperty(node, ContentModel.PROP_MODIFIED)); @@ -1718,12 +1714,12 @@ public class DiscussionServiceImplTest }, false, true); // Update the object itself - if(thing instanceof TopicInfo) + if (thing instanceof TopicInfo) { ((TopicInfoImpl)thing).setCreatedAt(newCreated); ((TopicInfoImpl)thing).setModifiedAt(newModified); } - if(thing instanceof PostInfo) + if (thing instanceof PostInfo) { ((PostInfoImpl)thing).setCreatedAt(newCreated); ((PostInfoImpl)thing).setModifiedAt(newModified); @@ -1743,8 +1739,7 @@ public class DiscussionServiceImplTest TEST_SITE_PREFIX, DiscussionServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(), "test site title", "test site description", - SiteVisibility.PUBLIC - ); + SiteVisibility.PUBLIC); privateDiscussionService.getSiteDiscussionsContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; @@ -1779,8 +1774,7 @@ public class DiscussionServiceImplTest TEST_SITE_PREFIX, DiscussionServiceImplTest.class.getSimpleName() + "_testAltSite" + System.currentTimeMillis(), "alternate site title", "alternate site description", - SiteVisibility.PRIVATE - ); + SiteVisibility.PRIVATE); privateDiscussionService.getSiteDiscussionsContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; diff --git a/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQuery.java b/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQuery.java index 6fcab96591..42c331b336 100644 --- a/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQuery.java +++ b/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQuery.java @@ -81,10 +81,10 @@ public class GetDiscussionTopcisWithPostsCannedQuery extends AbstractCannedQuery for (NodeWithChildrenEntity result : results) { // Filter by topic date - if(filterByTopicCreatedDate) + if (filterByTopicCreatedDate) { Date createdDate = DefaultTypeConverter.INSTANCE.convert(Date.class, result.getCreatedDate()); - if(createdDate.before(paramBean.getTopicCreatedAfter())) + if (createdDate.before(paramBean.getTopicCreatedAfter())) { // Created too early continue; @@ -92,13 +92,13 @@ public class GetDiscussionTopcisWithPostsCannedQuery extends AbstractCannedQuery } // Filter by post date - if(filterByPostCreatedDate) + if (filterByPostCreatedDate) { List wantedPosts = new ArrayList(); - for(NameAndCreatedAt post : result.getChildren()) + for (NameAndCreatedAt post : result.getChildren()) { Date createdDate = DefaultTypeConverter.INSTANCE.convert(Date.class, post.getCreatedAt()); - if(createdDate.before(paramBean.getPostCreatedAfter())) + if (createdDate.before(paramBean.getPostCreatedAfter())) { // Created too early continue; @@ -112,12 +112,12 @@ public class GetDiscussionTopcisWithPostsCannedQuery extends AbstractCannedQuery } // If required, filter out the primary post - if(paramBean.getExcludePrimaryPost()) + if (paramBean.getExcludePrimaryPost()) { List wantedPosts = new ArrayList(); - for(NameAndCreatedAt post : result.getChildren()) + for (NameAndCreatedAt post : result.getChildren()) { - if(post.getName().equals( result.getName() )) + if (post.getName().equals( result.getName() )) { // Primary post, skip continue; @@ -131,7 +131,7 @@ public class GetDiscussionTopcisWithPostsCannedQuery extends AbstractCannedQuery } // Ignore any topic with no posts - if(result.getChildren().size() == 0) + if (result.getChildren().size() == 0) { // No valid posts continue; @@ -144,9 +144,10 @@ public class GetDiscussionTopcisWithPostsCannedQuery extends AbstractCannedQuery // Sort by the result count, and then the created date Collections.sort(filtered, new Comparator() { @Override - public int compare(NodeWithChildrenEntity o1, NodeWithChildrenEntity o2) { + public int compare(NodeWithChildrenEntity o1, NodeWithChildrenEntity o2) + { int res = o2.getChildren().size() - o1.getChildren().size(); - if(res == 0) + if (res == 0) { res = o2.getCreatedDate().compareTo(o1.getCreatedDate()); } diff --git a/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQueryFactory.java b/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQueryFactory.java index b65c61ccd2..2dee6697ba 100644 --- a/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQueryFactory.java +++ b/source/java/org/alfresco/repo/discussion/cannedqueries/GetDiscussionTopcisWithPostsCannedQueryFactory.java @@ -51,8 +51,7 @@ public class GetDiscussionTopcisWithPostsCannedQueryFactory extends AbstractQNam public CannedQuery getCannedQuery(CannedQueryParameters parameters) { final GetDiscussionTopcisWithPostsCannedQuery cq = new GetDiscussionTopcisWithPostsCannedQuery( - cannedQueryDAO, methodSecurity, parameters - ); + cannedQueryDAO, methodSecurity, parameters); return (CannedQuery) cq; } @@ -73,8 +72,7 @@ public class GetDiscussionTopcisWithPostsCannedQueryFactory extends AbstractQNam getQNameId(ForumModel.TYPE_TOPIC), getQNameId(ForumModel.TYPE_POST), topicCreatedFrom, postCreatedFrom, - excludePrimaryPosts - ); + excludePrimaryPosts); CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq); diff --git a/source/java/org/alfresco/repo/forms/Form.java b/source/java/org/alfresco/repo/forms/Form.java index d6864c2fe1..e2d90372b0 100644 --- a/source/java/org/alfresco/repo/forms/Form.java +++ b/source/java/org/alfresco/repo/forms/Form.java @@ -89,12 +89,12 @@ public class Form public List getFieldDefinitionNames() { - List result = new ArrayList(fieldDefinitions.size()); - for (FieldDefinition fieldDefn : fieldDefinitions) - { - result.add(fieldDefn.getName()); - } - return result; + List result = new ArrayList(fieldDefinitions.size()); + for (FieldDefinition fieldDefn : fieldDefinitions) + { + result.add(fieldDefn.getName()); + } + return result; } /** @@ -253,8 +253,3 @@ public class Form return buffer.toString(); } } - - - - - diff --git a/source/java/org/alfresco/repo/forms/FormServiceImplTest.java b/source/java/org/alfresco/repo/forms/FormServiceImplTest.java index 0260c4d7e5..d321ea6ac5 100644 --- a/source/java/org/alfresco/repo/forms/FormServiceImplTest.java +++ b/source/java/org/alfresco/repo/forms/FormServiceImplTest.java @@ -232,7 +232,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("unchecked") - public void testGetAllDocForm() throws Exception + public void testGetAllDocForm() throws Exception { Form form = this.formService.getForm(new Item(NODE_FORM_ITEM_KIND, this.document.toString())); @@ -1705,13 +1705,13 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest public void testJavascriptAPI() throws Exception { - Map model = new HashMap(); - model.put("testDoc", this.document.toString()); - model.put("testDocName", this.documentName); - model.put("testAssociatedDoc", this.associatedDoc.toString()); - model.put("folder", this.folder.toString()); - model.put("folderName", this.folderName); - + Map model = new HashMap(); + model.put("testDoc", this.document.toString()); + model.put("testDocName", this.documentName); + model.put("testAssociatedDoc", this.associatedDoc.toString()); + model.put("folder", this.folder.toString()); + model.put("folderName", this.folderName); + ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/forms/script/test_formService.js"); this.scriptService.executeScript(location, model); } diff --git a/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java index 8c2878b115..acc5f5ae77 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java @@ -724,10 +724,10 @@ public abstract class ContentModelFormProcessor extends } } - // add the potentially changed content data object back to property map for persistence + // add the potentially changed content data object back to property map for persistence if (contentData != null) { - propsToPersist.put(ContentModel.PROP_CONTENT, contentData); + propsToPersist.put(ContentModel.PROP_CONTENT, contentData); } } } diff --git a/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java index b8ce5fb9d7..2bff032c30 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java @@ -37,22 +37,22 @@ import org.springframework.extensions.surf.util.I18NUtil; */ public class MimetypeFieldProcessor extends TransientFieldProcessor { - private static final Log logger = LogFactory.getLog(MimetypeFieldProcessor.class); - - public static final String KEY = "mimetype"; + private static final Log logger = LogFactory.getLog(MimetypeFieldProcessor.class); - private static final String MSG_MIMETYPE_LABEL = "form_service.mimetype.label"; + public static final String KEY = "mimetype"; + + private static final String MSG_MIMETYPE_LABEL = "form_service.mimetype.label"; private static final String MSG_MIMETYPE_DESC = "form_service.mimetype.description"; - @Override - protected Log getLogger() - { - return logger; - } - - @Override - protected FieldDefinition makeTransientFieldDefinition() - { + @Override + protected Log getLogger() + { + return logger; + } + + @Override + protected FieldDefinition makeTransientFieldDefinition() + { String dataKeyName = PROP_DATA_PREFIX + KEY; PropertyFieldDefinition mimetypeField = new PropertyFieldDefinition(KEY, DataTypeDefinition.TEXT .getLocalName()); @@ -62,9 +62,9 @@ public class MimetypeFieldProcessor extends TransientFieldProcessor return mimetypeField; } - @Override + @Override protected String getRegistryKey() - { - return KEY; - } + { + return KEY; + } } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormProcessorTest.java b/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormProcessorTest.java index 75d32355e2..6c1e1f970d 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormProcessorTest.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormProcessorTest.java @@ -593,8 +593,8 @@ public class TaskFormProcessorTest extends TestCase private WorkflowTask makeTask(WorkflowTransition... transitions) { String id = TASK_ID; - String title = "Test"; - WorkflowTaskState state = WorkflowTaskState.IN_PROGRESS; + String title = "Test"; + WorkflowTaskState state = WorkflowTaskState.IN_PROGRESS; WorkflowTaskDefinition taskDef = makeTaskDefinition(transitions); Map properties = makeTaskProperties(); @@ -608,7 +608,6 @@ public class TaskFormProcessorTest extends TestCase WorkflowPath path = new WorkflowPath(null, instance, node, true); return new WorkflowTask(id, taskDef, null, title, null, state, path, properties); - } private HashMap makeTaskProperties() diff --git a/source/java/org/alfresco/repo/forms/script/test_formService.js b/source/java/org/alfresco/repo/forms/script/test_formService.js index ffe18df130..3ed9555eb9 100644 --- a/source/java/org/alfresco/repo/forms/script/test_formService.js +++ b/source/java/org/alfresco/repo/forms/script/test_formService.js @@ -1,20 +1,20 @@ function testGetFormForNonExistentContentNode() { - // Replace all the digits in the ID with an 'x'. - // Surely that node will not exist... - var corruptedTestDoc = testDoc.replace(/\d/g, "x"); - var form = null; - - try - { - form = formService.getForm("node", corruptedTestDoc); - } - catch (e) - { - // expected - } - - test.assertNull(form, "Form should have not been found: " + testDoc); + // Replace all the digits in the ID with an 'x'. + // Surely that node will not exist... + var corruptedTestDoc = testDoc.replace(/\d/g, "x"); + var form = null; + + try + { + form = formService.getForm("node", corruptedTestDoc); + } + catch (e) + { + // expected + } + + test.assertNull(form, "Form should have not been found: " + testDoc); } function testGetFormForContentNode() @@ -40,8 +40,8 @@ function testGetFormForContentNode() var fieldDef = null; for (var x = 0; x < fieldDefs.length; x++) { - fieldDef = fieldDefs[x]; - fieldDefnDataHash[fieldDef.name] = fieldDef; + fieldDef = fieldDefs[x]; + fieldDefnDataHash[fieldDef.name] = fieldDef; } var nameField = fieldDefnDataHash['cm:name']; diff --git a/source/java/org/alfresco/repo/forum/CommentService.java b/source/java/org/alfresco/repo/forum/CommentService.java index a673e911bf..fd4d0f0d9b 100644 --- a/source/java/org/alfresco/repo/forum/CommentService.java +++ b/source/java/org/alfresco/repo/forum/CommentService.java @@ -21,7 +21,6 @@ package org.alfresco.repo.forum; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ForumModel; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; /** * This is a starting point for a future service for handling Share comments. diff --git a/source/java/org/alfresco/repo/forum/CommentServiceImpl.java b/source/java/org/alfresco/repo/forum/CommentServiceImpl.java index 491cd1247f..07fa8bedbc 100644 --- a/source/java/org/alfresco/repo/forum/CommentServiceImpl.java +++ b/source/java/org/alfresco/repo/forum/CommentServiceImpl.java @@ -20,7 +20,6 @@ package org.alfresco.repo.forum; import java.util.List; -import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.model.ForumModel; import org.alfresco.service.cmr.repository.ChildAssociationRef; diff --git a/source/java/org/alfresco/repo/forum/DiscussableAspect.java b/source/java/org/alfresco/repo/forum/DiscussableAspect.java index 11bd7ac945..e3150550e3 100644 --- a/source/java/org/alfresco/repo/forum/DiscussableAspect.java +++ b/source/java/org/alfresco/repo/forum/DiscussableAspect.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -75,10 +75,12 @@ public class DiscussableAspect implements { this.policyComponent = policyComponent; } + public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } + public final void setFileFolderService(FileFolderService fileFolderService) { this.fileFolderService = fileFolderService; diff --git a/source/java/org/alfresco/repo/forum/ForumPostBehaviours.java b/source/java/org/alfresco/repo/forum/ForumPostBehaviours.java index 0af3d4f946..1b35667b8a 100644 --- a/source/java/org/alfresco/repo/forum/ForumPostBehaviours.java +++ b/source/java/org/alfresco/repo/forum/ForumPostBehaviours.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java b/source/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java index d838939adc..66453f2d7f 100644 --- a/source/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java +++ b/source/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -799,7 +799,6 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri { invitationService.approve(invitationId, "No Way Hosea!"); assertTrue("excetion not thrown", false); - } catch (Exception e) { @@ -868,7 +867,6 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri { invitationService.reject(invitationId, "No Way Hosea!"); assertTrue("excetion not thrown", false); - } catch (Exception e) { @@ -972,7 +970,6 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri invitationService.searchInvitation(crit2); assertTrue("search everything returned 0 elements", resFive.size() > 0); - } /** diff --git a/source/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java b/source/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java index f3bb58c279..289efe99aa 100644 --- a/source/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java +++ b/source/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -21,7 +21,6 @@ package org.alfresco.repo.invitation; import org.alfresco.repo.site.SiteModel; import org.alfresco.service.cmr.invitation.Invitation; -import org.alfresco.service.cmr.invitation.NominatedInvitation; /** * @author Nick Smith @@ -62,6 +61,5 @@ public class ActivitiInvitationServiceImplTests extends AbstractInvitationServic // Disable Jbpm and enable Activiti workflowAdminService.setJbpmEngineEnabled(false); workflowAdminService.setActivitiEngineEnabled(true); - } } diff --git a/source/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java b/source/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java index e889ba1ece..8723451e1a 100644 --- a/source/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java +++ b/source/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -19,14 +19,13 @@ package org.alfresco.repo.invitation; - /** * Test InvitationService with both engines enabled. + * * @author Nick Smith * @since 4.0 - * */ public class FullInvitationServiceImplTests extends AbstractInvitationServiceImplTest { - // See inheited tests. + // See inherited tests. } diff --git a/source/java/org/alfresco/repo/invitation/InvitationImpl.java b/source/java/org/alfresco/repo/invitation/InvitationImpl.java index 60885767d4..3e0b571c9d 100644 --- a/source/java/org/alfresco/repo/invitation/InvitationImpl.java +++ b/source/java/org/alfresco/repo/invitation/InvitationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/InvitationProcess.java b/source/java/org/alfresco/repo/invitation/InvitationProcess.java index ef3724b567..77bfa608de 100644 --- a/source/java/org/alfresco/repo/invitation/InvitationProcess.java +++ b/source/java/org/alfresco/repo/invitation/InvitationProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -26,18 +26,15 @@ import org.alfresco.service.cmr.invitation.Invitation; * * This invitation process is the unmoderated invite someone else. */ - public interface InvitationProcess { - /* - * someone starts the invitation process - */ - public Invitation invite(Invitation request, String comment); - - - /* - * cancel this request - */ - public void cancel (Invitation request); - + /* + * someone starts the invitation process + */ + public Invitation invite(Invitation request, String comment); + + /* + * cancel this request + */ + public void cancel (Invitation request); } diff --git a/source/java/org/alfresco/repo/invitation/InvitationProcessDescription.java b/source/java/org/alfresco/repo/invitation/InvitationProcessDescription.java index 59879ce967..63d9671224 100644 --- a/source/java/org/alfresco/repo/invitation/InvitationProcessDescription.java +++ b/source/java/org/alfresco/repo/invitation/InvitationProcessDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/InvitationProcessDescriptionImpl.java b/source/java/org/alfresco/repo/invitation/InvitationProcessDescriptionImpl.java index 2bae0ce4a2..a0ab80f89e 100644 --- a/source/java/org/alfresco/repo/invitation/InvitationProcessDescriptionImpl.java +++ b/source/java/org/alfresco/repo/invitation/InvitationProcessDescriptionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/InvitationSearchCriteriaImpl.java b/source/java/org/alfresco/repo/invitation/InvitationSearchCriteriaImpl.java index 80096b0b79..a9fa2524d2 100644 --- a/source/java/org/alfresco/repo/invitation/InvitationSearchCriteriaImpl.java +++ b/source/java/org/alfresco/repo/invitation/InvitationSearchCriteriaImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -23,42 +23,59 @@ import org.alfresco.service.cmr.invitation.Invitation.ResourceType; public class InvitationSearchCriteriaImpl implements InvitationSearchCriteria { - private String invitee; - private String inviter; - private String resourceName; - private ResourceType resourceType; - private InvitationSearchCriteria.InvitationType invitationType = InvitationSearchCriteria.InvitationType.ALL; - - public void setInvitee(String invitee) { - this.invitee = invitee; - } - public String getInvitee() { - return invitee; - } - public void setInviter(String inviter) { - this.inviter = inviter; - } - public String getInviter() { - return inviter; - } - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - public String getResourceName() { - return resourceName; - } - public void setResourceType(ResourceType resourceType) { - this.resourceType = resourceType; - } - public ResourceType getResourceType() { - return resourceType; - } - public InvitationType getInvitationType() - { - return invitationType; - } - public void setInvitationType(InvitationType invitationType) - { - this.invitationType = invitationType; - } + private String invitee; + private String inviter; + private String resourceName; + private ResourceType resourceType; + private InvitationSearchCriteria.InvitationType invitationType = InvitationSearchCriteria.InvitationType.ALL; + + public void setInvitee(String invitee) + { + this.invitee = invitee; + } + + public String getInvitee() + { + return invitee; + } + + public void setInviter(String inviter) + { + this.inviter = inviter; + } + + public String getInviter() + { + return inviter; + } + + public void setResourceName(String resourceName) + { + this.resourceName = resourceName; + } + + public String getResourceName() + { + return resourceName; + } + + public void setResourceType(ResourceType resourceType) + { + this.resourceType = resourceType; + } + + public ResourceType getResourceType() + { + return resourceType; + } + + public InvitationType getInvitationType() + { + return invitationType; + } + + public void setInvitationType(InvitationType invitationType) + { + this.invitationType = invitationType; + } } diff --git a/source/java/org/alfresco/repo/invitation/InvitationServiceImpl.java b/source/java/org/alfresco/repo/invitation/InvitationServiceImpl.java index dfe3dcfae9..3df3d287a1 100644 --- a/source/java/org/alfresco/repo/invitation/InvitationServiceImpl.java +++ b/source/java/org/alfresco/repo/invitation/InvitationServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -42,7 +42,6 @@ import org.alfresco.repo.workflow.activiti.ActivitiConstants; import org.alfresco.repo.workflow.jbpm.JBPMEngine; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.invitation.Invitation; -import org.alfresco.service.cmr.invitation.Invitation.ResourceType; import org.alfresco.service.cmr.invitation.InvitationException; import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden; import org.alfresco.service.cmr.invitation.InvitationExceptionNotFound; @@ -274,12 +273,12 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli { WorkflowTask startTask = getStartTask(invitationId); NominatedInvitation invitation = getNominatedInvitation(startTask); - if(invitation == null) + if (invitation == null) { throw new InvitationException("State error, accept may only be called on a nominated invitation."); } // Check invitationId and ticket match - if(invitation.getTicket().equals(ticket)==false) + if (invitation.getTicket().equals(ticket)==false) { //TODO localise msg String msg = "Response to invite has supplied an invalid ticket. The response to the invitation could thus not be processed"; @@ -294,12 +293,12 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli private void endInvitation(WorkflowTask startTask, String transition, Map properties, QName... taskTypes ) { List tasks = workflowService.getTasksForWorkflowPath(startTask.getPath().getId()); - if(tasks.size()==1) + if (tasks.size()==1) { WorkflowTask task = tasks.get(0); - if(taskTypeMatches(task, taskTypes)) + if (taskTypeMatches(task, taskTypes)) { - if(properties != null) + if (properties != null) { workflowService.updateTask(task.getId(), properties, null, null); } @@ -322,7 +321,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli { WorkflowTask startTask = getStartTask(invitationId); ModeratedInvitation invitation = getModeratedInvitation(startTask); - if(invitation == null) + if (invitation == null) { String msg = "State error, can only call approve on a Moderated invitation."; throw new InvitationException(msg); @@ -350,7 +349,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli public Invitation reject(String invitationId, String reason) { WorkflowTask startTask = getStartTask(invitationId); - if(taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK)) + if (taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK)) { return rejectModeratedInvitation(startTask, reason); } @@ -393,7 +392,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli public Invitation cancel(String invitationId) { WorkflowTask startTask = getStartTask(invitationId); - if(taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK)) + if (taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK)) { return cancelModeratedInvitation(startTask); } @@ -446,7 +445,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli private Invitation getInvitation(WorkflowTask startTask) { Invitation invitation = getNominatedInvitation(startTask); - if(invitation == null) + if (invitation == null) { invitation = getModeratedInvitation(startTask); } @@ -572,13 +571,12 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli private boolean invitationMatches(Invitation invitation, InvitationSearchCriteria criteria) { String invitee = criteria.getInvitee(); - if(invitee!= null && - false == invitee.equals(invitation.getInviteeUserName())) + if (invitee!= null && false == invitee.equals(invitation.getInviteeUserName())) { return false; } String inviter = criteria.getInviter(); - if(inviter!= null) + if (inviter!= null) { if (invitation instanceof NominatedInvitation) { @@ -594,8 +592,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli } } String resourceName= criteria.getResourceName(); - if(resourceName!= null && - false == resourceName.equals(invitation.getResourceName())) + if (resourceName!= null && false == resourceName.equals(invitation.getResourceName())) { return false; } @@ -630,20 +627,20 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli // query for invite workflow tasks List results = new ArrayList(); - if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) + if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) { query.setTaskName(WorkflowModelModeratedInvitation.WF_REVIEW_TASK); List jbpmTasks = this.workflowService.queryTasks(query); - if(jbpmTasks !=null) + if (jbpmTasks != null) { results.addAll(jbpmTasks); } } - if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) + if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) { query.setTaskName(WorkflowModelModeratedInvitation.WF_ACTIVITI_REVIEW_TASK); List jbpmTasks = this.workflowService.queryTasks(query); - if(jbpmTasks !=null) + if (jbpmTasks != null) { results.addAll(jbpmTasks); } @@ -657,7 +654,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli query.setTaskState(WorkflowTaskState.IN_PROGRESS); String invitee = criteria.getInvitee(); - if(invitee != null) + if (invitee != null) { query.setActorId(invitee); } @@ -685,20 +682,20 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli query.setProcessCustomProps(queryProps); List results = new ArrayList(); - if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) + if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) { query.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_INVITE_PENDING); List jbpmTasks = this.workflowService.queryTasks(query); - if(jbpmTasks !=null) + if (jbpmTasks != null) { results.addAll(jbpmTasks); } } - if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) + if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) { query.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_ACTIVIT_INVITE_PENDING); List jbpmTasks = this.workflowService.queryTasks(query); - if(jbpmTasks !=null) + if (jbpmTasks != null) { results.addAll(jbpmTasks); } @@ -1183,27 +1180,29 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli private String getNominatedDefinitionName() { - if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) + if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) { return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI; } - else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) + else if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) { return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME; } + throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!"); } private String getModeratedDefinitionName() { - if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) + if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)) { return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI; } - else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) + else if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID)) { return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME; } + throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!"); } diff --git a/source/java/org/alfresco/repo/invitation/InviteHelper.java b/source/java/org/alfresco/repo/invitation/InviteHelper.java index dfeb7b174b..b87dad16c5 100644 --- a/source/java/org/alfresco/repo/invitation/InviteHelper.java +++ b/source/java/org/alfresco/repo/invitation/InviteHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -139,7 +139,7 @@ public class InviteHelper implements InitializingBean { public Void doWork() throws Exception { - if(false==authenticationService.getAuthenticationEnabled(invitee)) + if (false==authenticationService.getAuthenticationEnabled(invitee)) { authenticationService.setAuthenticationEnabled(invitee, true); } @@ -242,7 +242,7 @@ public class InviteHelper implements InitializingBean { if (overrideExisting || !siteService.isMember(siteName, invitee)) { - siteService.setMembership(siteName, invitee, role); + siteService.setMembership(siteName, invitee, role); } return null; } @@ -271,10 +271,10 @@ public class InviteHelper implements InitializingBean // outstanding for given invitee user name List pendingInvites = invitationService.listPendingInvitationsForInvitee(inviteeUserName); boolean invitesPending = CollectionUtils.isEmpty(pendingInvites)==false; - if(invitesPending && pendingInvites.size()==1) + if (invitesPending && pendingInvites.size() == 1) { Invitation pendingInvite = pendingInvites.get(0); - if(pendingInvite.getInviteId().equals(currentInviteId)) + if (pendingInvite.getInviteId().equals(currentInviteId)) { invitesPending = false; } @@ -327,7 +327,7 @@ public class InviteHelper implements InitializingBean public void sendNominatedInvitation(String inviteId, Map executionVariables) { - if(invitationService.isSendEmails()) + if (invitationService.isSendEmails()) { Map properties = makePropertiesFromContextVariables(executionVariables, sendInvitePropertyNames); @@ -365,7 +365,7 @@ public class InviteHelper implements InitializingBean public void rejectModeratedInvitation(Map vars) { //Do nothing if emails disabled. - if(invitationService.isSendEmails() == false) + if (invitationService.isSendEmails() == false) { return; } @@ -403,7 +403,7 @@ public class InviteHelper implements InitializingBean emailAction.setExecuteAsynchronously(true); actionService.executeAction(emailAction, null); } - catch(Exception e) + catch (Exception e) { // Swallow exception logger.error("unable to send reject email", e); @@ -433,5 +433,4 @@ public class InviteHelper implements InitializingBean { this.serviceRegistry = serviceRegistry; } - } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/invitation/JbpmInvitationServiceImplTests.java b/source/java/org/alfresco/repo/invitation/JbpmInvitationServiceImplTests.java index b16ec8d227..3710a11d93 100644 --- a/source/java/org/alfresco/repo/invitation/JbpmInvitationServiceImplTests.java +++ b/source/java/org/alfresco/repo/invitation/JbpmInvitationServiceImplTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -61,6 +61,5 @@ public class JbpmInvitationServiceImplTests extends AbstractInvitationServiceImp // Disable Jbpm and enable Activiti workflowAdminService.setActivitiEngineEnabled(false); workflowAdminService.setJbpmEngineEnabled(true); - } } diff --git a/source/java/org/alfresco/repo/invitation/ModeratedActionApprove.java b/source/java/org/alfresco/repo/invitation/ModeratedActionApprove.java index fc6e0d179e..cb0a71123a 100644 --- a/source/java/org/alfresco/repo/invitation/ModeratedActionApprove.java +++ b/source/java/org/alfresco/repo/invitation/ModeratedActionApprove.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java b/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java index e100313251..b5afa14193 100644 --- a/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java +++ b/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/ModeratedInvitationImpl.java b/source/java/org/alfresco/repo/invitation/ModeratedInvitationImpl.java index 62c7db0395..3e3dcd38b4 100644 --- a/source/java/org/alfresco/repo/invitation/ModeratedInvitationImpl.java +++ b/source/java/org/alfresco/repo/invitation/ModeratedInvitationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -37,16 +37,16 @@ import org.alfresco.service.namespace.QName; */ /*package scope */ class ModeratedInvitationImpl extends InvitationImpl implements ModeratedInvitation, Serializable { - private static final long serialVersionUID = -5557544865169876451L; - - private final String inviteeComments; - - public ModeratedInvitationImpl(String inviteId, Map props) - { - super(getConstructorProps(inviteId, props)); - inviteeComments = (String)props.get(WF_PROP_INVITEE_COMMENTS); - } - + private static final long serialVersionUID = -5557544865169876451L; + + private final String inviteeComments; + + public ModeratedInvitationImpl(String inviteId, Map props) + { + super(getConstructorProps(inviteId, props)); + inviteeComments = (String)props.get(WF_PROP_INVITEE_COMMENTS); + } + private static Map getConstructorProps(String inviteId, Map props) { Map parentProps = new HashMap(); @@ -58,13 +58,14 @@ import org.alfresco.service.namespace.QName; return parentProps; } - public String getInviteeComments() - { - return inviteeComments; - } - - @Override - public InvitationType getInvitationType() { - return InvitationType.MODERATED; - } + public String getInviteeComments() + { + return inviteeComments; + } + + @Override + public InvitationType getInvitationType() + { + return InvitationType.MODERATED; + } } diff --git a/source/java/org/alfresco/repo/invitation/ModeratedInvitationProcess.java b/source/java/org/alfresco/repo/invitation/ModeratedInvitationProcess.java index 372fc67585..1a092f6d66 100644 --- a/source/java/org/alfresco/repo/invitation/ModeratedInvitationProcess.java +++ b/source/java/org/alfresco/repo/invitation/ModeratedInvitationProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -30,28 +30,27 @@ import org.alfresco.service.cmr.invitation.Invitation; public interface ModeratedInvitationProcess extends InvitationProcess { - /** - * Invitee kicks off process - * @param request - * @param reason - */ - public Invitation invite(Invitation request, String reason); - - /** - * Moderator approves this request - * @param request the request to approve. - */ - public void approve(Invitation request, String reason); - - /** - * Moderator rejects this request - * @param request the request to reject - */ - public void reject(Invitation request, String reason); - - /** - * Invitee cancels this request - */ - public void cancel (Invitation request, String reason); - + /** + * Invitee kicks off process + * @param request + * @param reason + */ + public Invitation invite(Invitation request, String reason); + + /** + * Moderator approves this request + * @param request the request to approve. + */ + public void approve(Invitation request, String reason); + + /** + * Moderator rejects this request + * @param request the request to reject + */ + public void reject(Invitation request, String reason); + + /** + * Invitee cancels this request + */ + public void cancel (Invitation request, String reason); } diff --git a/source/java/org/alfresco/repo/invitation/NominatedInvitationImpl.java b/source/java/org/alfresco/repo/invitation/NominatedInvitationImpl.java index a5d7a320d6..faf0c936af 100644 --- a/source/java/org/alfresco/repo/invitation/NominatedInvitationImpl.java +++ b/source/java/org/alfresco/repo/invitation/NominatedInvitationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -150,5 +150,4 @@ import org.alfresco.service.namespace.QName; { return InvitationType.NOMINATED; } - } diff --git a/source/java/org/alfresco/repo/invitation/NominatedInvitationProcess.java b/source/java/org/alfresco/repo/invitation/NominatedInvitationProcess.java index 3e6911d722..be4ac6978f 100644 --- a/source/java/org/alfresco/repo/invitation/NominatedInvitationProcess.java +++ b/source/java/org/alfresco/repo/invitation/NominatedInvitationProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -30,26 +30,25 @@ import org.alfresco.service.cmr.invitation.Invitation; public interface NominatedInvitationProcess extends InvitationProcess { - /* - * inviter starts the invitation process - */ - public Invitation invite(Invitation request, String comment); - - /** - * invitee accepts this request - * @param request - */ - public void accept(Invitation request); - - /** - * invitee rejects this request - * @param request - */ - public void reject(Invitation request); - - /** - * cancel this request - */ - public void cancel (Invitation request); - + /* + * inviter starts the invitation process + */ + public Invitation invite(Invitation request, String comment); + + /** + * invitee accepts this request + * @param request + */ + public void accept(Invitation request); + + /** + * invitee rejects this request + * @param request + */ + public void reject(Invitation request); + + /** + * cancel this request + */ + public void cancel (Invitation request); } diff --git a/source/java/org/alfresco/repo/invitation/WorkflowModelModeratedInvitation.java b/source/java/org/alfresco/repo/invitation/WorkflowModelModeratedInvitation.java index 7ceac0aae6..e0023ac5d4 100644 --- a/source/java/org/alfresco/repo/invitation/WorkflowModelModeratedInvitation.java +++ b/source/java/org/alfresco/repo/invitation/WorkflowModelModeratedInvitation.java @@ -1,10 +1,5 @@ -package org.alfresco.repo.invitation; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; - /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -21,13 +16,16 @@ import org.alfresco.service.namespace.QName; * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ +package org.alfresco.repo.invitation; + +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; /** * Workflow Model for a Moderated Invitation */ public interface WorkflowModelModeratedInvitation { - // namespace public static final String NAMESPACE_URI = "http://www.alfresco.org/model/workflow/invite/moderated/1.0"; diff --git a/source/java/org/alfresco/repo/invitation/WorkflowModelNominatedInvitation.java b/source/java/org/alfresco/repo/invitation/WorkflowModelNominatedInvitation.java index 6a737890e9..62059a6271 100644 --- a/source/java/org/alfresco/repo/invitation/WorkflowModelNominatedInvitation.java +++ b/source/java/org/alfresco/repo/invitation/WorkflowModelNominatedInvitation.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/activiti/AbstractInvitationDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/AbstractInvitationDelegate.java index 489393e9df..96fa2a4205 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/AbstractInvitationDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/AbstractInvitationDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/activiti/AcceptNominatedInviteDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/AcceptNominatedInviteDelegate.java index 93518067ef..f7361264b5 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/AcceptNominatedInviteDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/AcceptNominatedInviteDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -39,5 +39,4 @@ public class AcceptNominatedInviteDelegate extends AbstractInvitationDelegate Map executionVariables = execution.getVariables(); inviteHelper.acceptNominatedInvitation(executionVariables); } - } diff --git a/source/java/org/alfresco/repo/invitation/activiti/ApproveModeratedInviteDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/ApproveModeratedInviteDelegate.java index ee5d239f45..f3f70ee25a 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/ApproveModeratedInviteDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/ApproveModeratedInviteDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -35,5 +35,4 @@ public class ApproveModeratedInviteDelegate extends AbstractInvitationDelegate { inviteHelper.approveModeratedInvitation(execution.getVariables()); } - } diff --git a/source/java/org/alfresco/repo/invitation/activiti/CancelNominatedInviteDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/CancelNominatedInviteDelegate.java index 63599348b7..65baefdd20 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/CancelNominatedInviteDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/CancelNominatedInviteDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/activiti/RejectModeratedInviteDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/RejectModeratedInviteDelegate.java index 862e086566..d8b7c121a4 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/RejectModeratedInviteDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/RejectModeratedInviteDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -38,5 +38,4 @@ public class RejectModeratedInviteDelegate extends AbstractInvitationDelegate { inviteHelper.rejectModeratedInvitation(execution.getVariables()); } - } diff --git a/source/java/org/alfresco/repo/invitation/activiti/RejectNominatedInviteDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/RejectNominatedInviteDelegate.java index 2e38b79bae..1c4232b816 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/RejectNominatedInviteDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/RejectNominatedInviteDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/activiti/SendNominatedInviteDelegate.java b/source/java/org/alfresco/repo/invitation/activiti/SendNominatedInviteDelegate.java index e361fa5a8b..90e22882ab 100644 --- a/source/java/org/alfresco/repo/invitation/activiti/SendNominatedInviteDelegate.java +++ b/source/java/org/alfresco/repo/invitation/activiti/SendNominatedInviteDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -41,5 +41,4 @@ public class SendNominatedInviteDelegate extends AbstractInvitationDelegate Map variables = execution.getVariables(); inviteHelper.sendNominatedInvitation(invitationId, variables); } - } diff --git a/source/java/org/alfresco/repo/invitation/script/ScriptInvitation.java b/source/java/org/alfresco/repo/invitation/script/ScriptInvitation.java index b454a3e2d7..04c199ae30 100644 --- a/source/java/org/alfresco/repo/invitation/script/ScriptInvitation.java +++ b/source/java/org/alfresco/repo/invitation/script/ScriptInvitation.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Alfresco Software Limited. + * Copyright (C) 2009-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -29,15 +29,15 @@ import org.alfresco.service.cmr.invitation.InvitationService; */ public abstract class ScriptInvitation { - private T invitation; - private InvitationService invitationService; + private T invitation; + private InvitationService invitationService; + + public ScriptInvitation(T invitation, InvitationService invitationService) + { + this.invitation = invitation; + this.invitationService = invitationService; + } - public ScriptInvitation(T invitation, InvitationService invitationService) - { - this.invitation = invitation; - this.invitationService = invitationService; - } - public void reject(String reason) { invitationService.reject(invitation.getInviteId(), reason); @@ -47,36 +47,36 @@ public abstract class ScriptInvitation { invitationService.cancel(invitation.getInviteId()); } - - public String getInviteId() - { - return invitation.getInviteId(); - } - public String getInvitationType() - { - return invitation.getInvitationType().toString(); - } + public String getInviteId() + { + return invitation.getInviteId(); + } - public String getResourceName() - { - return invitation.getResourceName(); - } - - public String getResourceType() - { - return invitation.getResourceType().toString(); - } - - protected T getInvitation() - { - return invitation; - } - - protected InvitationService getInvitationService() - { - return invitationService; - } + public String getInvitationType() + { + return invitation.getInvitationType().toString(); + } + + public String getResourceName() + { + return invitation.getResourceName(); + } + + public String getResourceType() + { + return invitation.getResourceType().toString(); + } + + protected T getInvitation() + { + return invitation; + } + + protected InvitationService getInvitationService() + { + return invitationService; + } /** * Which role to be added with @@ -84,7 +84,7 @@ public abstract class ScriptInvitation */ public String getRoleName() { - return getInvitation().getRoleName(); + return getInvitation().getRoleName(); } /** @@ -93,7 +93,7 @@ public abstract class ScriptInvitation */ public String getInviteeUserName() { - return getInvitation().getInviteeUserName(); + return getInvitation().getInviteeUserName(); } public abstract String getInviteeEmail(); diff --git a/source/java/org/alfresco/repo/invitation/script/ScriptInvitationFactory.java b/source/java/org/alfresco/repo/invitation/script/ScriptInvitationFactory.java index 2a95bf744c..2b4f7a6ebf 100644 --- a/source/java/org/alfresco/repo/invitation/script/ScriptInvitationFactory.java +++ b/source/java/org/alfresco/repo/invitation/script/ScriptInvitationFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Alfresco Software Limited. + * Copyright (C) 2009-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -52,27 +52,27 @@ public class ScriptInvitationFactory } public ScriptInvitation toScriptInvitation(Invitation invitation) - { - if(invitation instanceof NominatedInvitation) - { - return new ScriptNominatedInvitation((NominatedInvitation) invitation, invitationService); - } - - if(invitation instanceof ModeratedInvitation) - { - String userName = invitation.getInviteeUserName(); - NodeRef person = personService.getPerson(userName); - Map properties = nodeService.getProperties(person); - String firstName = (String) properties.get(ContentModel.PROP_FIRSTNAME); - String lastName = (String) properties.get(ContentModel.PROP_LASTNAME); - String email = (String) properties.get(ContentModel.PROP_EMAIL); - return new ScriptModeratedInvitation( - (ModeratedInvitation) invitation, - invitationService, - email, - firstName, - lastName); - } - throw new AlfrescoRuntimeException("Unknown invitation type."); - } + { + if(invitation instanceof NominatedInvitation) + { + return new ScriptNominatedInvitation((NominatedInvitation) invitation, invitationService); + } + + if(invitation instanceof ModeratedInvitation) + { + String userName = invitation.getInviteeUserName(); + NodeRef person = personService.getPerson(userName); + Map properties = nodeService.getProperties(person); + String firstName = (String) properties.get(ContentModel.PROP_FIRSTNAME); + String lastName = (String) properties.get(ContentModel.PROP_LASTNAME); + String email = (String) properties.get(ContentModel.PROP_EMAIL); + return new ScriptModeratedInvitation( + (ModeratedInvitation) invitation, + invitationService, + email, + firstName, + lastName); + } + throw new AlfrescoRuntimeException("Unknown invitation type."); + } } diff --git a/source/java/org/alfresco/repo/invitation/script/ScriptInvitationService.java b/source/java/org/alfresco/repo/invitation/script/ScriptInvitationService.java index a40cf2f3b9..1c0cab463a 100644 --- a/source/java/org/alfresco/repo/invitation/script/ScriptInvitationService.java +++ b/source/java/org/alfresco/repo/invitation/script/ScriptInvitationService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -43,7 +43,7 @@ import org.springframework.beans.factory.InitializingBean; public class ScriptInvitationService extends BaseScopableProcessorExtension implements InitializingBean { - + /** The invitation service */ private InvitationService invitationService; @@ -99,35 +99,35 @@ public class ScriptInvitationService extends BaseScopableProcessorExtension */ public ScriptInvitation[] listInvitations(Scriptable props) - { - InvitationSearchCriteriaImpl crit = new InvitationSearchCriteriaImpl(); + { + InvitationSearchCriteriaImpl crit = new InvitationSearchCriteriaImpl(); - if (props.has("resourceName", props)) - { - crit.setResourceName((String)props.get("resourceName", props)); - } - if (props.has("resourceType", props)) - { - crit.setResourceType(ResourceType.valueOf((String)props.get("resourceType", props))); - } - if (props.has("inviteeUserName", props)) - { - crit.setInvitee((String)props.get("inviteeUserName", props)); - } - if (props.has("invitationType", props)) - { - String invitationType = (String)props.get("invitationType", props); - crit.setInvitationType(InvitationType.valueOf(invitationType)); + if (props.has("resourceName", props)) + { + crit.setResourceName((String)props.get("resourceName", props)); } - - List invitations = invitationService.searchInvitation(crit); - ScriptInvitation[] ret = new ScriptInvitation[invitations.size()]; + if (props.has("resourceType", props)) + { + crit.setResourceType(ResourceType.valueOf((String)props.get("resourceType", props))); + } + if (props.has("inviteeUserName", props)) + { + crit.setInvitee((String)props.get("inviteeUserName", props)); + } + if (props.has("invitationType", props)) + { + String invitationType = (String)props.get("invitationType", props); + crit.setInvitationType(InvitationType.valueOf(invitationType)); + } + + List invitations = invitationService.searchInvitation(crit); + ScriptInvitation[] ret = new ScriptInvitation[invitations.size()]; int i = 0; - for(Invitation item : invitations) - { - ret[i++] = scriptInvitationFactory.toScriptInvitation(item); - } - return ret; + for(Invitation item : invitations) + { + ret[i++] = scriptInvitationFactory.toScriptInvitation(item); + } + return ret; } /* (non-Javadoc) diff --git a/source/java/org/alfresco/repo/invitation/script/ScriptModeratedInvitation.java b/source/java/org/alfresco/repo/invitation/script/ScriptModeratedInvitation.java index 307a4540f3..31462b35d3 100644 --- a/source/java/org/alfresco/repo/invitation/script/ScriptModeratedInvitation.java +++ b/source/java/org/alfresco/repo/invitation/script/ScriptModeratedInvitation.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Alfresco Software Limited. + * Copyright (C) 2009-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -29,37 +29,37 @@ import org.alfresco.service.cmr.invitation.ModeratedInvitation; */ public class ScriptModeratedInvitation extends ScriptInvitation implements java.io.Serializable { - private static final long serialVersionUID = 4285823431857215500L; + private static final long serialVersionUID = 4285823431857215500L; - private final String inviteeEmail; - private final String inviteeFirstName; - private final String inviteeLastName; - - public ScriptModeratedInvitation(ModeratedInvitation invitation, - InvitationService invitationService, - String inviteeEmail, - String inviteeFirstName, - String inviteeLastName) - { - super(invitation, invitationService); - this.inviteeEmail = inviteeEmail; - this.inviteeFirstName = inviteeFirstName; - this.inviteeLastName = inviteeLastName; - } - - public void approve(String reason) - { - getInvitationService().approve(getInviteId(), reason); - } - - /** - * The invitee comments - why does the invitee want access ? - * @return invitee comments - */ - public String getInviteeComments() - { - return getInvitation().getInviteeComments(); - } + private final String inviteeEmail; + private final String inviteeFirstName; + private final String inviteeLastName; + + public ScriptModeratedInvitation(ModeratedInvitation invitation, + InvitationService invitationService, + String inviteeEmail, + String inviteeFirstName, + String inviteeLastName) + { + super(invitation, invitationService); + this.inviteeEmail = inviteeEmail; + this.inviteeFirstName = inviteeFirstName; + this.inviteeLastName = inviteeLastName; + } + + public void approve(String reason) + { + getInvitationService().approve(getInviteId(), reason); + } + + /** + * The invitee comments - why does the invitee want access ? + * @return invitee comments + */ + public String getInviteeComments() + { + return getInvitation().getInviteeComments(); + } /* (non-Javadoc) * @see org.alfresco.repo.invitation.script.ScriptInvitation#getInviteeEmail() diff --git a/source/java/org/alfresco/repo/invitation/script/ScriptNominatedInvitation.java b/source/java/org/alfresco/repo/invitation/script/ScriptNominatedInvitation.java index 1ba69fd786..1849d58fc9 100644 --- a/source/java/org/alfresco/repo/invitation/script/ScriptNominatedInvitation.java +++ b/source/java/org/alfresco/repo/invitation/script/ScriptNominatedInvitation.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Alfresco Software Limited. + * Copyright (C) 2009-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,15 +31,15 @@ import org.springframework.extensions.surf.util.ISO8601DateFormat; * @author mrogers */ public class ScriptNominatedInvitation extends ScriptInvitation implements java.io.Serializable -{ - private static final long serialVersionUID = 6079656007339750930L; +{ + private static final long serialVersionUID = 6079656007339750930L; public ScriptNominatedInvitation(NominatedInvitation invitation, InvitationService invitationService) { super(invitation, invitationService); } - /** + /** * @see org.alfresco.service.cmr.invitation.NominatedInvitation#getInviteeEmail() */ @Override @@ -66,23 +66,23 @@ public class ScriptNominatedInvitation extends ScriptInvitation properties) { - return messageService.getMessage("invitation.invitesender.email.subject", - ModelUtil.getProductName(repoAdminService), getSiteName(properties)); + return messageService.getMessage("invitation.invitesender.email.subject", + ModelUtil.getProductName(repoAdminService), getSiteName(properties)); } private Map buildMailTextModel(Map properties, NodeRef inviter, NodeRef invitee) @@ -191,15 +191,16 @@ public class InviteSender return args; } - private String getRoleName(Map properties) { - String roleName = properties.get(wfVarRole); - String role = messageService.getMessage("invitation.invitesender.email.role."+roleName); - if(role == null) - { - role = roleName; - } - return role; - } + private String getRoleName(Map properties) + { + String roleName = properties.get(wfVarRole); + String role = messageService.getMessage("invitation.invitesender.email.role." + roleName); + if (role == null) + { + role = roleName; + } + return role; + } private String getEmail(NodeRef person) { diff --git a/source/java/org/alfresco/repo/invitation/site/InviteSenderTest.java b/source/java/org/alfresco/repo/invitation/site/InviteSenderTest.java index cb3984d2e4..c5a63c976b 100644 --- a/source/java/org/alfresco/repo/invitation/site/InviteSenderTest.java +++ b/source/java/org/alfresco/repo/invitation/site/InviteSenderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -107,17 +107,17 @@ public class InviteSenderTest extends TestCase public void testSendMailWorkingPath() throws Exception { - String rolePropertyName = "invitation.invitesender.email.role.Role"; - String subjectPropertyName = "invitation.invitesender.email.subject"; + String rolePropertyName = "invitation.invitesender.email.role.Role"; + String subjectPropertyName = "invitation.invitesender.email.subject"; + + String subjectMsg = "Subject message"; + when(messageService.getMessage(eq(subjectPropertyName), eq("Share"), eq(siteShortName))).thenReturn(subjectMsg); - String subjectMsg = "Subject message"; - when(messageService.getMessage(eq(subjectPropertyName), eq("Share"), eq(siteShortName))).thenReturn(subjectMsg); - Map properties = buildDefaultProperties(); sender.sendMail(properties); verify(messageService).getMessage(eq(subjectPropertyName), eq("Share"), eq(siteShortName)); - verify(messageService).getMessage(eq(rolePropertyName)); + verify(messageService).getMessage(eq(rolePropertyName)); verify(mailAction).setParameterValue(eq(MailActionExecuter.PARAM_FROM), eq(inviter.email)); verify(mailAction).setParameterValue(eq(MailActionExecuter.PARAM_TO), eq(invitee.email)); diff --git a/source/java/org/alfresco/repo/invitation/site/RejectInviteAction.java b/source/java/org/alfresco/repo/invitation/site/RejectInviteAction.java index a1545a4bd0..fac09f10d1 100644 --- a/source/java/org/alfresco/repo/invitation/site/RejectInviteAction.java +++ b/source/java/org/alfresco/repo/invitation/site/RejectInviteAction.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/invitation/site/SendInviteAction.java b/source/java/org/alfresco/repo/invitation/site/SendInviteAction.java index 0a44b95de3..663fb64b60 100644 --- a/source/java/org/alfresco/repo/invitation/site/SendInviteAction.java +++ b/source/java/org/alfresco/repo/invitation/site/SendInviteAction.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -38,5 +38,4 @@ public class SendInviteAction extends AbstractInvitationAction Map executionVariables = contextInstance.getVariables(); inviteHelper.sendNominatedInvitation(inviteId, executionVariables); } - } diff --git a/source/java/org/alfresco/repo/invitation/site/SiteModeratedInvitationProcess.java b/source/java/org/alfresco/repo/invitation/site/SiteModeratedInvitationProcess.java index 97c5d1dff6..7f58e7bedf 100644 --- a/source/java/org/alfresco/repo/invitation/site/SiteModeratedInvitationProcess.java +++ b/source/java/org/alfresco/repo/invitation/site/SiteModeratedInvitationProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -19,7 +19,6 @@ package org.alfresco.repo.invitation.site; import org.alfresco.repo.invitation.ModeratedInvitationProcess; -import org.alfresco.repo.invitation.NominatedInvitationProcess; import org.alfresco.service.cmr.invitation.Invitation; /** @@ -28,33 +27,29 @@ import org.alfresco.service.cmr.invitation.Invitation; */ public class SiteModeratedInvitationProcess implements ModeratedInvitationProcess { - - public void approve(Invitation request, String reason) { - // TODO Auto-generated method stub - - } - - public void cancel(Invitation request, String reason) { - // TODO Auto-generated method stub - - } - - public void reject(Invitation request, String reason) { - // TODO Auto-generated method stub - - } - - public Invitation invite(Invitation request, String reason) { - // TODO Auto-generated method stub - return null; - - } - - public void cancel(Invitation request) { - // TODO Auto-generated method stub - - } - - - + public void approve(Invitation request, String reason) + { + // TODO Auto-generated method stub + } + + public void cancel(Invitation request, String reason) + { + // TODO Auto-generated method stub + } + + public void reject(Invitation request, String reason) + { + // TODO Auto-generated method stub + } + + public Invitation invite(Invitation request, String reason) + { + // TODO Auto-generated method stub + return null; + } + + public void cancel(Invitation request) + { + // TODO Auto-generated method stub + } } diff --git a/source/java/org/alfresco/repo/invitation/site/SiteNominatedInvitationProcess.java b/source/java/org/alfresco/repo/invitation/site/SiteNominatedInvitationProcess.java index 0a974da2f2..339f5f69a8 100644 --- a/source/java/org/alfresco/repo/invitation/site/SiteNominatedInvitationProcess.java +++ b/source/java/org/alfresco/repo/invitation/site/SiteNominatedInvitationProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -27,38 +27,34 @@ import org.alfresco.service.cmr.invitation.Invitation; */ public class SiteNominatedInvitationProcess implements NominatedInvitationProcess { - /** - * inviter starts the invitation process - */ - public Invitation invite(Invitation request, String reason) - { - return null; - } - - /** - * invitee accepts this request - * @param request - */ - public void accept(Invitation request) - { - - } - - /** - * invitee rejects this request - * @param request - */ - public void reject(Invitation request) - { - - } - - /** - * cancel this request - */ - public void cancel (Invitation request) - { - - } - + /** + * inviter starts the invitation process + */ + public Invitation invite(Invitation request, String reason) + { + return null; + } + + /** + * invitee accepts this request + * @param request + */ + public void accept(Invitation request) + { + } + + /** + * invitee rejects this request + * @param request + */ + public void reject(Invitation request) + { + } + + /** + * cancel this request + */ + public void cancel (Invitation request) + { + } } diff --git a/source/java/org/alfresco/repo/links/LinksServiceImpl.java b/source/java/org/alfresco/repo/links/LinksServiceImpl.java index 9282d41ca6..1e17525881 100644 --- a/source/java/org/alfresco/repo/links/LinksServiceImpl.java +++ b/source/java/org/alfresco/repo/links/LinksServiceImpl.java @@ -169,7 +169,7 @@ public class LinksServiceImpl implements LinksService link.setURL((String)props.get(LinksModel.PROP_URL)); // Now the internal aspect - if(nodeService.hasAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK)) + if (nodeService.hasAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK)) { Boolean isInternal = DefaultTypeConverter.INSTANCE.convert( Boolean.class, props.get(LinksModel.PROP_IS_INTERNAL)); @@ -193,14 +193,14 @@ public class LinksServiceImpl implements LinksService public LinkInfo getLink(String siteShortName, String linkName) { NodeRef container = getSiteLinksContainer(siteShortName, false); - if(container == null) + if (container == null) { // No links return null; } NodeRef link = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, linkName); - if(link != null) + if (link != null) { return buildLink(link, container, linkName); } @@ -220,7 +220,7 @@ public class LinksServiceImpl implements LinksService props.put(LinksModel.PROP_DESCRIPTION, description); props.put(LinksModel.PROP_URL, url); - if(internal) + if (internal) { props.put(LinksModel.PROP_IS_INTERNAL, "true"); } @@ -254,7 +254,7 @@ public class LinksServiceImpl implements LinksService public LinkInfo updateLink(LinkInfo link) { // Sanity check what we were given - if(link.getNodeRef() == null) + if (link.getNodeRef() == null) { throw new IllegalArgumentException("Can't update a link that was never persisted, call create instead"); } @@ -266,9 +266,9 @@ public class LinksServiceImpl implements LinksService nodeService.setProperty(nodeRef, LinksModel.PROP_URL, link.getURL()); // Internal/External is "special" - if(link.isInternal()) + if (link.isInternal()) { - if(! nodeService.hasAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK)) + if (! nodeService.hasAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK)) { Map props = new HashMap(); props.put(LinksModel.PROP_IS_INTERNAL, "true"); @@ -277,7 +277,7 @@ public class LinksServiceImpl implements LinksService } else { - if(nodeService.hasAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK)) + if (nodeService.hasAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK)) { nodeService.removeAspect(nodeRef, LinksModel.ASPECT_INTERNAL_LINK); } @@ -298,7 +298,7 @@ public class LinksServiceImpl implements LinksService @Override public void deleteLink(LinkInfo link) { - if(link.getNodeRef() == null) + if (link.getNodeRef() == null) { throw new IllegalArgumentException("Can't delete a link entry that was never persisted"); } @@ -330,14 +330,15 @@ public class LinksServiceImpl implements LinksService Date from, Date to, PagingRequest paging) { NodeRef container = getSiteLinksContainer(siteShortName, false); - if(container == null) + if (container == null) { // No events return new EmptyPagingResults(); } // Run the canned query - GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN); + GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = + (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN); GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery( container, LinksModel.TYPE_LINK, user, from, to, null, null, null, getChildrenCannedQueryFactory.createDateDescendingCQSortDetails(), paging); @@ -354,7 +355,7 @@ public class LinksServiceImpl implements LinksService Date from, Date to, String tag, PagingRequest paging) { NodeRef container = getSiteLinksContainer(siteShortName, false); - if(container == null) + if (container == null) { // No links return new EmptyPagingResults(); @@ -362,30 +363,21 @@ public class LinksServiceImpl implements LinksService // Build the query StringBuilder luceneQuery = new StringBuilder(); - luceneQuery.append( - " +TYPE:\"" + LinksModel.TYPE_LINK + "\"" - ); - luceneQuery.append( - " +PATH:\"" + nodeService.getPath(container).toPrefixString(namespaceService) + "/*\"" - ); + luceneQuery.append(" +TYPE:\"" + LinksModel.TYPE_LINK + "\""); + luceneQuery.append(" +PATH:\"" + nodeService.getPath(container).toPrefixString(namespaceService) + "/*\""); - if(user != null) + if (user != null) { - luceneQuery.append( - " +@cm\\:creator:\"" + user + "\"" - ); + luceneQuery.append(" +@cm\\:creator:\"" + user + "\""); } - if(from != null && to != null) + if (from != null && to != null) { luceneQuery.append(LuceneUtils.createDateRangeQuery( - from, to, ContentModel.PROP_CREATED, dictionaryService, namespaceService - )); + from, to, ContentModel.PROP_CREATED, dictionaryService, namespaceService)); } - if(tag != null) + if (tag != null) { - luceneQuery.append( - " +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"" - ); + luceneQuery.append(" +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\""); } String sortOn = "@{http://www.alfresco.org/model/content/1.0}created"; @@ -418,7 +410,7 @@ public class LinksServiceImpl implements LinksService } finally { - if(results != null) + if (results != null) { results.close(); } @@ -430,23 +422,25 @@ public class LinksServiceImpl implements LinksService private PagingResults wrap(final ResultSet finalLuceneResults, final NodeRef container) { final List links = new ArrayList(); - for(ResultSetRow row : finalLuceneResults) + for (ResultSetRow row : finalLuceneResults) { LinkInfo link = buildLink( - row.getNodeRef(), container, row.getQName().getLocalName() - ); + row.getNodeRef(), container, row.getQName().getLocalName()); links.add(link); } // Wrap - return new PagingResults() { + return new PagingResults() + { @Override - public boolean hasMoreItems() { + public boolean hasMoreItems() + { return finalLuceneResults.hasMore(); } @Override - public Pair getTotalResultCount() { + public Pair getTotalResultCount() + { int skipCount = finalLuceneResults.getStart(); int itemsRemainingAfterThisPage = finalLuceneResults.length(); final int totalItemsInUnpagedResultSet = skipCount + itemsRemainingAfterThisPage; @@ -454,15 +448,17 @@ public class LinksServiceImpl implements LinksService } @Override - public List getPage() { + public List getPage() + { return links; } @Override - public String getQueryExecutionId() { + public String getQueryExecutionId() + { return null; } - }; + }; } /** @@ -473,7 +469,7 @@ public class LinksServiceImpl implements LinksService { // Pre-load the nodes before we create them List ids = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { ids.add(node.getId()); } @@ -487,11 +483,12 @@ public class LinksServiceImpl implements LinksService { return results.getQueryExecutionId(); } + @Override public List getPage() { List links = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { NodeRef nodeRef = node.getNodeRef(); String name = node.getName(); @@ -499,11 +496,13 @@ public class LinksServiceImpl implements LinksService } return links; } + @Override public boolean hasMoreItems() { return results.hasMoreItems(); } + @Override public Pair getTotalResultCount() { diff --git a/source/java/org/alfresco/repo/links/LinksServiceImplTest.java b/source/java/org/alfresco/repo/links/LinksServiceImplTest.java index 4de4a32757..b32dde4945 100644 --- a/source/java/org/alfresco/repo/links/LinksServiceImplTest.java +++ b/source/java/org/alfresco/repo/links/LinksServiceImplTest.java @@ -140,8 +140,7 @@ public class LinksServiceImplTest // Create one link = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "Title", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); // Ensure it got a noderef, and the correct site @@ -187,8 +186,7 @@ public class LinksServiceImplTest // Create a link link = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "Title", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); // Check it @@ -255,13 +253,12 @@ public class LinksServiceImplTest @Override public Void execute() throws Throwable { - if(SITE_SERVICE.getSite(TEST_SITE_NAME) != null) + 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 - ); + TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC); // Won't have the container to start with assertFalse(SITE_SERVICE.hasContainer(TEST_SITE_NAME, LinksServiceImpl.LINKS_COMPONENT)); @@ -269,8 +266,7 @@ public class LinksServiceImplTest // Create a link LINKS_SERVICE.createLink( TEST_SITE_NAME, "Title", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); // It will now exist assertTrue(SITE_SERVICE.hasContainer(TEST_SITE_NAME, LinksServiceImpl.LINKS_COMPONENT)); @@ -296,8 +292,7 @@ public class LinksServiceImplTest // Create one without tagging link = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "Title", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); testNodesToTidy.add(link.getNodeRef()); // Check @@ -384,16 +379,13 @@ public class LinksServiceImplTest // Add a few LinkInfo linkA = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleA", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); LinkInfo linkB = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleB", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); LinkInfo linkC = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleC", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); testNodesToTidy.add(linkA.getNodeRef()); testNodesToTidy.add(linkB.getNodeRef()); testNodesToTidy.add(linkC.getNodeRef()); @@ -409,8 +401,7 @@ public class LinksServiceImplTest AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); LinkInfo linkD = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleD", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); testNodesToTidy.add(linkD.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER); @@ -473,12 +464,12 @@ public class LinksServiceImplTest paging = new PagingRequest(10); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); results = LINKS_SERVICE.listLinks(LINKS_SITE.getShortName(), paging); - for(LinkInfo link : results.getPage()) + for (LinkInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } results = LINKS_SERVICE.listLinks(ALTERNATE_LINKS_SITE.getShortName(), paging); - for(LinkInfo link : results.getPage()) + for (LinkInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } @@ -513,28 +504,23 @@ public class LinksServiceImplTest // test user isn't a member of! LinkInfo linkA = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleA", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); LinkInfo linkB = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleB", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); testNodesToTidy.add(linkA.getNodeRef()); testNodesToTidy.add(linkB.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); LinkInfo linkPrivA = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleA", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); LinkInfo linkPrivB = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleB", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); LinkInfo linkPrivC = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleC", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); testNodesToTidy.add(linkPrivA.getNodeRef()); testNodesToTidy.add(linkPrivB.getNodeRef()); testNodesToTidy.add(linkPrivC.getNodeRef()); @@ -600,12 +586,12 @@ public class LinksServiceImplTest paging = new PagingRequest(10); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); results = LINKS_SERVICE.listLinks(LINKS_SITE.getShortName(), paging); - for(LinkInfo link : results.getPage()) + for (LinkInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } results = LINKS_SERVICE.listLinks(ALTERNATE_LINKS_SITE.getShortName(), paging); - for(LinkInfo link : results.getPage()) + for (LinkInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } @@ -635,28 +621,23 @@ public class LinksServiceImplTest // Add some entries to the two sites LinkInfo linkA = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleA", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); LinkInfo linkB = LINKS_SERVICE.createLink( LINKS_SITE.getShortName(), "TitleB", "Description", - "http://www.alfresco.com/", false - ); + "http://www.alfresco.com/", false); testNodesToTidy.add(linkA.getNodeRef()); testNodesToTidy.add(linkB.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); LinkInfo linkPrivA = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleA", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); LinkInfo linkPrivB = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleB", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); LinkInfo linkPrivC = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleC", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); testNodesToTidy.add(linkPrivA.getNodeRef()); testNodesToTidy.add(linkPrivB.getNodeRef()); testNodesToTidy.add(linkPrivC.getNodeRef()); @@ -710,8 +691,7 @@ public class LinksServiceImplTest LinkInfo linkPrivD = LINKS_SERVICE.createLink( ALTERNATE_LINKS_SITE.getShortName(), "PrivTitleD", "Description", - "http://team.alfresco.com/", false - ); + "http://team.alfresco.com/", false); testNodesToTidy.add(linkPrivD.getNodeRef()); @@ -800,28 +780,36 @@ public class LinksServiceImplTest final Date newCreated = new Date(created.getTime() - daysAgo*ONE_DAY_MS); // Update the created date - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { BEHAVIOUR_FILTER.disableBehaviour(ContentModel.ASPECT_AUDITABLE); NODE_SERVICE.setProperty(node, ContentModel.PROP_CREATED, newCreated); return null; } }, false, true); + // Change something else too in the public nodeservice, to force a re-index - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { BEHAVIOUR_FILTER.disableBehaviour(ContentModel.ASPECT_AUDITABLE); PUBLIC_NODE_SERVICE.setProperty(node, ContentModel.PROP_CREATED, newCreated); PUBLIC_NODE_SERVICE.setProperty(node, ContentModel.PROP_DESCRIPTION, "Forced Change"); return null; } }, false, true); + // Check it was taken - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { assertEquals(newCreated, NODE_SERVICE.getProperty(node, ContentModel.PROP_CREATED)); assertEquals(newCreated, PUBLIC_NODE_SERVICE.getProperty(node, ContentModel.PROP_CREATED)); return null; @@ -845,8 +833,7 @@ public class LinksServiceImplTest TEST_SITE_PREFIX, LinksServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(), "test site title", "test site description", - SiteVisibility.PUBLIC - ); + SiteVisibility.PUBLIC); privateCalendarService.getSiteLinksContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; @@ -864,8 +851,7 @@ public class LinksServiceImplTest TEST_SITE_PREFIX, LinksServiceImplTest.class.getSimpleName() + "_testAltSite" + System.currentTimeMillis(), "alternate site title", "alternate site description", - SiteVisibility.PRIVATE - ); + SiteVisibility.PRIVATE); privateCalendarService.getSiteLinksContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; diff --git a/source/java/org/alfresco/repo/notification/EMailNotificationProvider.java b/source/java/org/alfresco/repo/notification/EMailNotificationProvider.java index a1fb0282eb..71d54c4ba4 100644 --- a/source/java/org/alfresco/repo/notification/EMailNotificationProvider.java +++ b/source/java/org/alfresco/repo/notification/EMailNotificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -47,6 +47,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * EMail notification provider implementation * * @author Roy Wetherall + * @since 4.0 */ public class EMailNotificationProvider implements NotificationProvider { diff --git a/source/java/org/alfresco/repo/notification/NotificationServiceImpl.java b/source/java/org/alfresco/repo/notification/NotificationServiceImpl.java index bffe39f0a0..265bfe41da 100644 --- a/source/java/org/alfresco/repo/notification/NotificationServiceImpl.java +++ b/source/java/org/alfresco/repo/notification/NotificationServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -36,6 +36,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * Notification service implementation. * * @author Roy Wetherall + * @since 4.0 */ public class NotificationServiceImpl implements NotificationService { @@ -49,58 +50,58 @@ public class NotificationServiceImpl implements NotificationService /** Map of registered notification providers */ private Map providers = new HashMap(3); - /** - * @see org.alfresco.service.cmr.notification.NotificationService#register(org.alfresco.service.cmr.notification.NotificationProvider) - */ - @Override - public void register(NotificationProvider notificationProvider) - { - // Check mandatory params - ParameterCheck.mandatory("notificationProvider", notificationProvider); - - // Add the notification provider to the map - providers.put(notificationProvider.getName(), notificationProvider); - } - - /** - * @see org.alfresco.service.cmr.notification.NotificationService#exists(java.lang.String) - */ - @Override - public boolean exists(String notificationProvider) - { - // Check the mandatory params - ParameterCheck.mandatory("notificationProvider", notificationProvider); - - return providers.containsKey(notificationProvider); - } + /** + * @see org.alfresco.service.cmr.notification.NotificationService#register(org.alfresco.service.cmr.notification.NotificationProvider) + */ + @Override + public void register(NotificationProvider notificationProvider) + { + // Check mandatory params + ParameterCheck.mandatory("notificationProvider", notificationProvider); + + // Add the notification provider to the map + providers.put(notificationProvider.getName(), notificationProvider); + } - /** - * @see org.alfresco.service.cmr.notification.NotificationService#getNotificationProviders() - */ - @Override - public List getNotificationProviders() - { - return new ArrayList(providers.keySet()); - } - - /** - * @see org.alfresco.service.cmr.notification.NotificationService#sendNotification(java.lang.String, org.alfresco.service.cmr.notification.NotificationContext) - */ - @Override - public void sendNotification(String notificationProvider, NotificationContext notificationContext) - { - // Check the mandatory params - ParameterCheck.mandatory("notificationProvider", notificationProvider); - ParameterCheck.mandatory("notificationContext", notificationContext); - - // Check that the notificaiton provider exists - if (exists(notificationProvider) == false) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NP_DOES_NOT_EXIST, notificationProvider)); - } - - // Get the notification provider and send notification - NotificationProvider provider = providers.get(notificationProvider); - provider.sendNotification(notificationContext); - } + /** + * @see org.alfresco.service.cmr.notification.NotificationService#exists(java.lang.String) + */ + @Override + public boolean exists(String notificationProvider) + { + // Check the mandatory params + ParameterCheck.mandatory("notificationProvider", notificationProvider); + + return providers.containsKey(notificationProvider); + } + + /** + * @see org.alfresco.service.cmr.notification.NotificationService#getNotificationProviders() + */ + @Override + public List getNotificationProviders() + { + return new ArrayList(providers.keySet()); + } + + /** + * @see org.alfresco.service.cmr.notification.NotificationService#sendNotification(java.lang.String, org.alfresco.service.cmr.notification.NotificationContext) + */ + @Override + public void sendNotification(String notificationProvider, NotificationContext notificationContext) + { + // Check the mandatory params + ParameterCheck.mandatory("notificationProvider", notificationProvider); + ParameterCheck.mandatory("notificationContext", notificationContext); + + // Check that the notificaiton provider exists + if (exists(notificationProvider) == false) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NP_DOES_NOT_EXIST, notificationProvider)); + } + + // Get the notification provider and send notification + NotificationProvider provider = providers.get(notificationProvider); + provider.sendNotification(notificationContext); + } } diff --git a/source/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java b/source/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java index 5f5a37f56a..5e97703afc 100644 --- a/source/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java +++ b/source/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -42,6 +42,7 @@ import org.alfresco.util.GUID; * Notification service implementation test. * * @author Roy Wetherall + * @since 4.0 */ public class NotificationServiceImplSystemTest extends BaseAlfrescoTestCase { diff --git a/source/java/org/alfresco/repo/publishing/AbstractChannelType.java b/source/java/org/alfresco/repo/publishing/AbstractChannelType.java index e46382c45e..7568de44d6 100644 --- a/source/java/org/alfresco/repo/publishing/AbstractChannelType.java +++ b/source/java/org/alfresco/repo/publishing/AbstractChannelType.java @@ -44,7 +44,6 @@ import org.springframework.core.io.Resource; /** * @author Nick Smith * @since 4.0 - * */ public abstract class AbstractChannelType implements ChannelType, InitializingBean { diff --git a/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java b/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java index 94f21ebfd0..c467fe6310 100644 --- a/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java +++ b/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java @@ -38,7 +38,6 @@ import org.junit.Before; /** * @author Nick Smith * @since 4.0 - * */ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest { @@ -86,5 +85,4 @@ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest super.onTearDown(); } } - } diff --git a/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFilter.java b/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFilter.java index 41825217c8..07e6498b92 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFilter.java +++ b/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFilter.java @@ -32,7 +32,6 @@ import org.alfresco.util.ParameterCheck; /** * @author Nick Smith * @since 4.0 - * */ public class ChannelDependancyNodeFilter extends AbstractNodeFilter { @@ -64,13 +63,13 @@ public class ChannelDependancyNodeFilter extends AbstractNodeFilter public boolean accept(NodeRef thisNode) { String typeId = (String) nodeService.getProperty(thisNode, PROP_CHANNEL_TYPE); - if(typeId !=null) + if (typeId !=null) { ChannelType type = channelService.getChannelType(typeId); - if(type != null) + if (type != null) { NodeFilter filter = type.getNodeFilter(); - if(filter !=null) + if (filter !=null) { return filter.accept(thisNode); } @@ -78,5 +77,4 @@ public class ChannelDependancyNodeFilter extends AbstractNodeFilter } return true; } - } diff --git a/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFinder.java b/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFinder.java index a417c2bc0f..b60cfe81c3 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFinder.java +++ b/source/java/org/alfresco/repo/publishing/ChannelDependancyNodeFinder.java @@ -35,7 +35,6 @@ import org.alfresco.util.ParameterCheck; /** * @author Nick Smith * @since 4.0 - * */ public class ChannelDependancyNodeFinder extends AbstractNodeFinder { @@ -67,13 +66,13 @@ public class ChannelDependancyNodeFinder extends AbstractNodeFinder public Set findFrom(NodeRef thisNode) { String typeId = (String) nodeService.getProperty(thisNode, PROP_CHANNEL_TYPE); - if(typeId !=null) + if (typeId !=null) { ChannelType type = channelService.getChannelType(typeId); - if(type != null) + if (type != null) { NodeFinder finder = type.getNodeFinder(); - if(finder !=null) + if (finder !=null) { return finder.findFrom(thisNode); } @@ -81,5 +80,4 @@ public class ChannelDependancyNodeFinder extends AbstractNodeFinder } return Collections.emptySet(); } - } diff --git a/source/java/org/alfresco/repo/publishing/ChannelHelper.java b/source/java/org/alfresco/repo/publishing/ChannelHelper.java index 3092c074c4..b25e703676 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelHelper.java +++ b/source/java/org/alfresco/repo/publishing/ChannelHelper.java @@ -61,7 +61,6 @@ import org.alfresco.util.collections.Function; /** * @author Nick Smith * @since 4.0 - * */ public class ChannelHelper { @@ -98,8 +97,7 @@ public class ChannelHelper public Channel buildChannelObject(NodeRef nodeRef, ChannelService channelService) { - if(nodeRef == null || - nodeService.exists(nodeRef)==false) + if (nodeRef == null || nodeService.exists(nodeRef) == false) { return null; } @@ -130,7 +128,7 @@ public class ChannelHelper */ public static NodeRef mapSourceToEnvironment(NodeRef source, final NodeRef channelNode, final NodeService nodeService) { - if(source == null || channelNode == null) + if (source == null || channelNode == null) { return null; } @@ -177,10 +175,10 @@ public class ChannelHelper public Pair findChannelAndType(NodeRef node) { Pair result = getChannelAndTypeIfChannel(node); - if(result == null) + if (result == null) { result = getChannelAndType(node); - if(result == null) + if (result == null) { ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node); if (parentAssoc != null) @@ -209,7 +207,7 @@ public class ChannelHelper public boolean canPublish(NodeRef nodeToPublish, ChannelType type) { - if(type.canPublish() == false) + if (type.canPublish() == false) { return false; } @@ -234,13 +232,13 @@ public class ChannelHelper private boolean isContentTypeSupported(QName contentType, ChannelType type) { Set supportedContentTypes = type.getSupportedContentTypes(); - if(supportedContentTypes == null || supportedContentTypes.isEmpty()) + if (supportedContentTypes == null || supportedContentTypes.isEmpty()) { return true; } for (QName supportedType : supportedContentTypes) { - if(contentType.equals(supportedType) + if (contentType.equals(supportedType) || dictionaryService.isSubClass(contentType, supportedType)) { return true; @@ -257,14 +255,14 @@ public class ChannelHelper private Pair getChannelAndTypeIfChannel(NodeRef node) { QName type = nodeService.getType(node); - if(dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) + if (dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) { String channelTypeId = (String) nodeService.getProperty(node, PROP_CHANNEL_TYPE_ID); - if(channelTypeId == null) + if (channelTypeId == null) { TypeDefinition typeDef = dictionaryService.getType(type); PropertyDefinition channelTypeProp = typeDef.getProperties().get(PROP_CHANNEL_TYPE_ID); - if(channelTypeProp !=null) + if (channelTypeProp !=null) { channelTypeId = channelTypeProp.getDefaultValue(); } @@ -339,7 +337,7 @@ public class ChannelHelper private List getChannelAssocs(NodeRef channelContainer) { - if(channelContainer == null) + if (channelContainer == null) { return null; } @@ -350,7 +348,7 @@ public class ChannelHelper private List getChannelAssocsByType(NodeRef channelContainer, String channelTypeId) { - if(channelContainer == null) + if (channelContainer == null) { return null; } @@ -360,7 +358,7 @@ public class ChannelHelper private Pair getChannelAndType(NodeRef node) { NodeRef channel = (NodeRef) nodeService.getProperty(node, PROP_CHANNEL); - if(channel != null) + if (channel != null) { String channelType = (String) nodeService.getProperty(node, PROP_CHANNEL_TYPE); return new Pair(channel, channelType); @@ -375,7 +373,7 @@ public class ChannelHelper public Channel apply(ChildAssociationRef value) { NodeRef channelNode = value.getChildRef(); - if(checkPermissions && hasPublishPermissions(channelNode)==false) + if (checkPermissions && hasPublishPermissions(channelNode)==false) { return null; } @@ -431,5 +429,4 @@ public class ChannelHelper { this.permissionService = permissionService; } - } diff --git a/source/java/org/alfresco/repo/publishing/ChannelHelperTest.java b/source/java/org/alfresco/repo/publishing/ChannelHelperTest.java index b146bae782..cfca5adb0e 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelHelperTest.java +++ b/source/java/org/alfresco/repo/publishing/ChannelHelperTest.java @@ -19,11 +19,6 @@ package org.alfresco.repo.publishing; -import static org.mockito.Mockito.*; -import static junit.framework.Assert.*; - -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.NodeRef; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/source/java/org/alfresco/repo/publishing/ChannelImpl.java b/source/java/org/alfresco/repo/publishing/ChannelImpl.java index 9c9c8267e2..27ce056abe 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelImpl.java +++ b/source/java/org/alfresco/repo/publishing/ChannelImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -93,7 +93,7 @@ public class ChannelImpl implements Channel public void publish(NodeRef nodeToPublish) { channelHelper.addPublishedAspect(nodeToPublish, nodeRef); - if(channelHelper.canPublish(nodeToPublish, channelType)) + if (channelHelper.canPublish(nodeToPublish, channelType)) { channelType.publish(nodeToPublish, getProperties()); } @@ -104,7 +104,7 @@ public class ChannelImpl implements Channel */ public void unPublish(NodeRef nodeToUnpublish) { - if(channelType.canUnpublish()) + if (channelType.canUnpublish()) { channelType.unpublish(nodeToUnpublish, getProperties()); } @@ -115,7 +115,7 @@ public class ChannelImpl implements Channel */ public void updateStatus(String status, String nodeUrl) { - if(channelType.canPublishStatusUpdates()) + if (channelType.canPublishStatusUpdates()) { int urlLength = nodeUrl == null ? 0 : nodeUrl.length(); int maxLength = channelType.getMaximumStatusLength() - urlLength; @@ -124,7 +124,7 @@ public class ChannelImpl implements Channel int endpoint = Math.min(maxLength, status.length()); status = status.substring(0, endpoint ); } - String msg = nodeUrl==null ? status : status + nodeUrl; + String msg = nodeUrl == null ? status : status + nodeUrl; channelType.updateStatus(this, msg, getProperties()); } } diff --git a/source/java/org/alfresco/repo/publishing/ChannelImplTest.java b/source/java/org/alfresco/repo/publishing/ChannelImplTest.java index 384519ffa7..e3a092abf3 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelImplTest.java +++ b/source/java/org/alfresco/repo/publishing/ChannelImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -27,10 +27,10 @@ import junit.framework.TestCase; import org.alfresco.service.cmr.publishing.channels.ChannelType; import org.alfresco.service.cmr.repository.NodeRef; + /** * @author Nick Smith * @since 4.0 - * */ public class ChannelImplTest extends TestCase { diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java index 901d786d65..30c8a72c05 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java @@ -37,8 +37,6 @@ import org.alfresco.service.cmr.publishing.channels.ChannelService; import org.alfresco.service.cmr.publishing.channels.ChannelType; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.transfer.NodeFilter; import org.alfresco.service.cmr.transfer.NodeFinder; import org.alfresco.service.namespace.NamespaceService; @@ -51,7 +49,6 @@ import org.alfresco.util.collections.Filter; * @author Nick Smith * @author Brian * @since 4.0 - * */ public class ChannelServiceImpl implements ChannelService { @@ -126,7 +123,7 @@ public class ChannelServiceImpl implements ChannelService { NodeRef channelContainer = getChannelContainer(); ChannelType channelType = channelTypes.get(channelTypeId); - if(channelType == null) + if (channelType == null) { String message = "Channel Type: " + channelTypeId + " does not exist!"; throw new IllegalArgumentException(message); @@ -175,16 +172,16 @@ public class ChannelServiceImpl implements ChannelService ParameterCheck.mandatory("channelName", channelName); NodeRef channelContainer = getChannelContainer(); - if(channelContainer == null) + if (channelContainer == null) { return null; } NodeRef child = nodeService.getChildByName(channelContainer, ContentModel.ASSOC_CONTAINS, channelName); - if(child!=null) + if (child != null) { QName type = nodeService.getType(child); - if(dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) + if (dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) { return child; } @@ -209,7 +206,7 @@ public class ChannelServiceImpl implements ChannelService public List getPublishingChannels(boolean filterByPublishPermission) { final NodeRef containerNode = getChannelContainer(); - if(containerNode != null) + if (containerNode != null) { List types = CollectionUtils.filter(channelTypes.values(), new Filter() { @@ -308,7 +305,7 @@ public class ChannelServiceImpl implements ChannelService */ public Channel getChannelById(String id) { - if(id!=null&& NodeRef.isNodeRef(id)) + if (id != null && NodeRef.isNodeRef(id)) { NodeRef node = new NodeRef(id); return channelHelper.buildChannelObject(node, this); diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java index 297e6793e6..be83d7a3e2 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -46,7 +46,7 @@ import org.junit.Test; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrationTest { @@ -277,7 +277,7 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat for (Channel channel : channels) { remainingIds.remove(channel.getId()); - if(remainingIds.isEmpty()) + if (remainingIds.isEmpty()) { return true; } diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java index 3ad4bf4c59..b444222a02 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java @@ -42,10 +42,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + /** * @author Nick Smith * @since 4.0 - * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:test/alfresco/test-web-publishing-context.xml"}) @@ -154,5 +154,4 @@ public class ChannelServiceImplTest // TODO Test other NodeFilter behaviour when added. } - } diff --git a/source/java/org/alfresco/repo/publishing/Environment.java b/source/java/org/alfresco/repo/publishing/Environment.java index 178d028bac..1c3c1a2c82 100644 --- a/source/java/org/alfresco/repo/publishing/Environment.java +++ b/source/java/org/alfresco/repo/publishing/Environment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,7 +24,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public class Environment { @@ -55,9 +55,8 @@ public class Environment return channelsContainer; } - public NodeRef getNodeRef() - { - return nodeRef; - } - + public NodeRef getNodeRef() + { + return nodeRef; + } } diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java index 5353c2a383..8aec2fb12c 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java @@ -19,11 +19,9 @@ package org.alfresco.repo.publishing; - /** * @author Nick Smith * @since 4.0 - * */ public class EnvironmentImplTest //extends AbstractPublishingIntegrationTest { diff --git a/source/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java b/source/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java index ea81b811e1..dd9c44aa62 100644 --- a/source/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java +++ b/source/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java @@ -47,6 +47,10 @@ import org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; +/** + * @author Brian + * @since 4.0 + */ public class JaxbHttpMessageConverter extends AbstractXmlHttpMessageConverter { private static Log log = LogFactory.getLog(JaxbHttpMessageConverter.class); @@ -239,5 +243,4 @@ public class JaxbHttpMessageConverter extends AbstractXmlHttpMessageConverter getAllParentAssocs() { - if(transferNode==null) + if (transferNode == null) { return Collections.emptyList(); } @@ -66,7 +65,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public Set getAspects() { - if(transferNode==null) + if (transferNode == null) { return Collections.emptySet(); } @@ -78,7 +77,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public NodeRef getNodeRef() { - if(transferNode==null) + if (transferNode == null) { return null; } @@ -90,7 +89,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public List getOutboundPeerAssociations() { - if(transferNode==null) + if (transferNode == null) { return Collections.emptyList(); } @@ -102,7 +101,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public ChildAssociationRef getPrimaryParentAssoc() { - if(transferNode==null) + if (transferNode == null) { return null; } @@ -114,7 +113,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public Path getPrimaryPath() { - if(transferNode==null) + if (transferNode == null) { return null; } @@ -126,7 +125,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public Map getProperties() { - if(transferNode==null) + if (transferNode == null) { return Collections.emptyMap(); } @@ -138,7 +137,7 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot */ public QName getType() { - if(transferNode==null) + if (transferNode == null) { return null; } diff --git a/source/java/org/alfresco/repo/publishing/PublishEventAction.java b/source/java/org/alfresco/repo/publishing/PublishEventAction.java index 55e2d7d0b2..87c336fb45 100644 --- a/source/java/org/alfresco/repo/publishing/PublishEventAction.java +++ b/source/java/org/alfresco/repo/publishing/PublishEventAction.java @@ -28,9 +28,9 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * This ActionExecuter adds a publish event to the publish event queue. + * * @author Nick Smith * @since 4.0 - * */ public class PublishEventAction extends ActionExecuterAbstractBase { @@ -61,5 +61,4 @@ public class PublishEventAction extends ActionExecuterAbstractBase { this.processor = processor; } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java index 0b04758ded..92be9a7f8a 100644 --- a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java @@ -46,7 +46,6 @@ import javax.annotation.Resource; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.publishing.NodeSnapshot; import org.alfresco.service.cmr.publishing.PublishingDetails; import org.alfresco.service.cmr.publishing.PublishingEvent; @@ -67,7 +66,6 @@ import org.springframework.beans.factory.annotation.Autowired; /** * @author Nick Smith * @since 4.0 - * */ public class PublishEventActionTest extends AbstractPublishingIntegrationTest { @@ -409,7 +407,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest { PublishingDetails details = publishingService.getPublishingQueue().createPublishingDetails(); details.setPublishChannel(channel.getId()); - if(publish) + if (publish) { details.addNodesToPublish(source); } @@ -417,7 +415,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest { details.addNodesToUnpublish(source); } - if(message!=null) + if (message != null) { details.setStatusMessage(message) .setStatusNodeToLinkTo(source) diff --git a/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java b/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java index 4fb9dfba67..9dd8673f44 100644 --- a/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -33,7 +33,7 @@ import org.alfresco.util.ParameterCheck; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public class PublishServiceImpl implements PublishingService { @@ -61,34 +61,34 @@ public class PublishServiceImpl implements PublishingService /** * {@inheritDoc} */ - public PublishingEvent getPublishingEvent(String id) - { - return publishingEventHelper.getPublishingEvent(id); - } + public PublishingEvent getPublishingEvent(String id) + { + return publishingEventHelper.getPublishingEvent(id); + } - /** - * {@inheritDoc} - */ - public List getEventsForPublishedNode(NodeRef publishedNode) - { - NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef(); - List eventNodes = publishingEventHelper.getEventNodesForPublishedNode(queueNode, publishedNode); - return publishingEventHelper.getPublishingEvents(eventNodes); - } + /** + * {@inheritDoc} + */ + public List getEventsForPublishedNode(NodeRef publishedNode) + { + NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef(); + List eventNodes = publishingEventHelper.getEventNodesForPublishedNode(queueNode, publishedNode); + return publishingEventHelper.getPublishingEvents(eventNodes); + } - /** - * {@inheritDoc} - */ - public List getEventsForUnpublishedNode(NodeRef unpublishedNode) - { - NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef(); - List eventNodes = publishingEventHelper.getEventNodesForUnpublishedNode(queueNode, unpublishedNode); - return publishingEventHelper.getPublishingEvents(eventNodes); - } + /** + * {@inheritDoc} + */ + public List getEventsForUnpublishedNode(NodeRef unpublishedNode) + { + NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef(); + List eventNodes = publishingEventHelper.getEventNodesForUnpublishedNode(queueNode, unpublishedNode); + return publishingEventHelper.getPublishingEvents(eventNodes); + } - /** - * {@inheritDoc} - */ + /** + * {@inheritDoc} + */ public void cancelPublishingEvent(String id) { ParameterCheck.mandatory("id", id); @@ -130,5 +130,4 @@ public class PublishServiceImpl implements PublishingService //TODO return null; } - } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java b/source/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java index 3b040fb1f5..310621371b 100644 --- a/source/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java @@ -28,7 +28,6 @@ import org.alfresco.service.cmr.workflow.WorkflowPath; * @author Nick Smith * @author Frederik Heremans * @since 4.0 - * */ public class PublishWebContentActivitiTest extends PublishWebContentProcessTest { diff --git a/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java b/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java index c4af40551a..d09b70fbb5 100644 --- a/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java @@ -24,7 +24,6 @@ package org.alfresco.repo.publishing; * @author Nick Smith * @author Frederik Heremans * @since 4.0 - * */ public class PublishWebContentJbpmTest extends PublishWebContentProcessTest { @@ -35,5 +34,4 @@ public class PublishWebContentJbpmTest extends PublishWebContentProcessTest { return DEF_NAME; } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java b/source/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java index 42fc1826dc..f413074078 100644 --- a/source/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java @@ -71,7 +71,6 @@ import org.mockito.stubbing.Answer; * @author Frederik Heremans * * @since 4.0 - * */ public abstract class PublishWebContentProcessTest extends BaseSpringTest { @@ -133,7 +132,7 @@ public abstract class PublishWebContentProcessTest extends BaseSpringTest private void checkEnded(String instanceId2) { WorkflowInstance instance = workflowService.getWorkflowById(instanceId2); - if(instance.isActive()) + if (instance.isActive()) { List paths = workflowService.getWorkflowPaths(instance.getId()); String nodeName = paths.get(0).getNode().getName(); @@ -242,5 +241,4 @@ public abstract class PublishWebContentProcessTest extends BaseSpringTest nodeService.deleteNode(event); AuthenticationUtil.clearCurrentSecurityContext(); } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java b/source/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java index 6d594edc56..d9f93096c5 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -212,5 +212,4 @@ public class PublishingDetailsImpl implements PublishingDetails { return statusChannels; } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java b/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java index 70ee81467a..308f4ba8ee 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java @@ -31,7 +31,6 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Nick Smith * @since 4.0 - * */ public class PublishingEventFilterImpl implements PublishingEventFilter { @@ -44,7 +43,7 @@ public class PublishingEventFilterImpl implements PublishingEventFilter */ public PublishingEventFilter setIds(String... ids) { - if(ids != null && ids.length>0) + if (ids != null && ids.length > 0) { this.ids = new HashSet(Arrays.asList(ids)); } @@ -57,7 +56,7 @@ public class PublishingEventFilterImpl implements PublishingEventFilter @Override public PublishingEventFilter setIds(Collection ids) { - if(ids != null && ids.isEmpty() == false) + if (ids != null && ids.isEmpty() == false) { this.ids = new HashSet(ids); } @@ -76,7 +75,7 @@ public class PublishingEventFilterImpl implements PublishingEventFilter */ public PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes) { - if(publishedNodes != null && publishedNodes.length>0) + if (publishedNodes != null && publishedNodes.length > 0) { this.publishedNodes = new HashSet(Arrays.asList(publishedNodes)); } @@ -88,7 +87,7 @@ public class PublishingEventFilterImpl implements PublishingEventFilter */ public PublishingEventFilter setPublishedNodes(Collection publishedNodes) { - if(publishedNodes != null && publishedNodes.isEmpty() == false) + if (publishedNodes != null && publishedNodes.isEmpty() == false) { this.publishedNodes = new HashSet(publishedNodes); } @@ -108,7 +107,7 @@ public class PublishingEventFilterImpl implements PublishingEventFilter */ public PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes) { - if(unpublishedNodes != null && unpublishedNodes.length>0) + if (unpublishedNodes != null && unpublishedNodes.length > 0) { this.unpublishedNodes = new HashSet(Arrays.asList(unpublishedNodes)); } @@ -120,7 +119,7 @@ public class PublishingEventFilterImpl implements PublishingEventFilter */ public PublishingEventFilter setUnpublishedNodes(Collection unpublishedNodes) { - if(unpublishedNodes != null && unpublishedNodes.isEmpty() == false) + if (unpublishedNodes != null && unpublishedNodes.isEmpty() == false) { this.unpublishedNodes = new HashSet(unpublishedNodes); } @@ -134,5 +133,4 @@ public class PublishingEventFilterImpl implements PublishingEventFilter { return Collections.unmodifiableSet(unpublishedNodes); } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java index d2f8db0534..4471ecf207 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -98,7 +98,6 @@ import org.apache.commons.logging.LogFactory; * @author Brian * @author Nick Smith * @since 4.0 - * */ public class PublishingEventHelper { @@ -183,7 +182,7 @@ public class PublishingEventHelper public PublishingEvent getPublishingEvent(NodeRef eventNode) throws AlfrescoRuntimeException { - if(eventNode == null) + if (eventNode == null) { return null; } @@ -213,7 +212,7 @@ public class PublishingEventHelper { String message = (String) props.get(PROP_STATUS_UPDATE_MESSAGE); Collection channelNames = (Collection) props.get(PROP_STATUS_UPDATE_CHANNEL_NAMES); - if(channelNames == null || channelNames.isEmpty()) + if (channelNames == null || channelNames.isEmpty()) { return null; } @@ -237,7 +236,7 @@ public class PublishingEventHelper { checkChannelAccess(details.getPublishChannelId()); Set statusChannelIds = details.getStatusUpdateChannels(); - if(isEmpty(statusChannelIds)==false ) + if (isEmpty(statusChannelIds) == false) for (String statusChannelId : statusChannelIds) { checkChannelAccess(statusChannelId); @@ -257,7 +256,7 @@ public class PublishingEventHelper { NodeRef channelNode = new NodeRef(channelId); AccessStatus accessStatus = permissionService.hasPermission(channelNode, PermissionService.ADD_CHILDREN); - if(AccessStatus.ALLOWED != accessStatus) + if (AccessStatus.ALLOWED != accessStatus) { throw new AccessDeniedException("You do not have access to channel: " + channelId); } @@ -288,11 +287,11 @@ public class PublishingEventHelper props.put(PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH, (Serializable) unpublshStrings); String message = details.getStatusMessage(); Set statusChannels = details.getStatusUpdateChannels(); - if(message != null && isEmpty(statusChannels)==false) + if (message != null && isEmpty(statusChannels) == false) { props.put(PROP_STATUS_UPDATE_MESSAGE, message); NodeRef statusNode = details.getNodeToLinkTo(); - if(statusNode != null) + if (statusNode != null) { props.put(PROP_STATUS_UPDATE_NODE_REF, statusNode.toString()); } @@ -310,7 +309,7 @@ public class PublishingEventHelper { List eventNodes; Set publishedNodes = filter.getPublishedNodes(); - if(isEmpty(publishedNodes) == false) + if (isEmpty(publishedNodes) == false) { eventNodes= getEventNodesForPublishedNodes(queue, publishedNodes); } @@ -319,7 +318,7 @@ public class PublishingEventHelper eventNodes = getAllPublishingEventNodes(queue); } Set ids = filter.getIds(); - if(isEmpty(ids) == false) + if (isEmpty(ids) == false) { eventNodes = filterEventNodesById(eventNodes, ids); } @@ -473,7 +472,7 @@ public class PublishingEventHelper { String definitionName = workflowEngineId + "$" + WORKFLOW_DEFINITION_NAME; WorkflowDefinition definition = workflowService.getDefinitionByName(definitionName); - if(definition == null) + if (definition == null) { String msg = "The Web publishing workflow definition does not exist! Definition name: " + definitionName; throw new AlfrescoRuntimeException(msg); @@ -483,7 +482,7 @@ public class PublishingEventHelper public Calendar getScheduledTime(NodeRef eventNode) { - if(eventNode == null) + if (eventNode == null) { return null; } @@ -596,7 +595,7 @@ public class PublishingEventHelper private NodeSnapshot createUnpublishSnapshot(NodeRef source, NodeRef channelNode) { NodeRef lastEvent = getLastPublishEvent(source, channelNode); - if(lastEvent==null) + if (lastEvent == null) { String msg = "Cannot create unpublish snapshot as last publishing event does not exist! Source node: "+ source + " channelId: "+channelNode; throw new AlfrescoRuntimeException(msg); @@ -609,7 +608,7 @@ public class PublishingEventHelper public NodeRef getLastPublishEvent(NodeRef source, NodeRef channelNode) { NodeRef publishedNode = ChannelHelper.mapSourceToEnvironment(source, channelNode, nodeService); - if(publishedNode == null) + if (publishedNode == null) { return null; } @@ -650,7 +649,7 @@ public class PublishingEventHelper public AssociationRef linkToLastEvent(NodeRef publishedNode, NodeRef eventNode) { List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); - if(isEmpty(assocs)==false) + if (isEmpty(assocs) == false) { // Remove old association. AssociationRef assoc = assocs.get(0); diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java index 76316de0f4..ae8921dfcf 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java @@ -70,7 +70,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Nick Smith * @since 4.0 - * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:test/alfresco/test-web-publishing-context.xml"}) diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java b/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java index e044d5446a..486115a37c 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java @@ -31,7 +31,6 @@ import org.alfresco.service.cmr.publishing.StatusUpdate; /** * @author Nick Smith * @since 4.0 - * */ public class PublishingEventImpl implements PublishingEvent { @@ -178,12 +177,12 @@ public class PublishingEventImpl implements PublishingEvent */ public int compareTo(PublishingEvent event) { - if(event == null) + if (event == null) { return 1; } Date eventTime = event.getCreatedTime(); - if(eventTime == null) + if (eventTime == null) { return 1; } diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java index c46cc70231..2da23eb0af 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java @@ -57,7 +57,6 @@ import org.apache.commons.logging.LogFactory; /** * @author Nick Smith * @since 4.0 - * */ public class PublishingEventProcessor { @@ -71,8 +70,8 @@ public class PublishingEventProcessor private UrlShortener urlShortener; private DictionaryService dictionaryService; - public void processEventNode(NodeRef eventNode) - { + public void processEventNode(NodeRef eventNode) + { ParameterCheck.mandatory("eventNode", eventNode); try { @@ -94,7 +93,7 @@ public class PublishingEventProcessor nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, completedStatus); } } - catch(Exception e) + catch (Exception e) { log.error("Caught exception while processing publishing event " + eventNode, e); fail(eventNode, e.getMessage()); @@ -107,7 +106,7 @@ public class PublishingEventProcessor public void updateStatus(Channel publishChannel, StatusUpdate update) { - if(update == null) + if (update == null) { return; } @@ -117,7 +116,7 @@ public class PublishingEventProcessor for (String channelId : channels) { Channel channel = channelService.getChannelById(channelId); - if(channel != null) + if (channel != null) { channel.updateStatus(message, nodeUrl); } @@ -133,10 +132,10 @@ public class PublishingEventProcessor { NodeRef node = update.getNodeToLinkTo(); String nodeUrl = null; - if(node!= null) + if (node!= null) { nodeUrl = publishChannel.getUrl(node); - if(nodeUrl != null) + if (nodeUrl != null) { nodeUrl = " " + urlShortener.shortenUrl(nodeUrl); } @@ -145,7 +144,7 @@ public class PublishingEventProcessor } public void publishEvent(Channel channel, PublishingEvent event) - { + { NodeRef eventNode = eventHelper.getPublishingEventNode(event.getId()); for (PublishingPackageEntry entry : event.getPackage().getEntries()) { @@ -164,7 +163,7 @@ public class PublishingEventProcessor { NodeRef channelNode = new NodeRef(channel.getId()); NodeRef publishedNode = channelHelper.mapSourceToEnvironment(entry.getNodeRef(), channelNode); - if(NodeUtils.exists(publishedNode, nodeService)) + if (NodeUtils.exists(publishedNode, nodeService)) { channel.unPublish(publishedNode); // Need to set as temporary to delete node instead of archiving. @@ -183,7 +182,7 @@ public class PublishingEventProcessor public NodeRef publishEntry(Channel channel, PublishingPackageEntry entry, NodeRef eventNode) { NodeRef publishedNode = channelHelper.mapSourceToEnvironment(entry.getNodeRef(), channel.getNodeRef()); - if(publishedNode == null) + if (publishedNode == null) { publishedNode = publishNewNode(channel.getNodeRef(), entry.getSnapshot()); } @@ -284,67 +283,67 @@ public class PublishingEventProcessor } } - private void addAspects(NodeRef publishedNode, Collection aspects) - { - Set currentAspects = nodeService.getAspects(publishedNode); - for (QName aspect : aspects) - { - if(currentAspects.contains(aspect)==false) - { - nodeService.addAspect(publishedNode, aspect, null); - } - } - } + private void addAspects(NodeRef publishedNode, Collection aspects) + { + Set currentAspects = nodeService.getAspects(publishedNode); + for (QName aspect : aspects) + { + if (currentAspects.contains(aspect) == false) + { + nodeService.addAspect(publishedNode, aspect, null); + } + } + } - private NodeRef createPublishedNode(NodeRef root, NodeSnapshot snapshot) - { - QName type = snapshot.getType(); - Map actualProps = getPropertiesToPublish(snapshot); - String name = (String) actualProps.get(ContentModel.PROP_NAME); - if(name == null) - { - name = GUID.generate(); - } - QName assocName = QName.createQName(NAMESPACE, name); - ChildAssociationRef publishedAssoc = nodeService.createNode(root, ASSOC_CONTAINS, assocName, type, actualProps); - NodeRef publishedNode = publishedAssoc.getChildRef(); - return publishedNode; - } + private NodeRef createPublishedNode(NodeRef root, NodeSnapshot snapshot) + { + QName type = snapshot.getType(); + Map actualProps = getPropertiesToPublish(snapshot); + String name = (String) actualProps.get(ContentModel.PROP_NAME); + if (name == null) + { + name = GUID.generate(); + } + QName assocName = QName.createQName(NAMESPACE, name); + ChildAssociationRef publishedAssoc = nodeService.createNode(root, ASSOC_CONTAINS, assocName, type, actualProps); + NodeRef publishedNode = publishedAssoc.getChildRef(); + return publishedNode; + } - private Map getPropertiesToPublish(NodeSnapshot snapshot) - { - Map properties = snapshot.getProperties(); - // Remove the Node Ref Id - Map actualProps = new HashMap(properties); - actualProps.remove(ContentModel.PROP_NODE_UUID); - return actualProps; - } + private Map getPropertiesToPublish(NodeSnapshot snapshot) + { + Map properties = snapshot.getProperties(); + // Remove the Node Ref Id + Map actualProps = new HashMap(properties); + actualProps.remove(ContentModel.PROP_NODE_UUID); + return actualProps; + } - /** - * @param channelHelper the channelHelper to set - */ - public void setChannelHelper(ChannelHelper channelHelper) - { - this.channelHelper = channelHelper; - } - - /** - * @param channelService the channelService to set - */ - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - } - - /** - * @param eventHelper the Publishing Event Helper to set - */ - public void setPublishingEventHelper(PublishingEventHelper eventHelper) - { - this.eventHelper = eventHelper; - } + /** + * @param channelHelper the channelHelper to set + */ + public void setChannelHelper(ChannelHelper channelHelper) + { + this.channelHelper = channelHelper; + } + + /** + * @param channelService the channelService to set + */ + public void setChannelService(ChannelService channelService) + { + this.channelService = channelService; + } + + /** + * @param eventHelper the Publishing Event Helper to set + */ + public void setPublishingEventHelper(PublishingEventHelper eventHelper) + { + this.eventHelper = eventHelper; + } - /** + /** * @param nodeService the nodeService to set */ public void setNodeService(NodeService nodeService) diff --git a/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java b/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java index f8929d734f..0bbe6b15fa 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -54,7 +54,7 @@ import org.junit.Test; /** * @author Brian - * + * @since 4.0 */ public class PublishingIntegratedTest extends BaseSpringTest { @@ -168,5 +168,4 @@ public class PublishingIntegratedTest extends BaseSpringTest channelService.register(mockedChannelType); } } - } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/publishing/PublishingModel.java b/source/java/org/alfresco/repo/publishing/PublishingModel.java index d01d25af7a..482c7685e1 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingModel.java +++ b/source/java/org/alfresco/repo/publishing/PublishingModel.java @@ -24,7 +24,6 @@ import org.alfresco.service.namespace.QName; /** * @author Nick Smith * @since 4.0 - * */ public interface PublishingModel { @@ -95,5 +94,4 @@ public interface PublishingModel // Workflow Properties public static final QName PROP_WF_PUBLISHING_EVENT= QName.createQName(WF_NAMESPACE, "publishingEvent"); public static final QName PROP_WF_SCHEDULED_PUBLISH_DATE= QName.createQName(WF_NAMESPACE, "scheduledPublishDate"); - } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java b/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java index 54a259cf67..dffa0a50d0 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java @@ -27,7 +27,6 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Brian * @author Nick Smith * @since 4.0 - * */ // Package protected class PublishingPackageEntryImpl implements PublishingPackageEntry diff --git a/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java b/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java index c95c876dd7..c0bb75bcc1 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -33,7 +33,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public class PublishingPackageImpl implements PublishingPackage { @@ -48,7 +48,7 @@ public class PublishingPackageImpl implements PublishingPackage for (PublishingPackageEntry entry : entries.values()) { NodeRef node = entry.getNodeRef(); - if(entry.isPublish()) + if (entry.isPublish()) { toPublish.add(node); } @@ -92,5 +92,4 @@ public class PublishingPackageImpl implements PublishingPackage { return nodesToUnpublish; } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java b/source/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java index ed9e40b5ca..a65d44c106 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -50,7 +50,6 @@ import org.junit.Test; * @author Brian * @author Nick Smith * @since 4.0 - * */ public class PublishingPackageSerializerTest extends AbstractPublishingIntegrationTest { diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java b/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java index 2af4f74b54..c67b372791 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,7 +24,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @since 4.0 */ public interface PublishingQueueFactory { diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java index 7841619ac3..3bdfaf605e 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -34,7 +34,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public class PublishingQueueImpl implements PublishingQueue { @@ -51,7 +51,7 @@ public class PublishingQueueImpl implements PublishingQueue /** * {@inheritDoc} */ - public PublishingDetails createPublishingDetails() + public PublishingDetails createPublishingDetails() { return publishingEventHelper.createPublishingDetails(); } @@ -59,38 +59,38 @@ public class PublishingQueueImpl implements PublishingQueue /** * {@inheritDoc} */ - public StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, String... channelNames) - { - return createStatusUpdate(message, nodeToLinkTo, Arrays.asList(channelNames)); - } + public StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, String... channelNames) + { + return createStatusUpdate(message, nodeToLinkTo, Arrays.asList(channelNames)); + } - /** + /** * {@inheritDoc} */ - public StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, Collection channelNames) - { - return new StatusUpdateImpl(message, nodeToLinkTo, channelNames); - } + public StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, Collection channelNames) + { + return new StatusUpdateImpl(message, nodeToLinkTo, channelNames); + } - /** - * {@inheritDoc} - */ - public List getPublishingEvents(PublishingEventFilter filter) - { - return publishingEventHelper.findPublishingEvents(nodeRef, filter); - } - - /** - * {@inheritDoc} - */ - public PublishingEventFilter createPublishingEventFilter() - { - return new PublishingEventFilterImpl(); - } - - /** + /** * {@inheritDoc} - */ + */ + public List getPublishingEvents(PublishingEventFilter filter) + { + return publishingEventHelper.findPublishingEvents(nodeRef, filter); + } + + /** + * {@inheritDoc} + */ + public PublishingEventFilter createPublishingEventFilter() + { + return new PublishingEventFilterImpl(); + } + + /** + * {@inheritDoc} + */ public String scheduleNewEvent(PublishingDetails publishingDetails) { try @@ -112,5 +112,4 @@ public class PublishingQueueImpl implements PublishingQueue { return nodeRef; } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java index 062122c1ea..a54afdcf6a 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java @@ -33,10 +33,7 @@ import java.util.Map; import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.cmr.publishing.NodeSnapshot; import org.alfresco.service.cmr.publishing.PublishingDetails; import org.alfresco.service.cmr.publishing.PublishingEvent; import org.alfresco.service.cmr.publishing.PublishingPackage; @@ -57,7 +54,6 @@ import org.junit.Test; /** * @author Nick Smith * @since 4.0 - * */ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest { @@ -105,7 +101,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest ArrayList toUnpublish = new ArrayList(1); for (PublishingPackageEntry entry : pckg.getEntries()) { - if(entry.isPublish()) + if (entry.isPublish()) { assertNotNull(entry.getSnapshot()); toPublish.add(entry.getNodeRef()); @@ -241,5 +237,4 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest this.workflowService = serviceRegistry.getWorkflowService(); this.publishingService = (PublishingService) getApplicationContext().getBean("publishingService"); } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingRootObject.java b/source/java/org/alfresco/repo/publishing/PublishingRootObject.java index ce2d080566..4c3eea6bfd 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingRootObject.java +++ b/source/java/org/alfresco/repo/publishing/PublishingRootObject.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -45,9 +45,9 @@ import org.springframework.beans.BeansException; /** * Returns a properly configured Environment. The factory is multi-tenancy enabled, returning the correct Environment object for the current domain. + * * @author Nick Smith * @since 4.0 - * */ public class PublishingRootObject { diff --git a/source/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java b/source/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java index 3a5258b2f9..20b8d9ab1f 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -22,14 +22,13 @@ package org.alfresco.repo.publishing; import javax.annotation.Resource; import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.junit.Test; /** * @author Nick Smith - * + * @since 4.0 */ public class PublishingRootObjectTest extends AbstractPublishingIntegrationTest { @@ -76,5 +75,4 @@ public class PublishingRootObjectTest extends AbstractPublishingIntegrationTest super.onSetUp(); this.rootObject = (PublishingRootObject) getApplicationContext().getBean(PublishingRootObject.NAME); } - } diff --git a/source/java/org/alfresco/repo/publishing/PublishingTestHelper.java b/source/java/org/alfresco/repo/publishing/PublishingTestHelper.java index 1f2aa1a71a..366c8135b7 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingTestHelper.java +++ b/source/java/org/alfresco/repo/publishing/PublishingTestHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -60,7 +60,6 @@ import org.alfresco.util.GUID; /** * @author Nick Smith * @since 4.0 - * */ public class PublishingTestHelper { @@ -123,7 +122,7 @@ public class PublishingTestHelper { siteService.deleteSite(siteId); } - catch(Throwable t) + catch (Throwable t) { //NOOP } @@ -137,7 +136,7 @@ public class PublishingTestHelper { channelService.deleteChannel(channel); } - catch(Throwable t) + catch (Throwable t) { //NOOP } @@ -152,7 +151,7 @@ public class PublishingTestHelper { publishingService.cancelPublishingEvent(event); } - catch(Throwable t) + catch (Throwable t) { //NOOP } @@ -162,7 +161,7 @@ public class PublishingTestHelper public ChannelType mockChannelType(String channelTypeId) { ChannelType channelType = channelService.getChannelType(channelTypeId); - if(channelType != null) + if (channelType != null) { reset(channelType); when(channelType.getId()).thenReturn(channelTypeId); @@ -289,12 +288,12 @@ public class PublishingTestHelper String eventId = transactionHelper.doInTransaction(startWorkflowCallback); int i = 0; - while(i<100) + while (i < 100) { Thread.sleep(200); PublishingEvent event = publishingService.getPublishingEvent(eventId); Status status = event.getStatus(); - if(Status.IN_PROGRESS!=status && Status.SCHEDULED!=status) + if (Status.IN_PROGRESS != status && Status.SCHEDULED != status) { return event; } @@ -302,5 +301,4 @@ public class PublishingTestHelper } throw new IllegalStateException("The publishing event did not complete after 20s!"); } - } diff --git a/source/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.java b/source/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.java index 3ea585bcce..ade77a6553 100644 --- a/source/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.java +++ b/source/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -43,6 +43,7 @@ import org.alfresco.service.cmr.publishing.NodeSnapshot; /** * @author Brian * @author Nick Smith + * @since 4.0 */ public class StandardNodeSnapshotSerializer implements NodeSnapshotSerializer { @@ -67,8 +68,7 @@ public class StandardNodeSnapshotSerializer implements NodeSnapshotSerializer public void serialize(Collection snapshots, OutputStream output) throws Exception { try - { - + { TransferManifestHeader header = new TransferManifestHeader(); header.setCreatedDate(new Date()); header.setNodeCount(snapshots.size()); diff --git a/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java b/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java index 724ce3831e..c104635089 100644 --- a/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java +++ b/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -30,11 +30,9 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Nick Smith * @since 4.0 - * */ public class StatusUpdateImpl implements StatusUpdate { - private final String message; private final NodeRef nodeToLinkTo; private final Set channelNames; @@ -69,5 +67,4 @@ public class StatusUpdateImpl implements StatusUpdate { return nodeToLinkTo; } - } diff --git a/source/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java b/source/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java index 65a04ab109..6e74765cc5 100644 --- a/source/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java +++ b/source/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java @@ -25,7 +25,6 @@ import org.junit.runners.Suite; /** * @author Nick Smith * @since 4.0 - * */ @RunWith(Suite.class) @Suite.SuiteClasses( { ChannelServiceImplTest.class, diff --git a/source/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.java b/source/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.java index 67e43e4e69..b4e73cf14e 100644 --- a/source/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.java +++ b/source/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.java @@ -37,6 +37,10 @@ import org.springframework.social.oauth2.GrantType; import org.springframework.social.oauth2.OAuth2Operations; import org.springframework.social.oauth2.OAuth2Parameters; +/** + * @author Brian + * @since 4.0 + */ public class FacebookChannelType extends AbstractChannelType { public final static String ID = "facebook"; diff --git a/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java b/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java index de798dff4e..a588330867 100644 --- a/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java +++ b/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java @@ -26,6 +26,10 @@ import org.springframework.social.facebook.api.Facebook; import org.springframework.social.facebook.connect.FacebookConnectionFactory; import org.springframework.social.oauth2.AccessGrant; +/** + * @author Brian + * @since 4.0 + */ public class FacebookPublishingHelper { private NodeService nodeService; diff --git a/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java b/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java index b355b6d542..71d3c9e611 100644 --- a/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java +++ b/source/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java @@ -23,7 +23,7 @@ import org.alfresco.service.namespace.QName; /** * @author Brian - * + * @since 4.0 */ public interface FacebookPublishingModel { diff --git a/source/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java b/source/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java index 6407571b19..dad45c74bf 100644 --- a/source/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java +++ b/source/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java @@ -39,6 +39,10 @@ import org.springframework.social.oauth1.OAuth1Parameters; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +/** + * @author Brian + * @since 4.0 + */ public class FlickrChannelType extends AbstractOAuth1ChannelType { public final static String ID = "flickr"; diff --git a/source/java/org/alfresco/repo/rating/RatingSchemeRegistry.java b/source/java/org/alfresco/repo/rating/RatingSchemeRegistry.java index 3437f8b9f8..6e50b90f50 100644 --- a/source/java/org/alfresco/repo/rating/RatingSchemeRegistry.java +++ b/source/java/org/alfresco/repo/rating/RatingSchemeRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/rating/RatingServiceImpl.java b/source/java/org/alfresco/repo/rating/RatingServiceImpl.java index 4c846f6d4a..5b37b8850a 100644 --- a/source/java/org/alfresco/repo/rating/RatingServiceImpl.java +++ b/source/java/org/alfresco/repo/rating/RatingServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -109,7 +109,8 @@ public class RatingServiceImpl implements RatingService throw new RatingServiceException("Users can't rate their own content for scheme " + ratingSchemeName); } - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { public Void doWork() throws Exception { applyRating(targetNode, rating, ratingSchemeName, currentUser); diff --git a/source/java/org/alfresco/repo/rating/RatingServiceIntegrationTest.java b/source/java/org/alfresco/repo/rating/RatingServiceIntegrationTest.java index d5a17a99c6..c75e5d1987 100644 --- a/source/java/org/alfresco/repo/rating/RatingServiceIntegrationTest.java +++ b/source/java/org/alfresco/repo/rating/RatingServiceIntegrationTest.java @@ -37,7 +37,6 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.ScriptLocation; import org.alfresco.service.cmr.repository.ScriptService; import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.util.BaseAlfrescoSpringTest; @@ -156,7 +155,8 @@ public class RatingServiceIntegrationTest extends BaseAlfrescoSpringTest try { ratingService.applyRating(nodeRef, illegalRating, schemeName); - } catch (RatingServiceException expectedException) + } + catch (RatingServiceException expectedException) { return; } @@ -367,7 +367,8 @@ public class RatingServiceIntegrationTest extends BaseAlfrescoSpringTest { // But fiveStar rating scheme disallows rating your own content. ratingService.applyRating(testDoc_UserTwo, 4, FIVE_STAR_SCHEME_NAME); - } catch (RatingServiceException expected) + } + catch (RatingServiceException expected) { return; } diff --git a/source/java/org/alfresco/repo/rating/script/ScriptRatingService.java b/source/java/org/alfresco/repo/rating/script/ScriptRatingService.java index 03967ef833..042f02f5ac 100644 --- a/source/java/org/alfresco/repo/rating/script/ScriptRatingService.java +++ b/source/java/org/alfresco/repo/rating/script/ScriptRatingService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/repo/wiki/WikiServiceImpl.java b/source/java/org/alfresco/repo/wiki/WikiServiceImpl.java index 9b5036f37d..80244e10aa 100644 --- a/source/java/org/alfresco/repo/wiki/WikiServiceImpl.java +++ b/source/java/org/alfresco/repo/wiki/WikiServiceImpl.java @@ -162,10 +162,10 @@ public class WikiServiceImpl implements WikiService // Finally, do the content String contents = preLoadedContents; - if(contents == null) + if (contents == null) { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); - if(reader != null) + if (reader != null) { contents = reader.getContentString(); } @@ -184,14 +184,14 @@ public class WikiServiceImpl implements WikiService public WikiPageInfo getWikiPage(String siteShortName, String pageName) { NodeRef container = getSiteWikiContainer(siteShortName, false); - if(container == null) + if (container == null) { // No links return null; } NodeRef link = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, pageName); - if(link != null) + if (link != null) { return buildPage(link, container, pageName, null); } @@ -236,7 +236,7 @@ public class WikiServiceImpl implements WikiService public WikiPageInfo updateWikiPage(WikiPageInfo page) { // Sanity check what we were given - if(page.getNodeRef() == null) + if (page.getNodeRef() == null) { throw new IllegalArgumentException("Can't update a page that was never persisted, call create instead"); } @@ -246,14 +246,14 @@ public class WikiServiceImpl implements WikiService // Handle the rename case boolean renamed = false; - if(! nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE).equals(page.getTitle())) + if (! nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE).equals(page.getTitle())) { try { fileFolderService.rename(nodeRef, nodeName); renamed = true; } - catch(FileNotFoundException e) + catch (FileNotFoundException e) { throw new AlfrescoRuntimeException("Invalid node state - wiki page no longer found"); } @@ -270,7 +270,7 @@ public class WikiServiceImpl implements WikiService taggingService.setTags(nodeRef, page.getTags()); // If we re-named, re-create the object - if(renamed) + if (renamed) { page = buildPage(nodeRef, page.getContainerNodeRef(), nodeName, page.getContents()); } @@ -282,7 +282,7 @@ public class WikiServiceImpl implements WikiService @Override public void deleteWikiPage(WikiPageInfo page) { - if(page.getNodeRef() == null) + if (page.getNodeRef() == null) { throw new IllegalArgumentException("Can't delete a wiki page that was never persisted"); } @@ -321,14 +321,15 @@ public class WikiServiceImpl implements WikiService Date createdFrom, Date createdTo, Date modifiedFrom, Date modifiedTo, PagingRequest paging) { NodeRef container = getSiteWikiContainer(siteShortName, false); - if(container == null) + if (container == null) { // No events return new EmptyPagingResults(); } // Grab the factory - GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN); + GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = + (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN); // Do the sorting, newest first by created date CannedQuerySortDetails sorting = getChildrenCannedQueryFactory.createDateDescendingCQSortDetails(); @@ -353,7 +354,7 @@ public class WikiServiceImpl implements WikiService { // Pre-load the nodes before we create them List ids = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { ids.add(node.getId()); } @@ -367,11 +368,12 @@ public class WikiServiceImpl implements WikiService { return results.getQueryExecutionId(); } + @Override public List getPage() { List pages = new ArrayList(); - for(NodeBackedEntity node : results.getPage()) + for (NodeBackedEntity node : results.getPage()) { NodeRef nodeRef = node.getNodeRef(); String name = node.getName(); @@ -379,11 +381,13 @@ public class WikiServiceImpl implements WikiService } return pages; } + @Override public boolean hasMoreItems() { return results.hasMoreItems(); } + @Override public Pair getTotalResultCount() { diff --git a/source/java/org/alfresco/repo/wiki/WikiServiceImplTest.java b/source/java/org/alfresco/repo/wiki/WikiServiceImplTest.java index 8f50de759f..d50f4efa1d 100644 --- a/source/java/org/alfresco/repo/wiki/WikiServiceImplTest.java +++ b/source/java/org/alfresco/repo/wiki/WikiServiceImplTest.java @@ -142,8 +142,7 @@ public class WikiServiceImplTest // Create one page = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "Title", "This Is Some Content" - ); + WIKI_SITE.getShortName(), "Title", "This Is Some Content"); // Ensure it got a noderef, and the correct site @@ -184,8 +183,7 @@ public class WikiServiceImplTest // Create a page page = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "Title", "This Is Some Content" - ); + WIKI_SITE.getShortName(), "Title", "This Is Some Content"); testNodesToTidy.add(page.getNodeRef()); @@ -224,8 +222,7 @@ public class WikiServiceImplTest // Create a new node with spaces in title page = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "Title Space", "This Is Some Content" - ); + WIKI_SITE.getShortName(), "Title Space", "This Is Some Content"); testNodesToTidy.add(page.getNodeRef()); // Check it @@ -281,16 +278,14 @@ public class WikiServiceImplTest SITE_SERVICE.deleteSite(TEST_SITE_NAME); } SITE_SERVICE.createSite( - TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC - ); + TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC); // Won't have the container to start with assertFalse(SITE_SERVICE.hasContainer(TEST_SITE_NAME, WikiServiceImpl.WIKI_COMPONENT)); // Create a link WIKI_SERVICE.createWikiPage( - TEST_SITE_NAME, "Title", "TextTextText" - ); + TEST_SITE_NAME, "Title", "TextTextText"); // It will now exist assertTrue(SITE_SERVICE.hasContainer(TEST_SITE_NAME, WikiServiceImpl.WIKI_COMPONENT)); @@ -315,8 +310,7 @@ public class WikiServiceImplTest // Create one without tagging page = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "Title", "This Is Some Content" - ); + WIKI_SITE.getShortName(), "Title", "This Is Some Content"); testNodesToTidy.add(page.getNodeRef()); // Check @@ -402,14 +396,11 @@ public class WikiServiceImplTest // Add a few WikiPageInfo pageA = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "TitleA", "ContentA" - ); + WIKI_SITE.getShortName(), "TitleA", "ContentA"); WikiPageInfo pageB = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "TitleB", "ContentB" - ); + WIKI_SITE.getShortName(), "TitleB", "ContentB"); WikiPageInfo pageC = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "TitleC", "ContentC" - ); + WIKI_SITE.getShortName(), "TitleC", "ContentC"); testNodesToTidy.add(pageA.getNodeRef()); testNodesToTidy.add(pageB.getNodeRef()); testNodesToTidy.add(pageC.getNodeRef()); @@ -424,8 +415,7 @@ public class WikiServiceImplTest // Add one more, as a different user, and drop the page size AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); WikiPageInfo pageD = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "TitleD", "ContentD" - ); + WIKI_SITE.getShortName(), "TitleD", "ContentD"); testNodesToTidy.add(pageD.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER); @@ -531,12 +521,12 @@ public class WikiServiceImplTest paging = new PagingRequest(10); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); results = WIKI_SERVICE.listWikiPages(WIKI_SITE.getShortName(), paging); - for(WikiPageInfo link : results.getPage()) + for (WikiPageInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } results = WIKI_SERVICE.listWikiPages(ALTERNATE_WIKI_SITE.getShortName(), paging); - for(WikiPageInfo link : results.getPage()) + for (WikiPageInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } @@ -570,24 +560,19 @@ public class WikiServiceImplTest // Note - add the events as a different user for the site that the // test user isn't a member of! WikiPageInfo pageA = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "TitleA", "ContentA" - ); + WIKI_SITE.getShortName(), "TitleA", "ContentA"); WikiPageInfo pageB = WIKI_SERVICE.createWikiPage( - WIKI_SITE.getShortName(), "TitleB", "ContentB" - ); + WIKI_SITE.getShortName(), "TitleB", "ContentB"); testNodesToTidy.add(pageA.getNodeRef()); testNodesToTidy.add(pageB.getNodeRef()); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); WikiPageInfo pagePrivA = WIKI_SERVICE.createWikiPage( - ALTERNATE_WIKI_SITE.getShortName(), "PrivTitleA", "Contents A" - ); + ALTERNATE_WIKI_SITE.getShortName(), "PrivTitleA", "Contents A"); WikiPageInfo pagePrivB = WIKI_SERVICE.createWikiPage( - ALTERNATE_WIKI_SITE.getShortName(), "PrivTitleB", "Contents B" - ); + ALTERNATE_WIKI_SITE.getShortName(), "PrivTitleB", "Contents B"); WikiPageInfo pagePrivC = WIKI_SERVICE.createWikiPage( - ALTERNATE_WIKI_SITE.getShortName(), "PrivTitleC", "Contents C" - ); + ALTERNATE_WIKI_SITE.getShortName(), "PrivTitleC", "Contents C"); testNodesToTidy.add(pagePrivA.getNodeRef()); testNodesToTidy.add(pagePrivB.getNodeRef()); testNodesToTidy.add(pagePrivC.getNodeRef()); @@ -653,12 +638,12 @@ public class WikiServiceImplTest paging = new PagingRequest(10); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); results = WIKI_SERVICE.listWikiPages(WIKI_SITE.getShortName(), paging); - for(WikiPageInfo link : results.getPage()) + for (WikiPageInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } results = WIKI_SERVICE.listWikiPages(ALTERNATE_WIKI_SITE.getShortName(), paging); - for(WikiPageInfo link : results.getPage()) + for (WikiPageInfo link : results.getPage()) { PUBLIC_NODE_SERVICE.deleteNode(link.getNodeRef()); } @@ -681,19 +666,24 @@ public class WikiServiceImplTest final Date newModified = new Date(modified.getTime() - modifiedDaysAgo*ONE_DAY_MS); // Update the created date - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { BEHAVIOUR_FILTER.disableBehaviour(ContentModel.ASPECT_AUDITABLE); NODE_SERVICE.setProperty(node, ContentModel.PROP_CREATED, newCreated); NODE_SERVICE.setProperty(node, ContentModel.PROP_MODIFIED, newModified); return null; } }, false, true); + // Change something else too in the public nodeservice, to force a re-index - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { BEHAVIOUR_FILTER.disableBehaviour(ContentModel.ASPECT_AUDITABLE); PUBLIC_NODE_SERVICE.setProperty(node, ContentModel.PROP_CREATED, newCreated); PUBLIC_NODE_SERVICE.setProperty(node, ContentModel.PROP_MODIFIED, newModified); @@ -701,10 +691,13 @@ public class WikiServiceImplTest return null; } }, false, true); + // Check it was taken - TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() { + TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback() + { @Override - public Void execute() throws Throwable { + public Void execute() throws Throwable + { assertEquals(newCreated, NODE_SERVICE.getProperty(node, ContentModel.PROP_CREATED)); assertEquals(newCreated, PUBLIC_NODE_SERVICE.getProperty(node, ContentModel.PROP_CREATED)); assertEquals(newModified, NODE_SERVICE.getProperty(node, ContentModel.PROP_MODIFIED)); @@ -731,8 +724,7 @@ public class WikiServiceImplTest TEST_SITE_PREFIX, WikiServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(), "test site title", "test site description", - SiteVisibility.PUBLIC - ); + SiteVisibility.PUBLIC); privateWikiPageService.getSiteWikiContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; @@ -750,8 +742,7 @@ public class WikiServiceImplTest TEST_SITE_PREFIX, WikiServiceImplTest.class.getSimpleName() + "_testAltSite" + System.currentTimeMillis(), "alternate site title", "alternate site description", - SiteVisibility.PRIVATE - ); + SiteVisibility.PRIVATE); privateWikiPageService.getSiteWikiContainer(site.getShortName(), true); CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef()); return site; diff --git a/source/java/org/alfresco/repo/workflow/AbstractWorkflowNodeConverter.java b/source/java/org/alfresco/repo/workflow/AbstractWorkflowNodeConverter.java index 5e505dd91f..085adbd3ea 100644 --- a/source/java/org/alfresco/repo/workflow/AbstractWorkflowNodeConverter.java +++ b/source/java/org/alfresco/repo/workflow/AbstractWorkflowNodeConverter.java @@ -27,9 +27,8 @@ import java.util.List; import org.alfresco.service.cmr.repository.NodeRef; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public abstract class AbstractWorkflowNodeConverter implements WorkflowNodeConverter { @@ -39,11 +38,11 @@ public abstract class AbstractWorkflowNodeConverter implements WorkflowNodeConve @SuppressWarnings("unchecked") public Object convertNodes(Object value, boolean isMany) { - if(value instanceof NodeRef) + if (value instanceof NodeRef) { return convertNode((NodeRef) value, isMany); } - else if(value instanceof Collection) + else if (value instanceof Collection) { return convertNodes((Collection) value, isMany); } @@ -102,7 +101,7 @@ public abstract class AbstractWorkflowNodeConverter implements WorkflowNodeConve public Serializable convert(Object object) { - if(object instanceof Collection) + if (object instanceof Collection) { return (Serializable) convertToNodes((Collection)object); } @@ -114,5 +113,4 @@ public abstract class AbstractWorkflowNodeConverter implements WorkflowNodeConve public abstract List convertNodes(Collection values); public abstract NodeRef convertToNode(Object toConvert); - } diff --git a/source/java/org/alfresco/repo/workflow/AbstractWorkflowPropertyHandler.java b/source/java/org/alfresco/repo/workflow/AbstractWorkflowPropertyHandler.java index e686870b53..d87befa057 100644 --- a/source/java/org/alfresco/repo/workflow/AbstractWorkflowPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/AbstractWorkflowPropertyHandler.java @@ -34,9 +34,8 @@ import org.alfresco.service.cmr.workflow.WorkflowException; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public abstract class AbstractWorkflowPropertyHandler implements WorkflowPropertyHandler { @@ -53,7 +52,7 @@ public abstract class AbstractWorkflowPropertyHandler implements WorkflowPropert */ protected Object handleAssociation(Serializable value, AssociationDefinition assocDef) { - if(assocDef.isProtected()) + if (assocDef.isProtected()) { return DO_NOT_ADD; } @@ -120,7 +119,7 @@ public abstract class AbstractWorkflowPropertyHandler implements WorkflowPropert public void setRegistry(WorkflowPropertyHandlerRegistry registry) { QName key = getKey(); - if(key!=null) + if (key!=null) { registry.registerHandler(key, this); } @@ -155,14 +154,14 @@ public abstract class AbstractWorkflowPropertyHandler implements WorkflowPropert protected Object handleDefaultProperty(Object task, TypeDefinition type, QName key, Serializable value) { PropertyDefinition propDef = type.getProperties().get(key); - if(propDef!=null) + if (propDef != null) { return handleProperty(value, propDef); } else { AssociationDefinition assocDef = type.getAssociations().get(key); - if(assocDef!=null) + if (assocDef != null) { return handleAssociation(value, assocDef); } diff --git a/source/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java b/source/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java index 1040c27180..d8bbd2d819 100644 --- a/source/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java +++ b/source/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java @@ -60,10 +60,9 @@ import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; /** - * @since 3.4.e * @author Nick Smith * @author Frederik Heremans - * + * @since 3.4.e */ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringTest { @@ -509,7 +508,7 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT public void testGetTimers() { - // Make admin current user + // Make admin current user AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); // Start process that will have a timer @@ -573,7 +572,7 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT public void testQueryTasks() { - // Start adhoc Workflow + // Start adhoc Workflow WorkflowDefinition workflowDef = deployDefinition(getAdhocDefinitionPath()); assertNotNull(workflowDef); @@ -634,24 +633,25 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT assertEquals(5, tasks.size()); } - protected void checkQueryTasksInactiveWorkflow(String workflowInstanceId) { - WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); - taskQuery.setActive(false); - taskQuery.setProcessId(workflowInstanceId); - - List tasks = workflowService.queryTasks(taskQuery); + protected void checkQueryTasksInactiveWorkflow(String workflowInstanceId) + { + WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); + taskQuery.setActive(false); + taskQuery.setProcessId(workflowInstanceId); + + List tasks = workflowService.queryTasks(taskQuery); assertNotNull(tasks); assertEquals(3, tasks.size()); taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); - taskQuery.setActive(true); - taskQuery.setProcessId(workflowInstanceId); - checkNoTasksFoundUsingQuery(taskQuery); - } + taskQuery.setActive(true); + taskQuery.setProcessId(workflowInstanceId); + checkNoTasksFoundUsingQuery(taskQuery); + } - protected void checkTaskQueryTaskCompleted(String workflowInstanceId, WorkflowTask theTask, WorkflowTask startTask) - { - List expectedTasks = Arrays.asList(theTask.getId(), startTask.getId()); + protected void checkTaskQueryTaskCompleted(String workflowInstanceId, WorkflowTask theTask, WorkflowTask startTask) + { + List expectedTasks = Arrays.asList(theTask.getId(), startTask.getId()); checkProcessIdQuery(workflowInstanceId, expectedTasks, WorkflowTaskState.COMPLETED); // Adhoc task should only be returned @@ -666,12 +666,12 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT // Both tasks have custom property set checkTaskPropsQuery(expectedTasks, WorkflowTaskState.COMPLETED, null); - } + } - protected void checkTaskQueryInProgress(String workflowInstanceId, WorkflowTask expectedTask, String workflowInstanceId2) + protected void checkTaskQueryInProgress(String workflowInstanceId, WorkflowTask expectedTask, String workflowInstanceId2) { - List expectedTasks = Arrays.asList(expectedTask.getId()); - + List expectedTasks = Arrays.asList(expectedTask.getId()); + checkProcessIdQuery(workflowInstanceId, expectedTasks, WorkflowTaskState.IN_PROGRESS); checkTaskIdQuery(expectedTask.getId(), WorkflowTaskState.IN_PROGRESS); @@ -682,23 +682,24 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT checkTaskPropsQuery(expectedTasks, WorkflowTaskState.IN_PROGRESS, null); checkProcessPropsQuery(expectedTasks, WorkflowTaskState.IN_PROGRESS); } - - protected void checkTaskQueryStartTaskCompleted(String workflowInstanceId, WorkflowTask startTask) { - List expectedTasks = Arrays.asList(startTask.getId()); - - checkProcessIdQuery(workflowInstanceId, expectedTasks, WorkflowTaskState.COMPLETED); - checkTaskIdQuery(startTask.getId(), WorkflowTaskState.COMPLETED); - - QName startTaskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "submitAdhocTask"); - checkTaskNameQuery(startTaskName, expectedTasks, WorkflowTaskState.COMPLETED, null); - checkActorIdQuery(USER1, expectedTasks, WorkflowTaskState.COMPLETED, null); - checkIsActiveQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); - checkTaskPropsQuery(expectedTasks, WorkflowTaskState.COMPLETED, null); - } - - public void testGetWorkflows() throws Exception + + protected void checkTaskQueryStartTaskCompleted(String workflowInstanceId, WorkflowTask startTask) { - String fakeDefId = getEngine() + "$9999999999999"; + List expectedTasks = Arrays.asList(startTask.getId()); + + checkProcessIdQuery(workflowInstanceId, expectedTasks, WorkflowTaskState.COMPLETED); + checkTaskIdQuery(startTask.getId(), WorkflowTaskState.COMPLETED); + + QName startTaskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "submitAdhocTask"); + checkTaskNameQuery(startTaskName, expectedTasks, WorkflowTaskState.COMPLETED, null); + checkActorIdQuery(USER1, expectedTasks, WorkflowTaskState.COMPLETED, null); + checkIsActiveQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); + checkTaskPropsQuery(expectedTasks, WorkflowTaskState.COMPLETED, null); + } + + public void testGetWorkflows() throws Exception + { + String fakeDefId = getEngine() + "$9999999999999"; List workflows = workflowService.getActiveWorkflows(fakeDefId); assertTrue(workflows.isEmpty()); workflows = workflowService.getCompletedWorkflows(fakeDefId); @@ -777,19 +778,19 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT checkCompletedWorkflows(defId, instance1, instance2); checkWorkflows(defId, instance1, instance2); } - - - public void testDeleteWorkflow() throws Exception + + public void testDeleteWorkflow() throws Exception { //TODO Implement this test! } - public void checkWorkflows(String defId, String... expectedIds) - { - List workflows = workflowService.getWorkflows(defId); - checkWorkflows(workflows, expectedIds); - } - - public void testParallelReview() throws Exception + + public void checkWorkflows(String defId, String... expectedIds) + { + List workflows = workflowService.getWorkflows(defId); + checkWorkflows(workflows, expectedIds); + } + + public void testParallelReview() throws Exception { // start pooled review and approve workflow WorkflowDefinition workflowDef = deployDefinition(getParallelReviewDefinitionPath()); @@ -825,51 +826,52 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT tasks = workflowService.getAssignedTasks(USER3, WorkflowTaskState.IN_PROGRESS); assertEquals(1, tasks.size()); } - - public void checkCompletedWorkflows(String defId, String... expectedIds) - { - List workflows = workflowService.getCompletedWorkflows(defId); - checkWorkflows(workflows, expectedIds); - } - - private void checkActiveWorkflows(String defId, String... expectedIds) - { - List workflows = workflowService.getActiveWorkflows(defId); - checkWorkflows(workflows, expectedIds); - } + + public void checkCompletedWorkflows(String defId, String... expectedIds) + { + List workflows = workflowService.getCompletedWorkflows(defId); + checkWorkflows(workflows, expectedIds); + } + + private void checkActiveWorkflows(String defId, String... expectedIds) + { + List workflows = workflowService.getActiveWorkflows(defId); + checkWorkflows(workflows, expectedIds); + } private void checkWorkflows(List workflows, String... expectedIds) { assertEquals(expectedIds.length, workflows.size()); - List expIds = Arrays.asList(expectedIds); - for (WorkflowInstance workflow : workflows) + List expIds = Arrays.asList(expectedIds); + for (WorkflowInstance workflow : workflows) { String workflowId = workflow.getId(); assertTrue("The id: "+workflowId +" was not expected! Expected Ids: "+expIds, expIds.contains(workflowId)); } } - + protected void checkTaskNameQuery(QName taskName, List expectedTaskIds, WorkflowTaskState state, - String optionalProcessId) { + String optionalProcessId) + { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); taskQuery.setTaskName(taskName); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkTasksFoundUsingQuery(expectedTaskIds, taskQuery); QName unexistingTaskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "unexistingTask"); taskQuery = createWorkflowTaskQuery(state); taskQuery.setTaskName(unexistingTaskName); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkNoTasksFoundUsingQuery(taskQuery); - } + } - protected void checkProcessIdQuery(String workflowInstanceId, List expectedTaskIds, WorkflowTaskState state) + protected void checkProcessIdQuery(String workflowInstanceId, List expectedTaskIds, WorkflowTaskState state) { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); taskQuery.setProcessId(workflowInstanceId); @@ -895,9 +897,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); taskQuery.setActive(true); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkTasksFoundUsingQuery(expectedTaskIds, taskQuery); @@ -905,33 +907,33 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT taskQuery.setActive(false); if(optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkNoTasksFoundUsingQuery(taskQuery); } protected void checkActorIdQuery(String actorId, List expectedTaskIds, WorkflowTaskState state, - String optionalProcessId) + String optionalProcessId) { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); taskQuery.setActorId(actorId); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkTasksFoundUsingQuery(expectedTaskIds, taskQuery); taskQuery = createWorkflowTaskQuery(state); taskQuery.setActorId(USER3); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkNoTasksFoundUsingQuery(taskQuery); } protected void checkTaskPropsQuery(List expectedTaskIds, WorkflowTaskState state, - String optionalProcessId) + String optionalProcessId) { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); Map taskProps = new HashMap(); @@ -939,9 +941,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT taskProps.put(customStringProp, "stringValue"); taskQuery.setTaskCustomProps(taskProps); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkTasksFoundUsingQuery(expectedTaskIds, taskQuery); @@ -950,9 +952,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT taskQuery = createWorkflowTaskQuery(state); taskQuery.setTaskCustomProps(taskProps); - if(optionalProcessId != null) + if (optionalProcessId != null) { - taskQuery.setProcessId(optionalProcessId); + taskQuery.setProcessId(optionalProcessId); } checkNoTasksFoundUsingQuery(taskQuery); } @@ -997,39 +999,38 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT protected WorkflowTaskQuery createWorkflowTaskQuery(WorkflowTaskState state) { - WorkflowTaskQuery taskQuery = new WorkflowTaskQuery(); - taskQuery.setTaskState(state); - return taskQuery; + WorkflowTaskQuery taskQuery = new WorkflowTaskQuery(); + taskQuery.setTaskState(state); + return taskQuery; } protected void checkTasksFoundUsingQuery(List taskIds, WorkflowTaskQuery workflowTaskQuery) { - List tasks = workflowService.queryTasks(workflowTaskQuery); - assertNotNull(tasks); - assertEquals(taskIds.size(), tasks.size()); - for(WorkflowTask task : tasks) - { - assertTrue(taskIds.contains(task.getId())); - } + List tasks = workflowService.queryTasks(workflowTaskQuery); + assertNotNull(tasks); + assertEquals(taskIds.size(), tasks.size()); + for (WorkflowTask task : tasks) + { + assertTrue(taskIds.contains(task.getId())); + } } protected void checkNoTasksFoundUsingQuery(WorkflowTaskQuery workflowTaskQuery) { - List tasks = workflowService.queryTasks(workflowTaskQuery); - assertNotNull(tasks); - assertEquals(0, tasks.size()); + List tasks = workflowService.queryTasks(workflowTaskQuery); + assertNotNull(tasks); + assertEquals(0, tasks.size()); } - protected WorkflowTask getNextTaskForWorkflow(String workflowInstanceId) { - WorkflowTaskQuery taskQuery = new WorkflowTaskQuery(); - taskQuery.setProcessId(workflowInstanceId); - taskQuery.setTaskState(WorkflowTaskState.IN_PROGRESS); + WorkflowTaskQuery taskQuery = new WorkflowTaskQuery(); + taskQuery.setProcessId(workflowInstanceId); + taskQuery.setTaskState(WorkflowTaskState.IN_PROGRESS); - List workflowTasks = workflowService.queryTasks(taskQuery); - assertEquals(1, workflowTasks.size()); - return workflowTasks.get(0); + List workflowTasks = workflowService.queryTasks(taskQuery); + assertEquals(1, workflowTasks.size()); + return workflowTasks.get(0); } protected WorkflowDefinition deployDefinition(String resource) @@ -1055,9 +1056,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT String id = expDefinition.getId(); for (WorkflowDefinition definition : definitions) { - if(expContainsDef) + if (expContainsDef) { - if(definition.getId().equals(id)) + if (definition.getId().equals(id)) { checkDefinition(expDefinition, definition); return; @@ -1066,13 +1067,14 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT } else { - if(definition.getId().equals(id)) + if (definition.getId().equals(id)) { fail("The definitions unexpectedly contain id: "+id); } } } - if(expContainsDef) + + if (expContainsDef) fail("The definitions did not contain expected id: "+id); } diff --git a/source/java/org/alfresco/repo/workflow/AlfrescoBpmEngine.java b/source/java/org/alfresco/repo/workflow/AlfrescoBpmEngine.java index 7d54387013..99821c2d17 100644 --- a/source/java/org/alfresco/repo/workflow/AlfrescoBpmEngine.java +++ b/source/java/org/alfresco/repo/workflow/AlfrescoBpmEngine.java @@ -26,9 +26,8 @@ import org.alfresco.service.cmr.workflow.WorkflowException; import org.alfresco.service.namespace.NamespaceService; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public abstract class AlfrescoBpmEngine extends BPMEngine { diff --git a/source/java/org/alfresco/repo/workflow/DefaultWorkflowPropertyHandler.java b/source/java/org/alfresco/repo/workflow/DefaultWorkflowPropertyHandler.java index 0a5702d979..d3aabd2c50 100644 --- a/source/java/org/alfresco/repo/workflow/DefaultWorkflowPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/DefaultWorkflowPropertyHandler.java @@ -25,9 +25,8 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class DefaultWorkflowPropertyHandler extends AbstractWorkflowPropertyHandler { @@ -48,5 +47,4 @@ public class DefaultWorkflowPropertyHandler extends AbstractWorkflowPropertyHand // Does not have a key! return null; } - } diff --git a/source/java/org/alfresco/repo/workflow/NodeConverter.java b/source/java/org/alfresco/repo/workflow/NodeConverter.java index b6e3d63f15..f85d52a4af 100644 --- a/source/java/org/alfresco/repo/workflow/NodeConverter.java +++ b/source/java/org/alfresco/repo/workflow/NodeConverter.java @@ -25,9 +25,8 @@ import java.util.List; import org.alfresco.service.cmr.repository.NodeRef; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public interface NodeConverter { diff --git a/source/java/org/alfresco/repo/workflow/PackageManager.java b/source/java/org/alfresco/repo/workflow/PackageManager.java index 0e1ab87619..077be7478c 100644 --- a/source/java/org/alfresco/repo/workflow/PackageManager.java +++ b/source/java/org/alfresco/repo/workflow/PackageManager.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -49,9 +49,8 @@ import org.apache.commons.logging.LogFactory; * (such as adding and removing package items). These changes are then applied * to the package when either the create() or update() method is called. * - * @since 3.4 * @author Nick Smith - * + * @since 3.4 */ public class PackageManager { @@ -173,30 +172,27 @@ public class PackageManager */ public void update(final NodeRef packageRef) { - if(addItems.isEmpty() && removeItems.isEmpty()) + if (addItems.isEmpty() && removeItems.isEmpty()) return; AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - checkPackage(packageRef); - checkPackageItems(packageRef); - addPackageItems(packageRef); - removePackageItems(packageRef); - return null; - } - - }, AuthenticationUtil.getSystemUserName()); - addItems.clear(); - removeItems.clear(); + { + public Void doWork() throws Exception + { + checkPackage(packageRef); + checkPackageItems(packageRef); + addPackageItems(packageRef); + removePackageItems(packageRef); + return null; + } + }, AuthenticationUtil.getSystemUserName()); + addItems.clear(); + removeItems.clear(); } - private void checkPackage(NodeRef packageRef) { - if(packageRef == null - || nodeService.hasAspect(packageRef, PCKG_ASPECT)==false ) + if (packageRef == null || nodeService.hasAspect(packageRef, PCKG_ASPECT) == false) { String msg = "The package NodeRef must implement the aspect: " + PCKG_ASPECT; throw new WorkflowException(msg); @@ -256,7 +252,7 @@ public class PackageManager removeItems.removeAll(intersection); for (NodeRef node : intersection) { - if(logger.isDebugEnabled()) + if (logger.isDebugEnabled()) logger.debug("Item was added and removed from package! Ignoring item: "+ node); } checkAddedItems(currentitems); @@ -268,7 +264,7 @@ public class PackageManager for (Iterator iter = removeItems.iterator(); iter.hasNext();) { NodeRef removeItem= iter.next(); - if(currentitems.contains(removeItem)==false) + if (currentitems.contains(removeItem) == false) { iter.remove(); if (logger.isDebugEnabled()) @@ -282,7 +278,7 @@ public class PackageManager for (Iterator iter = addItems.iterator(); iter.hasNext();) { NodeRef addItem= iter.next(); - if(currentitems.contains(addItem)) + if (currentitems.contains(addItem)) { iter.remove(); if (logger.isDebugEnabled()) diff --git a/source/java/org/alfresco/repo/workflow/StartWorkflowActionExecuter.java b/source/java/org/alfresco/repo/workflow/StartWorkflowActionExecuter.java index 6767562cab..23ee8883a3 100644 --- a/source/java/org/alfresco/repo/workflow/StartWorkflowActionExecuter.java +++ b/source/java/org/alfresco/repo/workflow/StartWorkflowActionExecuter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -45,12 +45,12 @@ import org.alfresco.service.namespace.QName; */ public class StartWorkflowActionExecuter extends ActionExecuterAbstractBase { - public static final String NAME = "start-workflow"; - public static final String PARAM_WORKFLOW_NAME = "workflowName"; + public static final String NAME = "start-workflow"; + public static final String PARAM_WORKFLOW_NAME = "workflowName"; public static final String PARAM_END_START_TASK = "endStartTask"; public static final String PARAM_START_TASK_TRANSITION = "startTaskTransition"; - // action dependencies + // action dependencies private NamespaceService namespaceService; private WorkflowService workflowService; private NodeService nodeService; @@ -75,15 +75,15 @@ public class StartWorkflowActionExecuter extends ActionExecuterAbstractBase /** * @param workflowService */ - public void setWorkflowService(WorkflowService workflowService) - { - this.workflowService = workflowService; - } + public void setWorkflowService(WorkflowService workflowService) + { + this.workflowService = workflowService; + } - /* (non-Javadoc) + /* (non-Javadoc) * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getAdhocPropertiesAllowed() - */ + */ @Override protected boolean getAdhocPropertiesAllowed() { @@ -94,21 +94,21 @@ public class StartWorkflowActionExecuter extends ActionExecuterAbstractBase /* (non-Javadoc) * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_WORKFLOW_NAME, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_WORKFLOW_NAME))); + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_WORKFLOW_NAME, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_WORKFLOW_NAME))); paramList.add(new ParameterDefinitionImpl(PARAM_END_START_TASK, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_END_START_TASK))); paramList.add(new ParameterDefinitionImpl(PARAM_START_TASK_TRANSITION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_START_TASK_TRANSITION))); // TODO: start task node parameter - } + } /* (non-Javadoc) * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @Override - protected void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) + protected void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) { // retrieve workflow definition String workflowName = (String)ruleAction.getParameterValue(PARAM_WORKFLOW_NAME); @@ -158,5 +158,5 @@ public class StartWorkflowActionExecuter extends ActionExecuterAbstractBase workflowService.endTask(task.getId(), startTaskTransition); } } - } + } } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowAuthorityManager.java b/source/java/org/alfresco/repo/workflow/WorkflowAuthorityManager.java index 58b57b18cd..a125454df7 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowAuthorityManager.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowAuthorityManager.java @@ -24,15 +24,13 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AuthorityType; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class WorkflowAuthorityManager { private final AuthorityDAO authorityDAO; - public WorkflowAuthorityManager(AuthorityDAO authorityDAO) { this.authorityDAO = authorityDAO; @@ -78,5 +76,4 @@ public class WorkflowAuthorityManager { return authorityDAO.getAuthorityName(authorityRef); } - } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java b/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java index 2a77ad65b0..5d88b6f10f 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -40,8 +40,8 @@ import org.alfresco.service.namespace.QName; * accumulates the various parameters and package items used to start the * workflow. The workflow is started when the build() method is called. * - * @since 3.4 * @author Nick Smith + * @since 3.4 */ public class WorkflowBuilder { @@ -110,5 +110,4 @@ public class WorkflowBuilder throw new WorkflowException("Start task not found! Expected 1 task but found: " + tasks.size()); } } - } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowDefinitionType.java b/source/java/org/alfresco/repo/workflow/WorkflowDefinitionType.java index aaae2e3f8b..752528c0c8 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowDefinitionType.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowDefinitionType.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -95,7 +95,7 @@ public class WorkflowDefinitionType implements ContentServicePolicies.OnContentU */ public void onContentUpdate(NodeRef nodeRef, boolean newContent) { - workflowDeployer.deploy(nodeRef, true); + workflowDeployer.deploy(nodeRef, true); } /** @@ -118,23 +118,23 @@ public class WorkflowDefinitionType implements ContentServicePolicies.OnContentU { if (afterValue.booleanValue() == true) { - workflowDeployer.deploy(nodeRef, true); + workflowDeployer.deploy(nodeRef, true); } else { - workflowDeployer.undeploy(nodeRef); + workflowDeployer.undeploy(nodeRef); } } else if (afterValue == null && beforeValue != null) { // Undeploy the definition since the value has been cleared - workflowDeployer.undeploy(nodeRef); + workflowDeployer.undeploy(nodeRef); } } public void beforeDeleteNode(NodeRef nodeRef) { - workflowDeployer.undeploy(nodeRef); + workflowDeployer.undeploy(nodeRef); } } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowEngine.java b/source/java/org/alfresco/repo/workflow/WorkflowEngine.java index 455f37b554..d4dbd94496 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowEngine.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowEngine.java @@ -20,9 +20,8 @@ package org.alfresco.repo.workflow; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public interface WorkflowEngine extends WorkflowComponent, TaskComponent { diff --git a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java index 375e0310ef..3a970ae7b0 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -161,7 +161,7 @@ public class WorkflowInterpreter extends BaseInterpreter */ public void setAVMService(AVMService avmService) { - this.avmService = avmService; + this.avmService = avmService; } /** @@ -169,7 +169,7 @@ public class WorkflowInterpreter extends BaseInterpreter */ public void setAVMSyncService(AVMSyncService avmSyncService) { - this.avmSyncService = avmSyncService; + this.avmSyncService = avmSyncService; } /** @@ -1186,43 +1186,43 @@ public class WorkflowInterpreter extends BaseInterpreter } else if (command[2].equals("avmpackage")) { - // lookup source folder of changes - AVMNodeDescriptor avmSource = avmService.lookup(-1, command[3]); - if (avmSource == null || !avmSource.isDirectory()) - { - return command[3] + " must refer to a directory."; - } - - // create container for avm workflow packages - String packagesPath = "workflow-system:/packages"; - AVMNodeDescriptor packagesDesc = avmService.lookup(-1, packagesPath); - if (packagesDesc == null) - { - avmService.createStore("workflow-system"); - avmService.createDirectory("workflow-system:/", "packages"); - } - - // create package (layered to target, if target is specified) - String packageName = GUID.generate(); - String avmSourceIndirection = avmSource.getIndirection(); - if (avmSourceIndirection != null) - { - avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName); - List diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName, null); + // lookup source folder of changes + AVMNodeDescriptor avmSource = avmService.lookup(-1, command[3]); + if (avmSource == null || !avmSource.isDirectory()) + { + return command[3] + " must refer to a directory."; + } + + // create container for avm workflow packages + String packagesPath = "workflow-system:/packages"; + AVMNodeDescriptor packagesDesc = avmService.lookup(-1, packagesPath); + if (packagesDesc == null) + { + avmService.createStore("workflow-system"); + avmService.createDirectory("workflow-system:/", "packages"); + } + + // create package (layered to target, if target is specified) + String packageName = GUID.generate(); + String avmSourceIndirection = avmSource.getIndirection(); + if (avmSourceIndirection != null) + { + avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName); + List diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName, null); avmSyncService.update(diff, null, true, true, false, false, null, null); - } - else - { - // copy source folder to package folder - avmService.copy(-1, avmSource.getPath(), packagesPath, packageName); - } - - // convert package to workflow package - AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath + "/" + packageName); - NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); - nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); + } + else + { + // copy source folder to package folder + avmService.copy(-1, avmSource.getPath(), packagesPath, packageName); + } + + // convert package to workflow package + AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath + "/" + packageName); + NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); + nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); QName qname = QName.createQName(command[1], namespaceService); - vars.put(qname, packageNodeRef); + vars.put(qname, packageNodeRef); out.println("set var " + qname + " = " + vars.get(qname)); } else if (command[2].equals("package")) diff --git a/source/java/org/alfresco/repo/workflow/WorkflowNodeConverter.java b/source/java/org/alfresco/repo/workflow/WorkflowNodeConverter.java index 6a9125ffa6..67a520a47a 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowNodeConverter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowNodeConverter.java @@ -26,8 +26,8 @@ import java.util.List; import org.alfresco.service.cmr.repository.NodeRef; /** - * @since 3.4.e * @author Nick Smith + * @since 3.4.e */ public interface WorkflowNodeConverter { @@ -105,5 +105,4 @@ public interface WorkflowNodeConverter * @return */ Serializable convert(Object object); - } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowNotificationUtils.java b/source/java/org/alfresco/repo/workflow/WorkflowNotificationUtils.java index 25b96a4bbf..80403238cd 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowNotificationUtils.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowNotificationUtils.java @@ -38,6 +38,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * Utility class containing methods to help when sending workflow notifications. * * @author Roy Wetherall + * @since 4.0 */ public abstract class WorkflowNotificationUtils { diff --git a/source/java/org/alfresco/repo/workflow/WorkflowObjectFactory.java b/source/java/org/alfresco/repo/workflow/WorkflowObjectFactory.java index b19b57b174..772e81ce17 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowObjectFactory.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowObjectFactory.java @@ -43,9 +43,8 @@ import org.alfresco.service.cmr.workflow.WorkflowTransition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class WorkflowObjectFactory { @@ -159,7 +158,7 @@ public class WorkflowObjectFactory workflowInstance.priority = (Integer) getVariable(variables, WorkflowModel.PROP_WORKFLOW_PRIORITY); Date dueDate = (Date) getVariable(variables, WorkflowModel.PROP_WORKFLOW_DUE_DATE); - if(dueDate != null) + if (dueDate != null) { workflowInstance.dueDate = dueDate; } @@ -191,7 +190,7 @@ public class WorkflowObjectFactory public WorkflowTaskDefinition createTaskDefinition(String id, WorkflowNode node, String typeName, boolean isStart) { TypeDefinition metaData = getTaskTypeDefinition(typeName, isStart); - if(id == null) + if (id == null) { id = qNameConverter.mapQNameToName(metaData.getName()); } @@ -218,7 +217,7 @@ public class WorkflowObjectFactory } public WorkflowTimer createWorkflowTimer(String id, String name, String error, - Date dueDate, WorkflowPath workflowPath, WorkflowTask workflowTask) + Date dueDate, WorkflowPath workflowPath, WorkflowTask workflowTask) { String actualId = buildGlobalId(id); return new WorkflowTimer(actualId, name, workflowPath, workflowTask, dueDate, error); @@ -261,7 +260,7 @@ public class WorkflowObjectFactory String key = keyBase+ "." + labelKey; String label = messageService.getMessage(key); int i = 0; - while(label==null && i variables, QName qName) { Object obj = getVariable(variables, qName); - if (obj==null) + if (obj == null) { return null; } - if(obj instanceof ScriptNode) + if (obj instanceof ScriptNode) { ScriptNode scriptNode = (ScriptNode) obj; return scriptNode.getNodeRef(); @@ -287,7 +286,7 @@ public class WorkflowObjectFactory private Object getVariable(Map variables, QName qName) { - if(variables == null || qName == null) + if (variables == null || qName == null) return null; String varName = qNameConverter.mapQNameToName(qName); return variables.get(varName); @@ -295,7 +294,7 @@ public class WorkflowObjectFactory private Object getVariable(Map variables, String key) { - if(variables == null || key == null) + if (variables == null || key == null) return null; return variables.get(key); } @@ -343,7 +342,7 @@ public class WorkflowObjectFactory public TypeDefinition getTaskTypeDefinition(String name, boolean isStart) { TypeDefinition typeDef = null; - if(name!=null) + if (name!=null) { QName typeName = qNameConverter.mapNameToQName(name); typeDef = dictionaryService.getType(typeName); @@ -361,7 +360,7 @@ public class WorkflowObjectFactory return typeDef; } - /** + /** * Map QName to jBPM variable name * * @param name QName diff --git a/source/java/org/alfresco/repo/workflow/WorkflowPropertyConverter.java b/source/java/org/alfresco/repo/workflow/WorkflowPropertyConverter.java index c1486e6115..7956f2afa1 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowPropertyConverter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowPropertyConverter.java @@ -35,9 +35,8 @@ import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class WorkflowPropertyConverter { @@ -152,7 +151,7 @@ public class WorkflowPropertyConverter @SuppressWarnings("unchecked") private Object convertNodeRefs(boolean isMany, Object value) { - if(value instanceof NodeRef) + if (value instanceof NodeRef) { NodeRef node = (NodeRef) value; if (isMany) @@ -167,7 +166,7 @@ public class WorkflowPropertyConverter if (value instanceof Collection) { Collection nodes = (Collection) value; - if(isMany) + if (isMany) { converter.convertNodes(nodes); } @@ -179,5 +178,4 @@ public class WorkflowPropertyConverter } return value; } - } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandler.java b/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandler.java index 228165e5c9..51a1838326 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandler.java @@ -25,9 +25,8 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public interface WorkflowPropertyHandler { diff --git a/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandlerRegistry.java b/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandlerRegistry.java index c71ae7f2ca..9f2bb5cd8b 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandlerRegistry.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowPropertyHandlerRegistry.java @@ -28,9 +28,8 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class WorkflowPropertyHandlerRegistry { @@ -69,12 +68,12 @@ public class WorkflowPropertyHandlerRegistry QName key = entry.getKey(); Serializable value = entry.getValue(); WorkflowPropertyHandler handler = handlers.get(key); - if(handler == null) + if (handler == null) { handler = defaultHandler; } Object result = handler.handleProperty(key, value, type, object, objectType); - if(WorkflowPropertyHandler.DO_NOT_ADD.equals(result)==false) + if (WorkflowPropertyHandler.DO_NOT_ADD.equals(result)==false) { String keyStr = qNameConverter.mapQNameToName(key); variablesToSet.put(keyStr, result); @@ -82,5 +81,4 @@ public class WorkflowPropertyHandlerRegistry } return variablesToSet; } - } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowQNameConverter.java b/source/java/org/alfresco/repo/workflow/WorkflowQNameConverter.java index 47cabeaf3e..4c00570882 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowQNameConverter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowQNameConverter.java @@ -25,9 +25,8 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QNameCache; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class WorkflowQNameConverter { @@ -49,7 +48,7 @@ public class WorkflowQNameConverter public String mapQNameToName(QName qName) { String name = cache.getName(qName); - if(name == null) + if (name == null) { name = convertQNameToName(qName); cache.putQNameToName(qName, name); @@ -83,14 +82,14 @@ public class WorkflowQNameConverter private QName convertNameToQName(String name) { - if(name.indexOf(QName.NAMESPACE_BEGIN)==0) + if (name.indexOf(QName.NAMESPACE_BEGIN)==0) { return QName.createQName(name); } String qName = name; - if(name.indexOf(QName.NAMESPACE_PREFIX)==-1) + if (name.indexOf(QName.NAMESPACE_PREFIX)==-1) { - if(name.indexOf('_')==-1) + if (name.indexOf('_')==-1) { return QName.createQName(NamespaceService.DEFAULT_URI, name); } @@ -112,5 +111,4 @@ public class WorkflowQNameConverter // Return prefixed QName string. return nameStr.replace(':', '_'); } - } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowTestSuite.java b/source/java/org/alfresco/repo/workflow/WorkflowTestSuite.java index 3de09f08a3..8037125af3 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowTestSuite.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -76,24 +76,26 @@ public class WorkflowTestSuite extends TestSuite return suite; } - public static class WorkflowSuiteContextShutdownTest extends TestCase { - public void testDummy() { /*Do Nothing */ } + public static class WorkflowSuiteContextShutdownTest extends TestCase + { + public void testDummy() { /*Do Nothing */ } - @Override - protected void tearDown() throws Exception { - System.err.println("Workflow test suite has completed, shutting down the ApplicationContext..."); - ApplicationContextHelper.closeApplicationContext(); + @Override + protected void tearDown() throws Exception + { + System.err.println("Workflow test suite has completed, shutting down the ApplicationContext..."); + ApplicationContextHelper.closeApplicationContext(); - // Null out the static Workflow engine field - Field engineField = WorkflowTaskInstance.class.getDeclaredField("jbpmEngine"); - engineField.setAccessible(true); - engineField.set(null, null); - - Thread.yield(); - Thread.sleep(25); - Thread.yield(); - - System.err.println("Workflow test suite shutdown has finished"); - } + // Null out the static Workflow engine field + Field engineField = WorkflowTaskInstance.class.getDeclaredField("jbpmEngine"); + engineField.setAccessible(true); + engineField.set(null, null); + + Thread.yield(); + Thread.sleep(25); + Thread.yield(); + + System.err.println("Workflow test suite shutdown has finished"); + } } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java b/source/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java index 9674cf9be7..aaa52b4b3b 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java @@ -78,10 +78,9 @@ import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; /** - * @since 3.4.e * @author Nick Smith * @author Frederik Heremans - * + * @since 3.4.e */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:test-database-context.xml", diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiConstants.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiConstants.java index 30d462a4a3..b9d42abdf4 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiConstants.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiConstants.java @@ -20,9 +20,8 @@ package org.alfresco.repo.workflow.activiti; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public interface ActivitiConstants { @@ -33,19 +32,17 @@ public interface ActivitiConstants public static final String PROP_START_TASK_END_DATE = "_startTaskCompleted"; public static final String START_TASK_PREFIX = "start"; - + public static final String DEFAULT_TRANSITION_NAME = "Next"; public static final String START_TASK_PROPERTY_PREFIX = "_start_"; - + public static final String USER_TASK_NODE_TYPE = "userTask"; public static final String PROP_TASK_FORM_KEY = "taskFormKey"; public static final String PROP_POOLED_ACTORS_HISTORY = "pooledActorsHistory"; - public static final String DELETE_REASON_DELETED = "deleted"; - public static final String DELETE_REASON_CANCELLED = "cancelled"; - - public static final String SERVICE_REGISTRY_BEAN_KEY = "services"; - - public static final String PROCESS_INSTANCE_IMAGE_FORMAT = "png"; - - + public static final String DELETE_REASON_DELETED = "deleted"; + public static final String DELETE_REASON_CANCELLED = "cancelled"; + + public static final String SERVICE_REGISTRY_BEAN_KEY = "services"; + + public static final String PROCESS_INSTANCE_IMAGE_FORMAT = "png"; } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java index 5a321fed47..5c0a115c2d 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java @@ -30,6 +30,7 @@ import org.springframework.context.ApplicationListener; * job executor. * * @author Frederik Heremans + * @since 4.0 */ public class ActivitiEngineInitializer implements ApplicationListener { diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiNodeConverter.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiNodeConverter.java index f557de519e..7f9e4acadf 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiNodeConverter.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiNodeConverter.java @@ -78,15 +78,15 @@ public class ActivitiNodeConverter extends AbstractWorkflowNodeConverter @Override public boolean isSupported(Object object) { - if(object == null) + if (object == null) { return false; } - if(object instanceof ActivitiScriptNode) + if (object instanceof ActivitiScriptNode) { return true; } - if(object instanceof ActivitiScriptNodeList) + if (object instanceof ActivitiScriptNodeList) { return true; } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiScriptNodeList.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiScriptNodeList.java index 5a8056f138..a6b70c07fa 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiScriptNodeList.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiScriptNodeList.java @@ -38,7 +38,7 @@ public class ActivitiScriptNodeList extends ArrayList { // Extract all node references List nodeRefs = new ArrayList(); - for(ActivitiScriptNode scriptNode : this) + for (ActivitiScriptNode scriptNode : this) { nodeRefs.add(scriptNode.getNodeRef()); } @@ -46,7 +46,8 @@ public class ActivitiScriptNodeList extends ArrayList } @Override - public int size() { - return super.size(); + public int size() + { + return super.size(); } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java index 2db1a86839..937a1027ec 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java @@ -32,9 +32,8 @@ import org.activiti.engine.runtime.ProcessInstance; import org.springframework.core.io.ClassPathResource; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiSmokeTest extends TestCase { diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java index 988cb6b91e..148c5ef2a2 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java @@ -46,9 +46,8 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiSpringTest extends TestCase { @@ -104,7 +103,7 @@ public class ActivitiSpringTest extends TestCase }; String id = txnHelper.doInTransaction(callback); ProcessInstance instance = findProcessInstance(id); - if(instance!=null) + if (instance != null) { runtime.deleteProcessInstance(id, "For test"); fail("The process instance creation should have been rolled back!"); @@ -248,7 +247,8 @@ public class ActivitiSpringTest extends TestCase @Override protected void tearDown() throws Exception { - try{ + try + { repo.deleteDeployment(deployment.getId()); authenticationComponent.clearCurrentSecurityContext(); } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTransactionTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTransactionTest.java index f1ef630271..ded68914e3 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTransactionTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTransactionTest.java @@ -44,9 +44,8 @@ import org.alfresco.util.ApplicationContextHelper; import org.springframework.context.ApplicationContext; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiSpringTransactionTest extends TestCase { @@ -101,7 +100,7 @@ public class ActivitiSpringTransactionTest extends TestCase }; String id = txnHelper.doInTransaction(callback); ProcessInstance instance = findProcessInstance(id); - if(instance!=null) + if (instance != null) { runtime.deleteProcessInstance(id, "For test"); fail("The process instance creation should have been rolled back!"); @@ -232,7 +231,8 @@ public class ActivitiSpringTransactionTest extends TestCase @Override protected void tearDown() throws Exception { - try{ + try + { repo.deleteDeployment(deployment.getId(), true); authenticationComponent.clearCurrentSecurityContext(); } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java index e9a674a3ea..f142608194 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java @@ -51,9 +51,9 @@ import org.junit.Before; import org.junit.Test; /** - * @since 3.4.e * @author Nick Smith * @author Frederik Heremans + * @since 3.4.e */ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest { @@ -210,7 +210,7 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest } @SuppressWarnings("unchecked") - @Test + @Test public void testGetFinishedTaskById() throws Exception { WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap()); @@ -300,7 +300,7 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest for(HistoricDetail detail : updates) { HistoricVariableUpdate update = (HistoricVariableUpdate) detail; - if(update.getVariableName().equals("test_myVar")) + if (update.getVariableName().equals("test_myVar")) { Assert.assertEquals("test123", update.getValue()); found = true; @@ -373,7 +373,8 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest } @Test - public void testQueryTasksInProgress() throws Exception { + public void testQueryTasksInProgress() throws Exception + { // Testing all query functionality for WorkflowTaskState.IN_PROGRESS WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap()); @@ -542,28 +543,29 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest @Test - public void testQueryTasksCompleted() throws Exception { + public void testQueryTasksCompleted() throws Exception + { // Testing all query functionality for WorkflowTaskState.COMPLETED WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap()); Task task = taskService.createTaskQuery() - .executionId(BPMEngineRegistry.getLocalId(path.getId())) - .singleResult(); + .executionId(BPMEngineRegistry.getLocalId(path.getId())) + .singleResult(); taskService.setVariableLocal(task.getId(), "taskVar", "theValue"); - assertNotNull("Task should exist!", task); - String globalTaskId = createGlobalId(task.getId()); - - // Set the actor - taskService.setAssignee(task.getId(), TEST_USER); - - // Set process prop - runtime.setVariable(task.getExecutionId(), "processVar", "testing"); - - // End the task - workflowEngine.endTask(globalTaskId, null); + assertNotNull("Task should exist!", task); + String globalTaskId = createGlobalId(task.getId()); - // Test query by taskId + // Set the actor + taskService.setAssignee(task.getId(), TEST_USER); + + // Set process prop + runtime.setVariable(task.getExecutionId(), "processVar", "testing"); + + // End the task + workflowEngine.endTask(globalTaskId, null); + + // Test query by taskId WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); taskQuery.setActive(Boolean.FALSE); // Set to false, since workflow this task is in, has finished taskQuery.setTaskId(globalTaskId); @@ -592,16 +594,16 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest boolean taskFound = false; boolean startTaskFound = false; - for(WorkflowTask wfTask : tasks) + for (WorkflowTask wfTask : tasks) { - if(wfTask.getId().equals(globalTaskId)) - { - taskFound = true; - } - if(wfTask.getId().contains(ActivitiConstants.START_TASK_PREFIX)) - { - startTaskFound = true; - } + if (wfTask.getId().equals(globalTaskId)) + { + taskFound = true; + } + if (wfTask.getId().contains(ActivitiConstants.START_TASK_PREFIX)) + { + startTaskFound = true; + } } Assert.assertTrue("Task should have been returned", taskFound); Assert.assertTrue("Start-task should have been returned", startTaskFound); @@ -682,45 +684,47 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest } private void checkTaskVariableTaskPresent(WorkflowTaskState state, - QName varName, Object varValue, String expectedTask) { + QName varName, Object varValue, String expectedTask) + { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); Map customProperties = new HashMap(); customProperties.put(varName, varValue); taskQuery.setTaskCustomProps(customProperties); assertTaskPresent(taskQuery, expectedTask); - } + } private void checkTaskVariableNoMatch(WorkflowTaskState state, - QName varName, Object varValue) { + QName varName, Object varValue) + { WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state); Map customProperties = new HashMap(); customProperties.put(varName, varValue); taskQuery.setTaskCustomProps(customProperties); assertNoTaskPresent(taskQuery); - } + } - private WorkflowTaskQuery createWorkflowTaskQuery(WorkflowTaskState state) + private WorkflowTaskQuery createWorkflowTaskQuery(WorkflowTaskState state) { - WorkflowTaskQuery taskQuery = new WorkflowTaskQuery(); + WorkflowTaskQuery taskQuery = new WorkflowTaskQuery(); taskQuery.setTaskState(state); return taskQuery; } - private void assertTaskPresent(WorkflowTaskQuery taskQuery, - String taskId) - { - List tasks = workflowEngine.queryTasks(taskQuery); + private void assertTaskPresent(WorkflowTaskQuery taskQuery, + String taskId) + { + List tasks = workflowEngine.queryTasks(taskQuery); Assert.assertNotNull(tasks); Assert.assertEquals(1, tasks.size()); Assert.assertEquals(taskId, tasks.get(0).getId()); - } - - private void assertNoTaskPresent(WorkflowTaskQuery taskQuery) - { - List tasks = workflowEngine.queryTasks(taskQuery); + } + + private void assertNoTaskPresent(WorkflowTaskQuery taskQuery) + { + List tasks = workflowEngine.queryTasks(taskQuery); Assert.assertNotNull(tasks); Assert.assertEquals(0, tasks.size()); } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskPropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskPropertyHandler.java index 3b31100c94..556e48ed6a 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskPropertyHandler.java @@ -28,23 +28,21 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public abstract class ActivitiTaskPropertyHandler extends AbstractWorkflowPropertyHandler { - /** * {@inheritDoc} */ public Object handleProperty(QName key, Serializable value, TypeDefinition type, Object object, Class objectType) { - if(DelegateTask.class.equals(objectType)) + if (DelegateTask.class.equals(objectType)) { return handleDelegateTaskProperty((DelegateTask)object, type, key, value); } - else if(Task.class.equals(objectType)) + else if (Task.class.equals(objectType)) { return handleTaskProperty((Task)object, type, key, value); } @@ -81,5 +79,4 @@ public abstract class ActivitiTaskPropertyHandler extends AbstractWorkflowProper * @return */ protected abstract Object handleDelegateTaskProperty(DelegateTask task, TypeDefinition type, QName key, Serializable value); - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskTypeManager.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskTypeManager.java index 6792a45519..085cf78f1d 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskTypeManager.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTaskTypeManager.java @@ -30,9 +30,8 @@ import org.alfresco.repo.workflow.WorkflowObjectFactory; import org.alfresco.service.cmr.dictionary.TypeDefinition; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiTaskTypeManager { @@ -76,7 +75,7 @@ public class ActivitiTaskTypeManager private TypeDefinition getFullTaskDefinition(String taskDefinitionKey, FormData taskFormData) { String formKey = null; - if(taskFormData != null) + if (taskFormData != null) { formKey = taskFormData.getFormKey(); } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java index 33891d3948..b5ad2e13cf 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java @@ -57,7 +57,8 @@ // * @author Frederik Heremans // * @since 3.4.e // */ -//public class ActivitiTimerExecutionTest extends BaseSpringTest { +//public class ActivitiTimerExecutionTest extends BaseSpringTest +//{ // // private static final String USER1 = "User1" + GUID.generate(); // @@ -202,9 +203,9 @@ // .processInstanceId(processInstanceId).singleResult(); // // int numberOfRetries = 5; -// for(int i = 0; i < numberOfRetries; i++) +// for (int i = 0; i < numberOfRetries; i++) // { -// if(timer.getExceptionMessage() != null && timer.getRetries() == 0) +// if (timer.getExceptionMessage() != null && timer.getRetries() == 0) // { // break; // } @@ -254,7 +255,7 @@ // .processDefinitionKey("testTimerTransaction") // .singleResult(); // -// if(procDef != null) +// if (procDef != null) // { // activitiProcessEngine.getRepositoryService().deleteDeployment(procDef.getDeploymentId(), true); // } @@ -296,9 +297,9 @@ // .list(); // // int numberOfRetries = 5; -// for(int i=0; i< numberOfRetries; i++) +// for (int i=0; i< numberOfRetries; i++) // { -// if(timers.size() == 0) +// if (timers.size() == 0) // { // break; // } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTypeConverter.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTypeConverter.java index 6ae3f7a890..ddee63a755 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiTypeConverter.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiTypeConverter.java @@ -58,7 +58,6 @@ import org.alfresco.service.cmr.workflow.WorkflowTransition; import org.alfresco.service.namespace.QName; /** - * * @author Nick Smith * @author Frederik Heremans * @since 3.4.e @@ -100,7 +99,7 @@ public class ActivitiTypeConverter */ public WorkflowDeployment convert(Deployment deployment) { - if(deployment == null) + if (deployment == null) return null; List processDefs = repoService.createProcessDefinitionQuery() @@ -118,7 +117,7 @@ public class ActivitiTypeConverter */ public WorkflowDefinition convert(ProcessDefinition definition) { - if(definition==null) + if (definition==null) return null; String defId = definition.getId(); @@ -128,7 +127,7 @@ public class ActivitiTypeConverter String startTaskName = null; StartFormData startFormData = formService.getStartFormData(definition.getId()); - if(startFormData != null) + if (startFormData != null) { startTaskName = startFormData.getFormKey(); } @@ -148,7 +147,7 @@ public class ActivitiTypeConverter String startTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME); String startDescription= (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION); String startType = (String) activity.getProperty(ActivitiConstants.NODE_TYPE); - if(taskFormKey == null) + if (taskFormKey == null) { taskFormKey = startId; } @@ -164,20 +163,20 @@ public class ActivitiTypeConverter public WorkflowInstance convertAndSetVariables(ProcessInstance instance, Map collectedvariables) { - if(instance == null) + if (instance == null) return null; HistoricProcessInstance historicInstance = historyService - .createHistoricProcessInstanceQuery() - .processInstanceId(instance.getId()) - .singleResult(); + .createHistoricProcessInstanceQuery() + .processInstanceId(instance.getId()) + .singleResult(); return convertToInstanceAndSetVariables(historicInstance, collectedvariables); } public WorkflowInstance convert(HistoricProcessInstance instance, Map collectedvariables) { - if(instance == null) + if (instance == null) return null; HistoricProcessInstance historicInstance = historyService @@ -197,7 +196,7 @@ public class ActivitiTypeConverter public WorkflowPath convert(Execution execution, ProcessInstance instance) { - if(execution == null) + if (execution == null) return null; boolean isActive = !execution.isEnded(); @@ -222,25 +221,24 @@ public class ActivitiTypeConverter public WorkflowNode convert(PvmActivity activity, boolean forceIsTaskNode) { - String procDefId = activity.getProcessDefinition().getId(); - String key = activitiUtil.getProcessDefinition(procDefId).getKey(); - String name = activity.getId(); - String defaultTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME); - String defaultDescription = (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION); - String type = (String) activity.getProperty(ActivitiConstants.NODE_TYPE); - boolean isTaskNode = forceIsTaskNode || ActivitiConstants.USER_TASK_NODE_TYPE.equals(type); - - if(defaultTitle == null) - { - defaultTitle = name; - } - if(defaultDescription == null) - { - defaultDescription = name; - } + String procDefId = activity.getProcessDefinition().getId(); + String key = activitiUtil.getProcessDefinition(procDefId).getKey(); + String name = activity.getId(); + String defaultTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME); + String defaultDescription = (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION); + String type = (String) activity.getProperty(ActivitiConstants.NODE_TYPE); + boolean isTaskNode = forceIsTaskNode || ActivitiConstants.USER_TASK_NODE_TYPE.equals(type); + + if (defaultTitle == null) + { + defaultTitle = name; + } + if (defaultDescription == null) + { + defaultDescription = name; + } - return factory.createNode(name, key, defaultTitle, defaultDescription, type, isTaskNode, - NEXT_TRANSITION); + return factory.createNode(name, key, defaultTitle, defaultDescription, type, isTaskNode, NEXT_TRANSITION); } public WorkflowNode convert(PvmActivity activity) @@ -265,7 +263,7 @@ public class ActivitiTypeConverter for (Object in : inputs) { T out = (T) convert(in); - if(out != null) + if (out != null) { results.add(out); } @@ -281,7 +279,7 @@ public class ActivitiTypeConverter */ private Object convert(Object obj) { - if(obj == null) + if (obj == null) return null; if (obj instanceof Deployment) @@ -308,11 +306,11 @@ public class ActivitiTypeConverter { return convert( (Task) obj); } - if(obj instanceof HistoricTaskInstance) + if (obj instanceof HistoricTaskInstance) { return convert((HistoricTaskInstance) obj); } - if(obj instanceof HistoricProcessInstance) + if (obj instanceof HistoricProcessInstance) { return convert((HistoricProcessInstance) obj); } @@ -322,8 +320,9 @@ public class ActivitiTypeConverter public WorkflowTask convert(Task task) { - if(task == null) + if (task == null) return null; + String id = task.getId(); String defaultTitle = task.getName(); String defaultDescription = task.getDescription(); @@ -339,7 +338,7 @@ public class ActivitiTypeConverter TaskFormData taskFormData =formService.getTaskFormData(task.getId()); String taskDefId = null; - if(taskFormData != null) + if (taskFormData != null) { taskDefId = taskFormData.getFormKey(); } @@ -362,7 +361,7 @@ public class ActivitiTypeConverter String id = ActivitiConstants.START_TASK_PREFIX + execution.getProcessInstanceId(); WorkflowTaskState state = null; - if(inProgress) + if (inProgress) { state = WorkflowTaskState.IN_PROGRESS; } @@ -379,7 +378,7 @@ public class ActivitiTypeConverter StartFormData startFormData = formService.getStartFormData(processInstance.getProcessDefinitionId()); String taskDefId = null; - if(startFormData != null) + if (startFormData != null) { taskDefId = startFormData.getFormKey(); } @@ -403,7 +402,7 @@ public class ActivitiTypeConverter public WorkflowTask getVirtualStartTask(HistoricProcessInstance historicProcessInstance) { - if(historicProcessInstance == null) + if (historicProcessInstance == null) { return null; } @@ -414,7 +413,7 @@ public class ActivitiTypeConverter WorkflowTaskState state = null; boolean completed = historicProcessInstance.getEndTime() != null; - if(completed) + if (completed) { state = WorkflowTaskState.COMPLETED; } @@ -425,7 +424,7 @@ public class ActivitiTypeConverter // We use the process-instance ID as execution-id. It's ended anyway WorkflowPath path = buildCompletedPath(processInstanceId, processInstanceId); - if(path == null) + if (path == null) { return null; } @@ -447,8 +446,9 @@ public class ActivitiTypeConverter taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties); } - public WorkflowTask convert(HistoricTaskInstance historicTaskInstance) { - if(historicTaskInstance == null) + public WorkflowTask convert(HistoricTaskInstance historicTaskInstance) + { + if (historicTaskInstance == null) { return null; } @@ -456,7 +456,7 @@ public class ActivitiTypeConverter // Check to see if the instance is still running Execution execution = activitiUtil.getExecution(historicTaskInstance.getExecutionId()); - if(execution != null) + if (execution != null) { // Process execution still running path = convert(execution); @@ -467,7 +467,7 @@ public class ActivitiTypeConverter path = buildCompletedPath(historicTaskInstance.getExecutionId(), historicTaskInstance.getProcessInstanceId()); } - if(path == null) + if (path == null) { // When path is null, workflow is deleted or cancelled. Task should // not be used @@ -497,16 +497,16 @@ public class ActivitiTypeConverter private WorkflowNode buildHistoricTaskWorkflowNode(HistoricTaskInstance historicTaskInstance) { - ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId()); - PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey()); - return convert(taskActivity); - } + ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId()); + PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey()); + return convert(taskActivity); + } - public WorkflowPath buildCompletedPath(String executionId, String processInstanceId) + public WorkflowPath buildCompletedPath(String executionId, String processInstanceId) { WorkflowInstance wfInstance = null; ProcessInstance processInstance = activitiUtil.getProcessInstance(processInstanceId); - if(processInstance != null) + if (processInstance != null) { wfInstance = convert(processInstance); } @@ -516,10 +516,10 @@ public class ActivitiTypeConverter if(historicProcessInstance!= null) wfInstance = convert(historicProcessInstance); } - if(wfInstance == null) + if (wfInstance == null) { - // When workflow is cancelled or deleted, WorkflowPath should not be returned - return null; + // When workflow is cancelled or deleted, WorkflowPath should not be returned + return null; } WorkflowNode node = null; return factory.createPath(executionId, wfInstance, node, false); @@ -539,9 +539,9 @@ public class ActivitiTypeConverter Date endDate = historicProcessInstance.getEndTime(); // Copy all variables to map, if not null - if(collectedVariables != null) + if (collectedVariables != null) { - collectedVariables.putAll(variables); + collectedVariables.putAll(variables); } boolean isActive = historicProcessInstance.getEndTime() == null; @@ -551,7 +551,6 @@ public class ActivitiTypeConverter public WorkflowInstance convert(HistoricProcessInstance historicProcessInstance) { - return convertToInstanceAndSetVariables(historicProcessInstance, null); + return convertToInstanceAndSetVariables(historicProcessInstance, null); } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiUtil.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiUtil.java index 993027c96a..a4b31809c2 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiUtil.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiUtil.java @@ -40,9 +40,8 @@ import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.task.Task; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiUtil { @@ -107,7 +106,8 @@ public class ActivitiUtil public String getStartFormKey(String processDefinitionId) { ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) getDeployedProcessDefinition(processDefinitionId); - if(procDef.getStartFormHandler() == null) { + if(procDef.getStartFormHandler() == null) + { return null; } return procDef.getStartFormHandler().createStartFormData(procDef).getFormKey(); @@ -117,7 +117,7 @@ public class ActivitiUtil { String startTaskName = null; StartFormData startFormData = formService.getStartFormData(processDefinitionId); - if(startFormData != null) + if (startFormData != null) { startTaskName = startFormData.getFormKey(); } @@ -185,5 +185,4 @@ public class ActivitiUtil { return historyService.createHistoricTaskInstanceQuery().taskId(localId).singleResult(); } - } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowComponentTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowComponentTest.java index ac18f809d4..0ffddb8a9b 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowComponentTest.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowComponentTest.java @@ -62,9 +62,9 @@ import org.junit.Test; * Spring-configured JUnit 4 test case. * Uses Spring to load up a test context and runs each test case in a transaction which gets rolled back. * Loads up the activiti-context.xml and test-database-context.xml. - * @since 3.4.e + * * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiWorkflowComponentTest extends AbstractActivitiComponentTest { @@ -641,7 +641,7 @@ public class ActivitiWorkflowComponentTest extends AbstractActivitiComponentTest // One timer should be active on workflow String workflowInstanceId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, - processInstance.getProcessInstanceId()); + processInstance.getProcessInstanceId()); // Query the timer in activity to have reference Job timerJob = managementService.createJobQuery().timers().processInstanceId(processInstance.getId()).singleResult(); diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowEngine.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowEngine.java index 17a3eed923..181e7d0310 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowEngine.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowEngine.java @@ -109,9 +109,9 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** - * @since 3.4.e * @author Nick Smith * @author Frederik Heremans + * @since 3.4.e */ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { @@ -200,6 +200,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { super(); } + /** * {@inheritDoc} */ @@ -225,7 +226,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine try { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(localId).singleResult(); - if(processInstance == null) + if (processInstance == null) { throw new WorkflowException(messageService.getMessage(ERR_CANCEL_UNEXISTING_WORKFLOW)); } @@ -236,8 +237,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Convert historic process instance HistoricProcessInstance deletedInstance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(processInstance.getId()) - .singleResult(); + .processInstanceId(processInstance.getId()) + .singleResult(); WorkflowInstance result = typeConverter.convert(deletedInstance); // Delete the historic process instance @@ -245,7 +246,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine return result; } - catch(ActivitiException ae) + catch (ActivitiException ae) { String msg = messageService.getMessage(ERR_CANCEL_WORKFLOW); throw new WorkflowException(msg, ae); @@ -262,7 +263,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine try { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(localId).singleResult(); - if(processInstance == null) + if (processInstance == null) { throw new WorkflowException(messageService.getMessage(ERR_DELETE_UNEXISTING_WORKFLOW)); } @@ -272,8 +273,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Convert historic process instance HistoricProcessInstance deletedInstance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(processInstance.getId()) - .singleResult(); + .processInstanceId(processInstance.getId()) + .singleResult(); WorkflowInstance result = typeConverter.convert(deletedInstance); // Delete the historic process instance @@ -281,7 +282,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine return result; } - catch(ActivitiException ae) + catch (ActivitiException ae) { String msg = messageService.getMessage(ERR_DELETE_WORKFLOW); throw new WorkflowException(msg, ae); @@ -315,7 +316,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // not exposed return typeConverter.convert(deployment); } - catch(ActivitiException ae) + catch (ActivitiException ae) { String msg = messageService.getMessage(ERR_DEPLOY_WORKFLOW); throw new WorkflowException(msg, ae); @@ -342,7 +343,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { return getWorkflowInstances(workflowDefinitionId, true); } - catch(ActivitiException ae) + catch (ActivitiException ae) { String message = messageService.getMessage(ERR_GET_ACTIVE_WORKFLOW_INSTS, workflowDefinitionId); throw new WorkflowException(message, ae); @@ -355,7 +356,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine @Override public List getAllDefinitions() { - try { + try + { List definitions = repoService.createProcessDefinitionQuery().list(); return getValidWorkflowDefinitions(definitions); } @@ -375,12 +377,14 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine try { String name = workflowName; - if(tenantService.isEnabled()) + if (tenantService.isEnabled()) { // When a definition is requested from a wrong domain, an // AlfrescoRuntimeException will be thrown name = tenantService.getName(createLocalId(workflowName)); - } else { + } + else + { name = createLocalId(workflowName); } List definitions = repoService.createProcessDefinitionQuery() @@ -442,12 +446,14 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine try { String name = workflowName; - if(tenantService.isEnabled()) + if (tenantService.isEnabled()) { // When a definition is requested from a wrong domain, and // ActivitiRuntimeException will be thrown name = tenantService.getName(createLocalId(workflowName)); - } else { + } + else + { name = createLocalId(workflowName); } @@ -477,13 +483,13 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine .processDefinitionId(processDefinitionId) .singleResult(); - if(processDefinition == null) + if (processDefinition == null) { throw new WorkflowException(messageService.getMessage(ERR_GET_DEF_UNEXISTING_IMAGE, workflowDefinitionId)); } String diagramResourceName = ((ReadOnlyProcessDefinition)processDefinition).getDiagramResourceName(); - if(diagramResourceName != null) + if (diagramResourceName != null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream resourceInputStream = repoService.getResourceAsStream(processDefinitionId, diagramResourceName); @@ -494,12 +500,12 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // No image was found for the process definition return null; } - catch(IOException ioe) + catch (IOException ioe) { String msg = messageService.getMessage(ERR_GET_DEF_IMAGE, workflowDefinitionId); throw new WorkflowException(msg, ioe); } - catch(ActivitiException ae) + catch (ActivitiException ae) { String msg = messageService.getMessage(ERR_GET_DEF_IMAGE, workflowDefinitionId); throw new WorkflowException(msg, ae); @@ -560,7 +566,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine String startTaskName = null; StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); - if(startFormData != null) + if (startFormData != null) { startTaskName = startFormData.getFormKey(); } @@ -570,7 +576,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Now, continue through process, finding all user-tasks Collection taskActivities = findUserTasks(startEvent); - for(PvmActivity act : taskActivities) + for (PvmActivity act : taskActivities) { String formKey = getFormKey(act); defs.add(typeConverter.getTaskDefinition(act, formKey, processDefinition.getId())); @@ -581,14 +587,14 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private String getFormKey(PvmActivity act) { - if(act instanceof ActivityImpl) + if (act instanceof ActivityImpl) { ActivityImpl actImpl = (ActivityImpl) act; if (actImpl.getActivityBehavior() instanceof UserTaskActivityBehavior) { - UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior(); + UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior(); TaskFormHandler handler = uta.getTaskDefinition().getTaskFormHandler(); - if(handler != null && handler instanceof DefaultTaskFormHandler) + if (handler != null && handler instanceof DefaultTaskFormHandler) { // We cast to DefaultTaskFormHandler since we do not configure our own return ((DefaultTaskFormHandler)handler).getFormKey(); @@ -601,7 +607,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private boolean isReceiveTask(PvmActivity act) { - if(act instanceof ActivityImpl) + if (act instanceof ActivityImpl) { ActivityImpl actImpl = (ActivityImpl) act; return (actImpl.getActivityBehavior() instanceof ReceiveTaskActivityBehavior); @@ -622,9 +628,10 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private boolean isFirstActivity(PvmActivity activity, ReadOnlyProcessDefinition procDef) { - if(procDef.getInitial().getOutgoingTransitions().size() == 1) + if (procDef.getInitial().getOutgoingTransitions().size() == 1) { - if(procDef.getInitial().getOutgoingTransitions().get(0).getDestination().equals(activity)) { + if (procDef.getInitial().getOutgoingTransitions().get(0).getDestination().equals(activity)) + { return true; } } @@ -634,19 +641,19 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private void findUserTasks(PvmActivity currentActivity, Map userTasks) { // Only process activity if not already present to prevent endless loops - if(!userTasks.containsKey(currentActivity.getId())) + if (!userTasks.containsKey(currentActivity.getId())) { - if(isUserTask(currentActivity)) + if (isUserTask(currentActivity)) { userTasks.put(currentActivity.getId(), currentActivity); } // Process outgoing transitions - if(currentActivity.getOutgoingTransitions() != null) + if (currentActivity.getOutgoingTransitions() != null) { - for(PvmTransition transition : currentActivity.getOutgoingTransitions()) + for (PvmTransition transition : currentActivity.getOutgoingTransitions()) { - if(transition.getDestination() != null) + if (transition.getDestination() != null) { findUserTasks(transition.getDestination(), userTasks); } @@ -659,7 +666,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { // TODO: Validate if this is the best way to find out an activity is a usertask String type = (String) currentActivity.getProperty(ActivitiConstants.NODE_TYPE); - if(type != null && type.equals(ActivitiConstants.USER_TASK_NODE_TYPE)) + if (type != null && type.equals(ActivitiConstants.USER_TASK_NODE_TYPE)) { return true; } @@ -676,14 +683,14 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { // Extract the Activiti ID from the path String executionId = getExecutionIdFromPath(pathId); - if(executionId == null) + if (executionId == null) { throw new WorkflowException(messageService.getMessage(ERR_GET_WORKFLOW_TOKEN_INVALID, pathId)); } // Check if the execution exists Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult(); - if(execution == null) + if (execution == null) { throw new WorkflowException(messageService.getMessage(ERR_GET_WORKFLOW_TOKEN_NULL, pathId)); } @@ -693,20 +700,20 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Check if workflow's start task has been completed. If not, return the virtual task // Otherwise, just return the runtime activiti tasks Date startTaskEndDate = (Date) runtimeService.getVariable(execution.getProcessInstanceId(), - ActivitiConstants.PROP_START_TASK_END_DATE); + ActivitiConstants.PROP_START_TASK_END_DATE); boolean startTaskEnded = (startTaskEndDate != null); - if(startTaskEnded) + if (startTaskEnded) { - List tasks = taskService.createTaskQuery().executionId(executionId).list(); - for(Task task : tasks) - { - resultList.add(typeConverter.convert(task)); - } + List tasks = taskService.createTaskQuery().executionId(executionId).list(); + for (Task task : tasks) + { + resultList.add(typeConverter.convert(task)); + } } else { - resultList.add(typeConverter.getVirtualStartTask(executionId, true)); + resultList.add(typeConverter.getVirtualStartTask(executionId, true)); } return resultList; } @@ -716,14 +723,13 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine throw new WorkflowException(msg, ae); } } - - - protected String getExecutionIdFromPath(String workflowPath) { - if(workflowPath != null) + protected String getExecutionIdFromPath(String workflowPath) + { + if (workflowPath != null) { String[] parts = workflowPath.split(WORKFLOW_TOKEN_SEPERATOR); - if(parts.length != 2) + if (parts.length != 2) { throw new WorkflowException(messageService.getMessage(ERR_GET_WORKFLOW_TOKEN_INVALID, workflowPath)); } @@ -738,41 +744,41 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine @Override public List getTimers(String workflowId) { - try - { - List timers = new ArrayList(); + try + { + List timers = new ArrayList(); - String processInstanceId = createLocalId(workflowId); - List timerJobs = managementService.createJobQuery() - .processInstanceId(processInstanceId) - .timers() - .list(); - - // Only fetch process-instance when timers are available, to prevent extra unneeded query - ProcessInstance jobsProcessInstance = null; - if(timerJobs.size() > 0) - { - // Reuse the process-instance, is used from WorkflowPath creation - jobsProcessInstance = runtimeService.createProcessInstanceQuery() - .processInstanceId(processInstanceId).singleResult(); - } - - // Convert the timerJobs to WorkflowTimers - for(Job job : timerJobs) - { - Execution jobExecution = runtimeService.createExecutionQuery() - .executionId(job.getExecutionId()).singleResult(); - - WorkflowPath path = typeConverter.convert(jobExecution, jobsProcessInstance); - WorkflowTask workflowTask = getTaskForTimer(job, jobsProcessInstance, jobExecution); - - WorkflowTimer workflowTimer = factory.createWorkflowTimer(job.getId(), job.getId(), - job.getExceptionMessage(), job.getDuedate(), path, workflowTask); - timers.add(workflowTimer); - } - - return timers; + String processInstanceId = createLocalId(workflowId); + List timerJobs = managementService.createJobQuery() + .processInstanceId(processInstanceId) + .timers() + .list(); + // Only fetch process-instance when timers are available, to prevent extra unneeded query + ProcessInstance jobsProcessInstance = null; + if (timerJobs.size() > 0) + { + // Reuse the process-instance, is used from WorkflowPath creation + jobsProcessInstance = runtimeService.createProcessInstanceQuery() + .processInstanceId(processInstanceId).singleResult(); + } + + // Convert the timerJobs to WorkflowTimers + for (Job job : timerJobs) + { + Execution jobExecution = runtimeService.createExecutionQuery() + .executionId(job.getExecutionId()).singleResult(); + + WorkflowPath path = typeConverter.convert(jobExecution, jobsProcessInstance); + WorkflowTask workflowTask = getTaskForTimer(job, jobsProcessInstance, jobExecution); + + WorkflowTimer workflowTimer = factory.createWorkflowTimer(job.getId(), job.getId(), + job.getExceptionMessage(), job.getDuedate(), path, workflowTask); + timers.add(workflowTimer); + } + + return timers; + } catch (ActivitiException ae) { @@ -781,33 +787,34 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine } } - private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) { - if (job instanceof TimerEntity) { - - ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); - List activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId()); - - if(activeActivityIds.size() == 1) - { - PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0)); - if(targetActivity != null) - { - // Only get tasks of active activity is a user-task - String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE); - if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType)) - { - Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult(); - return typeConverter.convert(task); - } - } - } - } - return null; - } + private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) + { + if (job instanceof TimerEntity) + { + ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); + List activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId()); + + if (activeActivityIds.size() == 1) + { + PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0)); + if (targetActivity != null) + { + // Only get tasks of active activity is a user-task + String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE); + if (ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType)) + { + Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult(); + return typeConverter.convert(task); + } + } + } + } + return null; + } - /** - * {@inheritDoc} - */ + /** + * {@inheritDoc} + */ @Override public WorkflowInstance getWorkflowById(String workflowId) { @@ -820,7 +827,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine .processInstanceId(processInstanceId) .singleResult(); - if(processIntance != null) + if (processIntance != null) { instance = typeConverter.convert(processIntance); } @@ -919,7 +926,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private String getProcessKey(InputStream workflowDefinition) throws Exception { - try { + try + { InputSource inputSource = new InputSource(workflowDefinition); DOMParser parser = new DOMParser(); parser.parse(inputSource); @@ -953,7 +961,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine Execution oldExecution = activitiUtil.getExecution(execId); runtimeService.signal(execId); Execution execution = activitiUtil.getExecution(execId); - if(execution !=null) + if (execution !=null) { return typeConverter.convert(execution); } @@ -996,7 +1004,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Start the process-instance ProcessInstance instance = runtimeService.startProcessInstanceById(processDefId, variables); - if(instance.isEnded()) + if (instance.isEnded()) { return typeConverter.buildCompletedPath(instance.getId(), instance.getId()); } @@ -1024,7 +1032,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine ProcessDefinition procDef = repoService.createProcessDefinitionQuery() .processDefinitionId(procDefId) .singleResult(); - if(procDef == null) { + if (procDef == null) + { String msg = messageService.getMessage(ERR_UNDEPLOY_WORKFLOW_UNEXISTING, workflowDefinitionId); throw new WorkflowException(msg); } @@ -1254,7 +1263,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { String localTaskId = createLocalId(taskId); // Check if the task is a virtual start task - if(localTaskId.startsWith(ActivitiConstants.START_TASK_PREFIX)) + if (localTaskId.startsWith(ActivitiConstants.START_TASK_PREFIX)) { return endStartTask(taskId, localTaskId, transition); } @@ -1267,7 +1276,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Retrieve task Task task = taskService.createTaskQuery().taskId(localTaskId).singleResult(); - if(task == null) + if (task == null) { String msg = messageService.getMessage(ERR_END_UNEXISTING_TASK, taskId); throw new WorkflowException(msg); @@ -1288,9 +1297,9 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine Map properties = propertyConverter.getTaskProperties(task, false); QName outcomePropName = (QName) properties.get(WorkflowModel.PROP_OUTCOME_PROPERTY_NAME); - if(outcomePropName !=null) + if (outcomePropName !=null) { - if(isDefaultTransition == false) + if (isDefaultTransition == false) { outcomeValue = transition; Serializable transitionValue = propertyConverter.convertValueToPropertyType(task, transition, outcomePropName); @@ -1299,13 +1308,13 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine else { Serializable rawOutcome = properties.get(outcomePropName); - if(rawOutcome != null) + if (rawOutcome != null) { outcomeValue = DefaultTypeConverter.INSTANCE.convert(String.class, rawOutcome); } } } - else if (isDefaultTransition==false) + else if (isDefaultTransition == false) { // Only 'Next' is supported as transition. String taskId = createGlobalId(task.getId()); @@ -1333,14 +1342,15 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); PvmActivity activity = procDef.findActivity(currentActivity); - if(isReceiveTask(activity) && isFirstActivity(activity, procDef)) + if (isReceiveTask(activity) && isFirstActivity(activity, procDef)) { // Signal the process to start flowing, beginning from the recieve task runtimeService.signal(processInstanceId); // It's possible the process has ended after signalling the receive task processInstance = activitiUtil.getProcessInstance(processInstanceId); - if(processInstance != null) { + if (processInstance != null) + { return typeConverter.getVirtualStartTask(processInstanceId, false); } else @@ -1353,7 +1363,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Return virtual start task for the execution, it's safe to use the processInstanceId return typeConverter.getVirtualStartTask(processInstanceId, false); } - } /** @@ -1364,7 +1373,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { try { - if(state == WorkflowTaskState.IN_PROGRESS) + if (state == WorkflowTaskState.IN_PROGRESS) { List tasks = taskService.createTaskQuery() .taskAssignee(authority) @@ -1394,7 +1403,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { try { - if(authorities != null && authorities.size() > 0) { + if (authorities != null && authorities.size() > 0) + { // As an optimisation, we assume the first authority CAN be a user. All the // others are groups to which the user (or group) belongs. This way, we don't have to // check for the type of the authority. @@ -1413,7 +1423,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine // Candidate group addTasksForCandidateGroup(firstAuthority, resultingTasks); } - for(int i=1; i tasks = new ArrayList(); // Only tasks that have NO assignee, should be returned - for(Task task : resultingTasks.values()) { - if(task.getAssignee() == null) { + for(Task task : resultingTasks.values()) + { + if(task.getAssignee() == null) + { tasks.add(task); } } @@ -1431,10 +1444,10 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine return Collections.emptyList(); } - catch(ActivitiException ae) + catch (ActivitiException ae) { String authorityString = null; - if(authorities != null) + if (authorities != null) { authorityString = StringUtils.join(authorities.iterator(), ", "); } @@ -1446,7 +1459,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private void addTasksForCandidateGroup(String groupName, Map resultingTasks) { List tasks = taskService.createTaskQuery().taskCandidateGroup(groupName).list(); - for(Task task : tasks) + for (Task task : tasks) { resultingTasks.put(task.getId(), task); } @@ -1455,7 +1468,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private void addTasksForCandidateUser(String userName, Map resultingTasks) { List tasks = taskService.createTaskQuery().taskCandidateUser(userName).list(); - for(Task task : tasks) + for (Task task : tasks) { resultingTasks.put(task.getId(), task); } @@ -1470,7 +1483,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine try { String localId = createLocalId(taskId); - if(localId.startsWith(ActivitiConstants.START_TASK_PREFIX)) + if (localId.startsWith(ActivitiConstants.START_TASK_PREFIX)) { String processInstanceId = localId.replace(ActivitiConstants.START_TASK_PREFIX ,""); return getVirtualStartTaskForProcessInstance(processInstanceId); @@ -1478,7 +1491,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine else { Task task = activitiUtil.getTaskInstance(localId); - if(task != null) + if (task != null) { return typeConverter.convert(task); } @@ -1501,13 +1514,13 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { ArrayList result = new ArrayList(); WorkflowTaskState taskState = query.getTaskState(); - if(WorkflowTaskState.COMPLETED.equals(taskState) == false) + if (WorkflowTaskState.COMPLETED.equals(taskState) == false) { result.addAll(queryRuntimeTasks(query)); } // Depending on the state, history should be included/excluded as wel - if(WorkflowTaskState.IN_PROGRESS.equals(taskState) == false) + if (WorkflowTaskState.IN_PROGRESS.equals(taskState) == false) { result.addAll(queryHistoricTasks(query)); result.addAll(queryStartTasks(query)); @@ -1592,8 +1605,9 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine } private void addProcessPropertiesToQuery( - Map processCustomProps, TaskQuery taskQuery) { - for(Entry customProperty : processCustomProps.entrySet()) + Map processCustomProps, TaskQuery taskQuery) + { + for (Entry customProperty : processCustomProps.entrySet()) { String name =factory.mapQNameToName(customProperty.getKey()); taskQuery.processVariableValueEquals(name, customProperty.getValue()); @@ -1630,7 +1644,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine return processName; } - private void orderQuery(TaskQuery taskQuery, OrderBy[] orderBy) { + private void orderQuery(TaskQuery taskQuery, OrderBy[] orderBy) + { for (WorkflowTaskQuery.OrderBy orderByPart : orderBy) { if (orderByPart == WorkflowTaskQuery.OrderBy.TaskActor_Asc) @@ -1677,7 +1692,8 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine } } - private void orderQuery(HistoricTaskInstanceQuery taskQuery, OrderBy[] orderBy) { + private void orderQuery(HistoricTaskInstanceQuery taskQuery, OrderBy[] orderBy) + { for (WorkflowTaskQuery.OrderBy orderByPart : orderBy) { if (orderByPart == WorkflowTaskQuery.OrderBy.TaskActor_Asc) @@ -1733,7 +1749,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine private void addTaskPropertiesToQuery(Map taskCustomProps, TaskQuery taskQuery) { - for(Entry customProperty : taskCustomProps.entrySet()) + for (Entry customProperty : taskCustomProps.entrySet()) { String name =factory.mapQNameToName(customProperty.getKey()); taskQuery.taskVariableValueEquals(name, customProperty.getValue()); @@ -1832,21 +1848,23 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine } private void addTaskPropertiesToQuery(Map taskCustomProps, - HistoricTaskInstanceQuery taskQuery) { - for(Entry customProperty : taskCustomProps.entrySet()) - { - String name =factory.mapQNameToName(customProperty.getKey()); - taskQuery.taskVariableValueEquals(name, customProperty.getValue()); - } + HistoricTaskInstanceQuery taskQuery) + { + for (Entry customProperty : taskCustomProps.entrySet()) + { + String name =factory.mapQNameToName(customProperty.getKey()); + taskQuery.taskVariableValueEquals(name, customProperty.getValue()); + } } private void addProcessPropertiesToQuery(Map processCustomProps, - HistoricTaskInstanceQuery taskQuery) { - for(Entry customProperty : processCustomProps.entrySet()) - { - String name =factory.mapQNameToName(customProperty.getKey()); - taskQuery.processVariableValueEquals(name, customProperty.getValue()); - } + HistoricTaskInstanceQuery taskQuery) + { + for (Entry customProperty : processCustomProps.entrySet()) + { + String name =factory.mapQNameToName(customProperty.getKey()); + taskQuery.processVariableValueEquals(name, customProperty.getValue()); + } } private List queryStartTasks(WorkflowTaskQuery query) @@ -1855,16 +1873,16 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine String processInstanceId = null; String taskId = query.getTaskId(); - if(taskId != null ) + if (taskId != null ) { String localTaskId = createLocalId(taskId); - if(localTaskId.startsWith(ActivitiConstants.START_TASK_PREFIX)) + if (localTaskId.startsWith(ActivitiConstants.START_TASK_PREFIX)) processInstanceId = localTaskId.substring(ActivitiConstants.START_TASK_PREFIX.length()); } else { String processId = query.getProcessId(); - if(processId != null) + if (processId != null) { // Start task for a specific process processInstanceId = createLocalId(processId); @@ -1872,155 +1890,153 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine } // Only return start-task when a process or task id is set - if(processInstanceId != null) + if (processInstanceId != null) { // Extract processInstanceId WorkflowTask workflowTask = getVirtualStartTaskForProcessInstance(processInstanceId); - if(workflowTask != null) + if (workflowTask != null) { - boolean startTaskMatches = isStartTaskMatching(workflowTask, query); - if(startTaskMatches) - { - startTasks.add(workflowTask); - } + boolean startTaskMatches = isStartTaskMatching(workflowTask, query); + if (startTaskMatches) + { + startTasks.add(workflowTask); + } } } return startTasks; } - private boolean isStartTaskMatching(WorkflowTask workflowTask, - WorkflowTaskQuery query) { - - if(query.isActive() != null) - { - if(query.isActive() && !workflowTask.getPath().isActive()) - { - return false; - } - if(!query.isActive() && workflowTask.getPath().isActive()) - { - return false; - } - } - - if(query.getActorId() != null && !query.getActorId().equals(workflowTask.getProperties().get(ContentModel.PROP_OWNER))) - { - return false; - } - - if(query.getProcessCustomProps() != null) - { - // Get properties for process instance, based on path of start task, which is process-instance - Map props = getPathProperties(workflowTask.getPath().getId()); - if(!checkPropertiesPresent(query.getProcessCustomProps(), props)) - { - return false; - } - } - - if(query.getProcessId() != null) - { - if(!query.getProcessId().equals(workflowTask.getPath().getInstance().getId())) - { - return false; - } - } - - // Query by process name deprecated, but still implemented. - if(query.getProcessName() != null) - { - String processName = factory.mapQNameToName(query.getProcessName()); - if(!processName.equals(workflowTask.getPath().getInstance().getDefinition().getName())) - { - return false; - } - } - - if(query.getWorkflowDefinitionName() != null) + private boolean isStartTaskMatching(WorkflowTask workflowTask, WorkflowTaskQuery query) + { + if (query.isActive() != null) { - if(!query.getWorkflowDefinitionName().equals(workflowTask.getPath().getInstance().getDefinition().getName())) + if (query.isActive() && !workflowTask.getPath().isActive()) + { + return false; + } + if (!query.isActive() && workflowTask.getPath().isActive()) { return false; } } - - if(query.getTaskCustomProps() != null) - { - if(!checkPropertiesPresent(query.getTaskCustomProps(), workflowTask.getProperties())) - { - return false; - } - } - - if(query.getTaskId() != null) - { - if(!query.getTaskId().equals(workflowTask.getId())) - { - return false; - } - } - - if(query.getTaskName() != null) - { - if(!query.getTaskName().equals(workflowTask.getDefinition().getMetadata().getName())) - { - return false; - } - } - - if(query.getTaskState() != null) - { - if(!query.getTaskState().equals(workflowTask.getState())) - { - return false; - } - } - - // If we fall through, start task matches the query - return true; + + if (query.getActorId() != null && !query.getActorId().equals(workflowTask.getProperties().get(ContentModel.PROP_OWNER))) + { + return false; + } + + if (query.getProcessCustomProps() != null) + { + // Get properties for process instance, based on path of start task, which is process-instance + Map props = getPathProperties(workflowTask.getPath().getId()); + if (!checkPropertiesPresent(query.getProcessCustomProps(), props)) + { + return false; + } + } + + if (query.getProcessId() != null) + { + if (!query.getProcessId().equals(workflowTask.getPath().getInstance().getId())) + { + return false; + } + } + + // Query by process name deprecated, but still implemented. + if (query.getProcessName() != null) + { + String processName = factory.mapQNameToName(query.getProcessName()); + if (!processName.equals(workflowTask.getPath().getInstance().getDefinition().getName())) + { + return false; + } + } + + if (query.getWorkflowDefinitionName() != null) + { + if (!query.getWorkflowDefinitionName().equals(workflowTask.getPath().getInstance().getDefinition().getName())) + { + return false; + } + } + + if (query.getTaskCustomProps() != null) + { + if (!checkPropertiesPresent(query.getTaskCustomProps(), workflowTask.getProperties())) + { + return false; + } + } + + if (query.getTaskId() != null) + { + if (!query.getTaskId().equals(workflowTask.getId())) + { + return false; + } + } + + if (query.getTaskName() != null) + { + if (!query.getTaskName().equals(workflowTask.getDefinition().getMetadata().getName())) + { + return false; + } + } + + if (query.getTaskState() != null) + { + if (!query.getTaskState().equals(workflowTask.getState())) + { + return false; + } + } + + // If we fall through, start task matches the query + return true; } private boolean checkPropertiesPresent(Map expectedProperties, Map props) { - for(Map.Entry entry : expectedProperties.entrySet()) - { - if(props.containsKey(entry.getKey())) - { - Object requiredValue = entry.getValue(); - Object actualValue = props.get(entry.getKey()); - - if(requiredValue != null) - { - if(!requiredValue.equals(actualValue)) - { - return false; - } - break; - } - else - { - if(actualValue != null) - { - return false; - } - break; - } - } - if(entry.getValue() != null) - { - // If variable is not found and required value is non null, start-task doesn't match - return false; - } - } - - return true; + for(Map.Entry entry : expectedProperties.entrySet()) + { + if (props.containsKey(entry.getKey())) + { + Object requiredValue = entry.getValue(); + Object actualValue = props.get(entry.getKey()); + + if (requiredValue != null) + { + if (!requiredValue.equals(actualValue)) + { + return false; + } + break; + } + else + { + if (actualValue != null) + { + return false; + } + break; + } + } + if (entry.getValue() != null) + { + // If variable is not found and required value is non null, start-task doesn't match + return false; + } + } + + return true; } - - /** - * {@inheritDoc} - */ + /** + * {@inheritDoc} + */ @Override public WorkflowTask getStartTask(String workflowInstanceId) { @@ -2035,11 +2051,11 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine .processInstanceId(processInstanceId) .singleResult(); - if(runningInstance != null) + if (runningInstance != null) { // Check the process instance variable to see if start-task has been completed Date startTaskEndDate = (Date) runtimeService.getVariable(runningInstance.getProcessInstanceId(), - ActivitiConstants.PROP_START_TASK_END_DATE); + ActivitiConstants.PROP_START_TASK_END_DATE); boolean startTaskEnded = (startTaskEndDate != null); return typeConverter.getVirtualStartTask(runningInstance.getId(), !startTaskEnded); } @@ -2080,7 +2096,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { try { - if(taskId.startsWith(ActivitiConstants.START_TASK_PREFIX)) + if (taskId.startsWith(ActivitiConstants.START_TASK_PREFIX)) { // Known limitation, start-tasks cannot be updated String msg = messageService.getMessage(ERR_UPDATE_START_TASK, taskId); @@ -2088,7 +2104,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine } Task task = taskService.createTaskQuery().taskId(createLocalId(taskId)).singleResult(); - if(task != null) + if (task != null) { Task updatedTask = propertyConverter.updateTask(task, properties, add, remove); return typeConverter.convert(updatedTask); @@ -2099,7 +2115,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine throw new WorkflowException(msg); } } - catch(ActivitiException ae) + catch (ActivitiException ae) { String msg = messageService.getMessage(ERR_UPDATE_TASK, taskId); throw new WorkflowException(msg, ae); @@ -2110,7 +2126,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine { String processDefId = createLocalId(workflowDefinitionId); LinkedList results = new LinkedList(); - if(Boolean.FALSE.equals(isActive)==false) + if (Boolean.FALSE.equals(isActive)==false) { List activeInstances = runtimeService.createProcessInstanceQuery() .processDefinitionId(processDefId) @@ -2118,7 +2134,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine List activeResults = typeConverter.convert(activeInstances); results.addAll(activeResults); } - if(Boolean.TRUE.equals(isActive)==false) + if (Boolean.TRUE.equals(isActive)==false) { List completedInstances = historyService.createHistoricProcessInstanceQuery() .processDefinitionId(processDefId) diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowManagerFactory.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowManagerFactory.java index 96ebbcd5bf..2d27dd937b 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowManagerFactory.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowManagerFactory.java @@ -69,15 +69,15 @@ public class ActivitiWorkflowManagerFactory implements FactoryBean expectedTasks = Arrays.asList(startTask.getId()); - + // In activiti, start-tasks only show up when the taskId or workflowInstanceId is passed in. + List expectedTasks = Arrays.asList(startTask.getId()); + checkProcessIdQuery(workflowInstanceId, expectedTasks, WorkflowTaskState.COMPLETED); - checkTaskIdQuery(startTask.getId(), WorkflowTaskState.COMPLETED); - - // Check additional filtering, when workflowInstanceId is passed - QName startTaskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "submitAdhocTask"); - checkTaskNameQuery(startTaskName, expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); - checkActorIdQuery(USER1, expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); - checkIsActiveQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); - checkTaskPropsQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); - } + checkTaskIdQuery(startTask.getId(), WorkflowTaskState.COMPLETED); + + // Check additional filtering, when workflowInstanceId is passed + QName startTaskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "submitAdhocTask"); + checkTaskNameQuery(startTaskName, expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); + checkActorIdQuery(USER1, expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); + checkIsActiveQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); + checkTaskPropsQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); + } @Override protected void checkTaskQueryTaskCompleted(String workflowInstanceId, WorkflowTask theTask, WorkflowTask startTask) - { - List withoutStartTask = Arrays.asList(theTask.getId()); - List bothTasks= Arrays.asList(theTask.getId(), startTask.getId()); + { + List withoutStartTask = Arrays.asList(theTask.getId()); + List bothTasks= Arrays.asList(theTask.getId(), startTask.getId()); - checkProcessIdQuery(workflowInstanceId, bothTasks, WorkflowTaskState.COMPLETED); + checkProcessIdQuery(workflowInstanceId, bothTasks, WorkflowTaskState.COMPLETED); // Adhoc task should only be returned QName taskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "adhocTask"); @@ -121,25 +120,26 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ // Process properties checkProcessPropsQuery(withoutStartTask, WorkflowTaskState.COMPLETED); - } + } @Override - protected void checkQueryTasksInactiveWorkflow(String workflowInstanceId) { - WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); - taskQuery.setActive(false); - taskQuery.setProcessId(workflowInstanceId); - - List tasks = workflowService.queryTasks(taskQuery); + protected void checkQueryTasksInactiveWorkflow(String workflowInstanceId) + { + WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); + taskQuery.setActive(false); + taskQuery.setProcessId(workflowInstanceId); + + List tasks = workflowService.queryTasks(taskQuery); assertNotNull(tasks); // Activiti doesn't return start-task when no process/task id is set in query, so only 2 tasks will be returned assertEquals(3, tasks.size()); taskQuery = createWorkflowTaskQuery(WorkflowTaskState.COMPLETED); - taskQuery.setActive(true); + taskQuery.setActive(true); taskQuery.setProcessId(workflowInstanceId); - checkNoTasksFoundUsingQuery(taskQuery); - } + checkNoTasksFoundUsingQuery(taskQuery); + } @Override protected String getEngine() @@ -171,15 +171,15 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ return "alfresco/workflow/parallel-review.bpmn20.xml"; } - @Override - protected String getTestTimerDefinitionPath() - { - return "activiti/testTimer.bpmn20.xml"; - } - - @Override - protected QName getAdhocProcessName() { - return QName.createQName("activitiAdhoc"); - } - + @Override + protected String getTestTimerDefinitionPath() + { + return "activiti/testTimer.bpmn20.xml"; + } + + @Override + protected QName getAdhocProcessName() + { + return QName.createQName("activitiAdhoc"); + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/AddTaskListenerParseListener.java b/source/java/org/alfresco/repo/workflow/activiti/AddTaskListenerParseListener.java index 3c102458b5..34da576757 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/AddTaskListenerParseListener.java +++ b/source/java/org/alfresco/repo/workflow/activiti/AddTaskListenerParseListener.java @@ -49,14 +49,14 @@ public class AddTaskListenerParseListener implements BpmnParseListener public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { ActivityBehavior activitybehaviour = activity.getActivityBehavior(); - if(activitybehaviour instanceof UserTaskActivityBehavior) + if (activitybehaviour instanceof UserTaskActivityBehavior) { - UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activitybehaviour; - if(createTaskListener != null) + UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activitybehaviour; + if (createTaskListener != null) { userTaskActivity.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_CREATE, createTaskListener); } - if(completeTaskListener != null) + if (completeTaskListener != null) { userTaskActivity.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_COMPLETE, completeTaskListener); } @@ -168,25 +168,26 @@ public class AddTaskListenerParseListener implements BpmnParseListener } @Override - public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, - boolean interrupting, ActivityImpl activity, - ActivityImpl nestedErrorEventActivity) + public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, + boolean interrupting, ActivityImpl activity, + ActivityImpl nestedErrorEventActivity) { - // Nothing to do here - } + // Nothing to do here + } @Override - public void parseIntermediateTimerEventDefinition( - Element timerEventDefinition, ActivityImpl timerActivity) + public void parseIntermediateTimerEventDefinition( + Element timerEventDefinition, ActivityImpl timerActivity) { - // Nothing to do here - } + // Nothing to do here + } @Override public void parseMultiInstanceLoopCharacteristics(Element activityElement, - Element multiInstanceLoopCharacteristicsElement, - ActivityImpl activity) { - // Nothing to do here + Element multiInstanceLoopCharacteristicsElement, + ActivityImpl activity) + { + // Nothing to do here } public void setCompleteTaskListener(TaskListener completeTaskListener) @@ -203,5 +204,4 @@ public class AddTaskListenerParseListener implements BpmnParseListener { this.processCreateListener = processCreateListener; } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/AlfrescoProcessEngineConfiguration.java b/source/java/org/alfresco/repo/workflow/activiti/AlfrescoProcessEngineConfiguration.java index c7390dce84..72610b1912 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/AlfrescoProcessEngineConfiguration.java +++ b/source/java/org/alfresco/repo/workflow/activiti/AlfrescoProcessEngineConfiguration.java @@ -28,9 +28,9 @@ import org.activiti.engine.impl.variable.VariableType; import org.activiti.spring.SpringProcessEngineConfiguration; /** - * @since 3.4.e * @author Nick Smith * @author Frederik Heremans + * @since 3.4.e */ public class AlfrescoProcessEngineConfiguration extends SpringProcessEngineConfiguration { @@ -41,30 +41,31 @@ public class AlfrescoProcessEngineConfiguration extends SpringProcessEngineConfi { super.initVariableTypes(); // Add custom types before SerializableType - if(customTypes != null) + if (customTypes != null) { int serializableIndex = variableTypes.getTypeIndex(SerializableType.TYPE_NAME); - for(VariableType type : customTypes) { + for (VariableType type : customTypes) + { variableTypes.addType(type, serializableIndex); } } } @Override - protected void initJobExecutor() { - super.initJobExecutor(); - - // Get the existing timer-job handler and wrap - // with one that is alfresco-authentication aware - JobHandler jobHandler = jobHandlers.get(TimerExecuteNestedActivityJobHandler.TYPE); - JobHandler wrappingJobHandler = new AuthenticatedTimerJobHandler(jobHandler); - - jobHandlers.put(TimerExecuteNestedActivityJobHandler.TYPE, wrappingJobHandler); + protected void initJobExecutor() + { + super.initJobExecutor(); + + // Get the existing timer-job handler and wrap + // with one that is alfresco-authentication aware + JobHandler jobHandler = jobHandlers.get(TimerExecuteNestedActivityJobHandler.TYPE); + JobHandler wrappingJobHandler = new AuthenticatedTimerJobHandler(jobHandler); + + jobHandlers.put(TimerExecuteNestedActivityJobHandler.TYPE, wrappingJobHandler); } public void setCustomTypes(List customTypes) { this.customTypes = customTypes; } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/AuthenticatedTimerJobHandler.java b/source/java/org/alfresco/repo/workflow/activiti/AuthenticatedTimerJobHandler.java index f40767200e..1f4c767a58 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/AuthenticatedTimerJobHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/AuthenticatedTimerJobHandler.java @@ -41,61 +41,62 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; */ public class AuthenticatedTimerJobHandler implements JobHandler { - private JobHandler wrappedHandler; - - public AuthenticatedTimerJobHandler(JobHandler jobHandler) - { - if(jobHandler == null) - { - throw new IllegalArgumentException("JobHandler to delegate to is required"); - } - this.wrappedHandler = jobHandler; - } - - @Override - public void execute(final String configuration, final ExecutionEntity execution, - final CommandContext commandContext) - { - String userName = null; - - PvmActivity targetActivity = execution.getActivity(); - if(targetActivity != null) - { - // Only try getting active task, if execution timer is waiting on is a userTask - String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE); - if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType)) - { - Task task = new TaskQueryImpl(commandContext) - .executionId(execution.getId()) - .executeSingleResult(commandContext); - - if(task != null && task.getAssignee() != null) - { - userName = task.getAssignee(); - } - } - } - - // When no task assignee is set, use system user to run job - if(userName == null) - { - userName = AuthenticationUtil.getSystemUserName(); - } - - // Execute timer + private JobHandler wrappedHandler; + + public AuthenticatedTimerJobHandler(JobHandler jobHandler) + { + if (jobHandler == null) + { + throw new IllegalArgumentException("JobHandler to delegate to is required"); + } + this.wrappedHandler = jobHandler; + } + + @Override + public void execute(final String configuration, final ExecutionEntity execution, + final CommandContext commandContext) + { + String userName = null; + + PvmActivity targetActivity = execution.getActivity(); + if (targetActivity != null) + { + // Only try getting active task, if execution timer is waiting on is a userTask + String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE); + if (ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType)) + { + Task task = new TaskQueryImpl(commandContext) + .executionId(execution.getId()) + .executeSingleResult(commandContext); + + if (task != null && task.getAssignee() != null) + { + userName = task.getAssignee(); + } + } + } + + // When no task assignee is set, use system user to run job + if (userName == null) + { + userName = AuthenticationUtil.getSystemUserName(); + } + +// Execute timer AuthenticationUtil.runAs(new RunAsWork() { @SuppressWarnings("synthetic-access") public Void doWork() throws Exception { - wrappedHandler.execute(configuration, execution, commandContext); - return null; + wrappedHandler.execute(configuration, execution, commandContext); + return null; } }, userName); - } - - @Override - public String getType() { - return wrappedHandler.getType(); - } + } + + @Override + public String getType() + { + return wrappedHandler.getType(); + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java b/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java index 5ade778619..e300c51d42 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java +++ b/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,6 +31,7 @@ import org.alfresco.service.ServiceRegistry; public abstract class BaseJavaDelegate implements JavaDelegate { private ServiceRegistry serviceRegistry; + /** * Get the service-registry from the current Activiti-context. * diff --git a/source/java/org/alfresco/repo/workflow/activiti/listener/ConvertDateToISO8601.java b/source/java/org/alfresco/repo/workflow/activiti/listener/ConvertDateToISO8601.java index eb3c79cc16..89eddae6d0 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/listener/ConvertDateToISO8601.java +++ b/source/java/org/alfresco/repo/workflow/activiti/listener/ConvertDateToISO8601.java @@ -34,10 +34,10 @@ import org.alfresco.util.ISO8601DateFormat; * will be written in field configured in "target". * * @author Frederik Heremans + * @since 4.0 */ public class ConvertDateToISO8601 implements ExecutionListener { - protected Expression source; protected Expression target; @@ -57,7 +57,7 @@ public class ConvertDateToISO8601 implements ExecutionListener String sourceVarName = getExpressionString(source, execution); String targetVarName = getExpressionString(target, execution); - if(sourceVarName == null || targetVarName == null) + if (sourceVarName == null || targetVarName == null) { throw new IllegalArgumentException("Both fields 'source' and 'target' shoudl be set"); } @@ -66,16 +66,23 @@ public class ConvertDateToISO8601 implements ExecutionListener Date dateToConvert = null; // Accept null, Date or Calendar as value - if(dateVar != null) { - if(dateVar instanceof Date) { - dateToConvert = (Date) execution.getVariable(sourceVarName); - } else if(dateVar instanceof Calendar) { - dateToConvert = ((Calendar) execution.getVariable(sourceVarName)).getTime(); - } else { - throw new IllegalArgumentException("Variable with name: " + sourceVarName + " must be a Date or a Calendar"); - } + if (dateVar != null) + { + if (dateVar instanceof Date) + { + dateToConvert = (Date) execution.getVariable(sourceVarName); + } + else if (dateVar instanceof Calendar) + { + dateToConvert = ((Calendar) execution.getVariable(sourceVarName)).getTime(); + } + else + { + throw new IllegalArgumentException("Variable with name: " + sourceVarName + " must be a Date or a Calendar"); + } } - if(dateToConvert != null) { + if (dateToConvert != null) + { // Convert the date to ISO-8601 format String convertedDate = ISO8601DateFormat.format(dateToConvert); execution.setVariable(targetVarName, convertedDate); @@ -84,7 +91,7 @@ public class ConvertDateToISO8601 implements ExecutionListener protected String getExpressionString(Expression expression, VariableScope variableScope) { - if(expression != null) + if (expression != null) { return (String) expression.getValue(variableScope); } diff --git a/source/java/org/alfresco/repo/workflow/activiti/listener/ProcessStartExecutionListener.java b/source/java/org/alfresco/repo/workflow/activiti/listener/ProcessStartExecutionListener.java index c72cdd4f83..6edbd78c9f 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/listener/ProcessStartExecutionListener.java +++ b/source/java/org/alfresco/repo/workflow/activiti/listener/ProcessStartExecutionListener.java @@ -30,15 +30,14 @@ import org.alfresco.repo.workflow.activiti.ActivitiConstants; * when process starts. * * @author Frederik Heremans + * @since 4.0 */ public class ProcessStartExecutionListener implements ExecutionListener { - public void notify(DelegateExecution execution) throws Exception { // Add the workflow ID execution.setVariable(WorkflowConstants.PROP_WORKFLOW_INSTANCE_ID, BPMEngineRegistry .createGlobalId(ActivitiConstants.ENGINE_ID, execution.getId())); - } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/listener/ScriptExecutionListener.java b/source/java/org/alfresco/repo/workflow/activiti/listener/ScriptExecutionListener.java index fa491e56b8..1506c3da8a 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/listener/ScriptExecutionListener.java +++ b/source/java/org/alfresco/repo/workflow/activiti/listener/ScriptExecutionListener.java @@ -43,37 +43,38 @@ import org.alfresco.service.cmr.repository.ScriptService; */ public class ScriptExecutionListener extends DelegateExecutionScriptBase implements ExecutionListener { + private static final String DELETED_FLAG = "deleted"; + private static final String CANCELLED_FLAG = "cancelled"; - private static final String DELETED_FLAG = "deleted"; - private static final String CANCELLED_FLAG = "cancelled"; - - @Override - public void notify(DelegateExecution execution) throws Exception { - runScript(execution); - } - - @Override - protected Map getInputMap(DelegateExecution execution, - String runAsUser) { - Map scriptModel = super.getInputMap(execution, runAsUser); - - ExecutionListenerExecution listenerExecution = (ExecutionListenerExecution) execution; - - // Add deleted/cancelled flags + @Override + public void notify(DelegateExecution execution) throws Exception + { + runScript(execution); + } + + @Override + protected Map getInputMap(DelegateExecution execution, + String runAsUser) + { + Map scriptModel = super.getInputMap(execution, runAsUser); + + ExecutionListenerExecution listenerExecution = (ExecutionListenerExecution) execution; + + // Add deleted/cancelled flags boolean cancelled = false; boolean deleted = false; - if(ActivitiConstants.DELETE_REASON_DELETED.equals(listenerExecution.getDeleteReason())) + if (ActivitiConstants.DELETE_REASON_DELETED.equals(listenerExecution.getDeleteReason())) { - deleted = true; + deleted = true; } - else if(ActivitiConstants.DELETE_REASON_CANCELLED.equals(listenerExecution.getDeleteReason())) + else if (ActivitiConstants.DELETE_REASON_CANCELLED.equals(listenerExecution.getDeleteReason())) { - cancelled = true; + cancelled = true; } scriptModel.put(DELETED_FLAG, deleted); scriptModel.put(CANCELLED_FLAG, cancelled); - return scriptModel; - } + return scriptModel; + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDescriptionPropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDescriptionPropertyHandler.java index 975324498a..6ae976403a 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDescriptionPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDescriptionPropertyHandler.java @@ -29,17 +29,14 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiDescriptionPropertyHandler extends ActivitiTaskPropertyHandler { - /** * {@inheritDoc} - */ - + */ @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { @@ -62,11 +59,9 @@ public class ActivitiDescriptionPropertyHandler extends ActivitiTaskPropertyHand /** * {@inheritDoc} */ - @Override protected QName getKey() { return WorkflowModel.PROP_DESCRIPTION; } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDueDatePropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDueDatePropertyHandler.java index 735dfd15ac..e1a42d6dd5 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDueDatePropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiDueDatePropertyHandler.java @@ -30,17 +30,14 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.5 * @author Frederik Heremans - * + * @since 4.0 */ public class ActivitiDueDatePropertyHandler extends ActivitiTaskPropertyHandler { - /** * {@inheritDoc} */ - @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { @@ -63,11 +60,9 @@ public class ActivitiDueDatePropertyHandler extends ActivitiTaskPropertyHandler /** * {@inheritDoc} */ - @Override protected QName getKey() { return WorkflowModel.PROP_DUE_DATE; } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiOwnerPropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiOwnerPropertyHandler.java index e208c056c7..843b1f5eb9 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiOwnerPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiOwnerPropertyHandler.java @@ -29,13 +29,11 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiOwnerPropertyHandler extends ActivitiTaskPropertyHandler { - /** * {@inheritDoc} */ @@ -68,11 +66,9 @@ public class ActivitiOwnerPropertyHandler extends ActivitiTaskPropertyHandler /** * {@inheritDoc} */ - @Override protected QName getKey() { return ContentModel.PROP_OWNER; } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPackagePropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPackagePropertyHandler.java index 2a49020c34..59362611f6 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPackagePropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPackagePropertyHandler.java @@ -31,9 +31,8 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiPackagePropertyHandler extends ActivitiTaskPropertyHandler { @@ -63,9 +62,9 @@ public class ActivitiPackagePropertyHandler extends ActivitiTaskPropertyHandler { Object currentPckg = runtimeService.getVariableLocal(processId, PCKG_KEY); // Do not change package if one already exists! - if(currentPckg == null) + if (currentPckg == null) { - if(value instanceof NodeRef) + if (value instanceof NodeRef) { return nodeConverter.convertNode((NodeRef)value); } @@ -80,7 +79,6 @@ public class ActivitiPackagePropertyHandler extends ActivitiTaskPropertyHandler /** * {@inheritDoc} */ - @Override protected QName getKey() { diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPooledActorsPropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPooledActorsPropertyHandler.java index 5037ac8bc9..3da0539cc6 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPooledActorsPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPooledActorsPropertyHandler.java @@ -41,9 +41,8 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiPooledActorsPropertyHandler extends ActivitiTaskPropertyHandler { @@ -77,11 +76,11 @@ public class ActivitiPooledActorsPropertyHandler extends ActivitiTaskPropertyHan @SuppressWarnings("unchecked") private Collection getNodes(Serializable value) { - if(value instanceof Collection) + if (value instanceof Collection) { return (Collection) value; } - if(value instanceof NodeRef) + if (value instanceof NodeRef) { return Collections.singletonList((NodeRef)value); } @@ -91,55 +90,55 @@ public class ActivitiPooledActorsPropertyHandler extends ActivitiTaskPropertyHan private void updateTaskCandidates(String taskId, UserAndGroupUpdates updates) { // Only new candidates are present in pooledUsers and pooledGroups, create Links for these - for(String user : updates.getUsers()) + for (String user : updates.getUsers()) { taskService.addCandidateUser(taskId, user); } - for(String group : updates.getGroups()) + for (String group : updates.getGroups()) { taskService.addCandidateGroup(taskId, group); } // Remove all candidates which have been removed - for(IdentityLink link : updates.getLinksToRemove()) + for (IdentityLink link : updates.getLinksToRemove()) { - if(link.getUserId() != null) - { - taskService.deleteUserIdentityLink(link.getTaskId(), - link.getUserId(), link.getType()); - } - else - { - taskService.deleteGroupIdentityLink(link.getTaskId(), - link.getGroupId(), link.getType()); - } + if (link.getUserId() != null) + { + taskService.deleteUserIdentityLink(link.getTaskId(), + link.getUserId(), link.getType()); + } + else + { + taskService.deleteGroupIdentityLink(link.getTaskId(), + link.getGroupId(), link.getType()); + } } } private void updateTaskCandidates(DelegateTask task, UserAndGroupUpdates updates) { // Only new candidates are present in pooledUsers and pooledGroups, create Links for these - for(String user : updates.getUsers()) + for (String user : updates.getUsers()) { task.addCandidateUser( user); } - for(String group : updates.getGroups()) + for (String group : updates.getGroups()) { task.addCandidateGroup( group); } // Remove all candidates which have been removed - for(IdentityLink link : updates.linksToRemove) + for (IdentityLink link : updates.linksToRemove) { - if(link.getUserId() != null) - { - task.deleteUserIdentityLink(link.getUserId(), link.getType()); - } - else - { - task.deleteGroupIdentityLink(link.getGroupId(), link.getType()); - } + if (link.getUserId() != null) + { + task.deleteUserIdentityLink(link.getUserId(), link.getType()); + } + else + { + task.deleteGroupIdentityLink(link.getGroupId(), link.getType()); + } } } @@ -169,11 +168,12 @@ public class ActivitiPooledActorsPropertyHandler extends ActivitiTaskPropertyHan List linksToRemove = new LinkedList(); for (IdentityLink link : links) { - if(IdentityLinkType.CANDIDATE.equals(link.getType())) { - String userId = link.getUserId(); - if(userId!=null) + if (IdentityLinkType.CANDIDATE.equals(link.getType())) + { + String userId = link.getUserId(); + if (userId != null) { - if(users.remove(userId)==false) + if (users.remove(userId)==false) { linksToRemove.add(link); } @@ -181,12 +181,12 @@ public class ActivitiPooledActorsPropertyHandler extends ActivitiTaskPropertyHan else { String groupId = link.getGroupId(); - if(groupId!=null && groups.remove(groupId)==false) + if (groupId != null && groups.remove(groupId) == false) { linksToRemove.add(link); } } - } + } } return new UserAndGroupUpdates(users, groups, linksToRemove); } @@ -254,5 +254,4 @@ public class ActivitiPooledActorsPropertyHandler extends ActivitiTaskPropertyHan return linksToRemove; } } - } diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java index 9bad185488..90aa2e4a0e 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java @@ -29,9 +29,8 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiPriorityPropertyHandler extends ActivitiTaskPropertyHandler { diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPropertyConverter.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPropertyConverter.java index f489896597..176db7eb91 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPropertyConverter.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPropertyConverter.java @@ -69,9 +69,8 @@ import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; /** - * @since 3.4.e * @author Nick Smith - * + * @since 3.4.e */ public class ActivitiPropertyConverter { @@ -117,7 +116,7 @@ public class ActivitiPropertyConverter Map localVariables = taskService.getVariablesLocal(task.getId()); Map variables = null; - if(!localOnly) + if (!localOnly) { variables = new HashMap(); variables.putAll(localVariables); @@ -125,9 +124,9 @@ public class ActivitiPropertyConverter // Execution-variables should also be added, if no value is present locally Map executionVariables = activitiUtil.getExecutionVariables(task.getExecutionId()); - for(Entry entry : executionVariables.entrySet()) + for (Entry entry : executionVariables.entrySet()) { - if(!localVariables.containsKey(entry.getKey())) + if (!localVariables.containsKey(entry.getKey())) { variables.put(entry.getKey(), entry.getValue()); } @@ -159,7 +158,7 @@ public class ActivitiPropertyConverter // Be sure to fetch the outcome String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME); - if(variables.get(outcomeVarName) != null) + if (variables.get(outcomeVarName) != null) { properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) variables.get(outcomeVarName)); } @@ -186,14 +185,14 @@ public class ActivitiPropertyConverter public List getPooledActorsReference(Collection links) { List pooledActorRefs = new ArrayList(); - if(links != null) + if (links != null) { - for(IdentityLink link : links) + for (IdentityLink link : links) { - if(IdentityLinkType.CANDIDATE.equals(link.getType())) + if (IdentityLinkType.CANDIDATE.equals(link.getType())) { String id = link.getGroupId(); - if(id == null) + if (id == null) { id = link.getUserId(); } @@ -228,7 +227,7 @@ public class ActivitiPropertyConverter Map localVariables = task.getVariablesLocal(); Map variables = null; - if(localOnly==false) + if (localOnly == false) { variables = new HashMap(); variables.putAll(localVariables); @@ -236,7 +235,7 @@ public class ActivitiPropertyConverter // Execution-variables should also be added, if no value is present locally Map executionVariables = task.getExecution().getVariables(); - for(Entry entry : executionVariables.entrySet()) + for (Entry entry : executionVariables.entrySet()) { String key = entry.getKey(); if(localVariables.containsKey(key)==false) @@ -308,7 +307,7 @@ public class ActivitiPropertyConverter // Be sure to fetch the outcome String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME); - if(variables.get(outcomeVarName) != null) + if (variables.get(outcomeVarName) != null) { properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) variables.get(outcomeVarName)); } @@ -316,15 +315,16 @@ public class ActivitiPropertyConverter // History of pooled actors is stored in task variable List pooledActors = new ArrayList(); List pooledActorRefIds = (List) variables.get(ActivitiConstants.PROP_POOLED_ACTORS_HISTORY); - if(pooledActorRefIds != null) + if (pooledActorRefIds != null) { - for(String nodeId : pooledActorRefIds) + for (String nodeId : pooledActorRefIds) { pooledActors.add(new NodeRef(nodeId)); } } + // Add pooled actors. When no actors are found, set empty list - properties.put(WorkflowModel.ASSOC_POOLED_ACTORS, (Serializable) pooledActors); + properties.put(WorkflowModel.ASSOC_POOLED_ACTORS, (Serializable) pooledActors); return filterTaskProperties(properties); } @@ -448,7 +448,7 @@ public class ActivitiPropertyConverter String wfDueDateKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_DUE_DATE); String dueDateKey = factory.mapQNameToName(WorkflowModel.PROP_DUE_DATE); Serializable dueDate = (Serializable) variables.get(wfDueDateKey); - if(dueDate == null) + if (dueDate == null) { dueDate = (Serializable) variables.get(dueDateKey); } @@ -460,7 +460,7 @@ public class ActivitiPropertyConverter // Use workflow priority at the time of starting the process String priorityKey = factory.mapQNameToName(WorkflowModel.PROP_PRIORITY); Serializable priority = (Serializable) variables.get(priorityKey); - if(priority == null) + if (priority == null) { String wfPriorityKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_PRIORITY); priority = (Serializable) variables.get(wfPriorityKey); @@ -471,12 +471,12 @@ public class ActivitiPropertyConverter // Use initiator username as owner ActivitiScriptNode ownerNode = (ActivitiScriptNode) variables.get(WorkflowConstants.PROP_INITIATOR); - if(ownerNode != null) + if (ownerNode != null) { properties.put(ContentModel.PROP_OWNER, (Serializable) ownerNode.getProperties().get("userName")); } - if(completed) + if (completed) { // Override default 'Not Yet Started' when start-task is completed properties.put(WorkflowModel.PROP_STATUS, WorkflowConstants.TASK_STATUS_COMPLETED); @@ -589,7 +589,7 @@ public class ActivitiPropertyConverter { return null; } - if(nodeConverter.isSupported(value)) + if (nodeConverter.isSupported(value)) { return nodeConverter.convert(value); } @@ -611,7 +611,7 @@ public class ActivitiPropertyConverter { TypeDefinition taskDef = typeManager.getFullTaskDefinition(task); PropertyDefinition propDef = taskDef.getProperties().get(propertyName); - if(propDef != null) + if (propDef != null) { return (Serializable) DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value); } @@ -622,7 +622,7 @@ public class ActivitiPropertyConverter private Map getNewTaskProperties(Task task, Map properties, Map> add, Map> remove) { - // create properties to set on task instance + // create properties to set on task instance Map newProperties = properties; if (add != null || remove != null) @@ -694,11 +694,12 @@ public class ActivitiPropertyConverter public void setTaskProperties(DelegateTask task, Map properties) { - if(properties==null || properties.isEmpty()) + if (properties==null || properties.isEmpty()) return; + TypeDefinition type = typeManager.getFullTaskDefinition(task); Map variablesToSet = handlerRegistry.handleVariablesToSet(properties, type, task, DelegateTask.class); - if(variablesToSet.size() > 0) + if (variablesToSet.size() > 0) { task.setVariablesLocal(variablesToSet); } @@ -710,7 +711,7 @@ public class ActivitiPropertyConverter */ public void setTaskProperties(Task task, Map properties) { - if(properties==null || properties.isEmpty()) + if (properties == null || properties.isEmpty()) return; TypeDefinition type = typeManager.getFullTaskDefinition(task); @@ -744,7 +745,7 @@ public class ActivitiPropertyConverter String currentAssignee = task.getAssignee(); // Only set the assignee if the value has changes to prevent // triggering assignementhandlers when not needed - if (ObjectUtils.equals(currentAssignee, assignee)==false) + if (ObjectUtils.equals(currentAssignee, assignee) == false) { activitiUtil.getTaskService().setAssignee(task.getId(), assignee); } @@ -764,8 +765,9 @@ public class ActivitiPropertyConverter * @return filtered properties. */ private Map filterTaskProperties( - Map properties) { - if(properties != null) + Map properties) + { + if (properties != null) { properties.remove(QName.createQName(null, ActivitiConstants.PROP_POOLED_ACTORS_HISTORY)); properties.remove(QName.createQName(null, ActivitiConstants.PROP_TASK_FORM_KEY)); @@ -791,11 +793,11 @@ public class ActivitiPropertyConverter } }); Map variables = new HashMap(); - for(HistoricDetail detail : details) + for (HistoricDetail detail : details) { HistoricVariableUpdate varUpdate = (HistoricVariableUpdate) detail; // First value for a single key is used - if(!variables.containsKey(varUpdate.getVariableName())) + if (!variables.containsKey(varUpdate.getVariableName())) { variables.put(varUpdate.getVariableName(), varUpdate.getValue()); } @@ -833,7 +835,7 @@ public class ActivitiPropertyConverter // Special case for task description default value // Use the shared description set in the workflowinstance String description = (String) defaultProperties.get(WorkflowModel.PROP_DESCRIPTION); - if(description == null) + if (description == null) { String wfDescription = (String) defaultProperties.get(WorkflowModel.PROP_WORKFLOW_DESCRIPTION); String procDefKey = procDef.getKey(); @@ -910,7 +912,7 @@ public class ActivitiPropertyConverter private boolean isMandatory(ClassAttributeDefinition definition) { - if(definition instanceof PropertyDefinition) + if (definition instanceof PropertyDefinition) { PropertyDefinition propDef = (PropertyDefinition) definition; return propDef.isMandatory(); @@ -925,7 +927,7 @@ public class ActivitiPropertyConverter */ private boolean isEmptyString(Object value) { - if(value instanceof String) + if (value instanceof String) { String str = (String)value; return str.isEmpty(); diff --git a/source/java/org/alfresco/repo/workflow/activiti/script/ActivitiScriptBase.java b/source/java/org/alfresco/repo/workflow/activiti/script/ActivitiScriptBase.java index 2106185128..5ff1691d85 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/script/ActivitiScriptBase.java +++ b/source/java/org/alfresco/repo/workflow/activiti/script/ActivitiScriptBase.java @@ -41,147 +41,156 @@ import org.alfresco.service.cmr.workflow.WorkflowException; * @author Frederik Heremans * @since 3.4.e */ -public class ActivitiScriptBase { +public class ActivitiScriptBase +{ + protected static final String PERSON_BINDING_NAME = "person"; + protected static final String USERHOME_BINDING_NAME = "userhome"; + protected static final String EXECUTION_BINDING_NAME = "execution"; - protected static final String PERSON_BINDING_NAME = "person"; - protected static final String USERHOME_BINDING_NAME = "userhome"; - protected static final String EXECUTION_BINDING_NAME = "execution"; - - protected Expression script; - protected Expression runAs; - protected Expression scriptProcessor; - - protected Object executeScript(String theScript, Map model, String scriptProcessorName, String runAsUser) + protected Expression script; + protected Expression runAs; + protected Expression scriptProcessor; + + protected Object executeScript(String theScript, Map model, String scriptProcessorName, String runAsUser) { - String user = AuthenticationUtil.getFullyAuthenticatedUser(); - - Object scriptResult = null; - if(runAsUser == null && user != null) - { - // Just execute the script using the current user - scriptResult = executeScript(theScript, model, scriptProcessorName); - } - else { - if(runAsUser != null) - { - // Check if the user used for running exists - validateRunAsUser(runAsUser); - } - else - { - // No current user is authenticated, use the system-user to execute the script - runAsUser = AuthenticationUtil.getSystemUserName(); - } - executeScriptAsUser(theScript, model, scriptProcessorName, runAsUser); - } - return scriptResult; + String user = AuthenticationUtil.getFullyAuthenticatedUser(); + + Object scriptResult = null; + if (runAsUser == null && user != null) + { + // Just execute the script using the current user + scriptResult = executeScript(theScript, model, scriptProcessorName); + } + else + { + if (runAsUser != null) + { + // Check if the user used for running exists + validateRunAsUser(runAsUser); + } + else + { + // No current user is authenticated, use the system-user to execute the script + runAsUser = AuthenticationUtil.getSystemUserName(); + } + executeScriptAsUser(theScript, model, scriptProcessorName, runAsUser); + } + return scriptResult; } protected Object executeScriptAsUser(final String theScript, final Map model, final String scriptProcessorName, final String runAsUser) { - // execute as specified runAsUser - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() throws Exception - { - return executeScript(theScript, model, scriptProcessorName); - } - }, runAsUser); + // execute as specified runAsUser + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() throws Exception + { + return executeScript(theScript, model, scriptProcessorName); + } + }, runAsUser); } protected Object executeScript(String theScript, Map model, String scriptProcessorName) { - // Execute the script using the appropriate processor - Object scriptResult = null; - if(scriptProcessorName != null) - { - scriptResult = getServiceRegistry().getScriptService().executeScriptString(scriptProcessorName, theScript, model); - } - else - { - // Use default script-processor - scriptResult = getServiceRegistry().getScriptService().executeScriptString(theScript, model); - } - - return scriptResult; + // Execute the script using the appropriate processor + Object scriptResult = null; + if (scriptProcessorName != null) + { + scriptResult = getServiceRegistry().getScriptService().executeScriptString(scriptProcessorName, theScript, model); + } + else + { + // Use default script-processor + scriptResult = getServiceRegistry().getScriptService().executeScriptString(theScript, model); + } + + return scriptResult; } - protected String getStringValue(Expression expression, VariableScope scope) { - if(expression != null) - { - return (String) expression.getValue(scope); - } - return null; - } + protected String getStringValue(Expression expression, VariableScope scope) + { + if (expression != null) + { + return (String) expression.getValue(scope); + } + return null; + } - protected ServiceRegistry getServiceRegistry() - { - ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); - if(config != null) - { - // Fetch the registry that is injected in the activiti spring-configuration - ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); - if(registry == null) - { - throw new RuntimeException( - "Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + - ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); - } - return registry; - } - throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context"); - } - - /** - * Checks that the specified 'runAs' field - * specifies a valid username. - */ - private void validateRunAsUser(final String runAsUser) { - Boolean runAsExists = AuthenticationUtil.runAs(new RunAsWork() - { // Validate using System user to ensure sufficient permissions available to access person node. - - public Boolean doWork() throws Exception { - return getServiceRegistry().getPersonService().personExists(runAsUser); - } - }, AuthenticationUtil.getSystemUserName()); - if (!runAsExists) - { - throw new WorkflowException("runas user '" + runAsUser + "' does not exist."); - } - } + protected ServiceRegistry getServiceRegistry() + { + ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); + if (config != null) + { + // Fetch the registry that is injected in the activiti spring-configuration + ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); + if (registry == null) + { + throw new RuntimeException( + "Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + + ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY); + } + return registry; + } + throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context"); + } + + /** + * Checks that the specified 'runAs' field + * specifies a valid username. + */ + private void validateRunAsUser(final String runAsUser) + { + Boolean runAsExists = AuthenticationUtil.runAs(new RunAsWork() + { + // Validate using System user to ensure sufficient permissions available to access person node. + + public Boolean doWork() throws Exception + { + return getServiceRegistry().getPersonService().personExists(runAsUser); + } + }, AuthenticationUtil.getSystemUserName()); + + if (!runAsExists) + { + throw new WorkflowException("runas user '" + runAsUser + "' does not exist."); + } + } protected ActivitiScriptNode getPersonNode(String runAsUser) { - String userName = null; - if(runAsUser != null) - { - userName = runAsUser; - } - else - { - userName = AuthenticationUtil.getFullyAuthenticatedUser(); - } - if(userName != null) - { - ServiceRegistry services = getServiceRegistry(); - NodeRef person = services.getPersonService().getPerson(userName); - if(person !=null) - { - return new ActivitiScriptNode(person, services); - } - } - return null; + String userName = null; + if (runAsUser != null) + { + userName = runAsUser; + } + else + { + userName = AuthenticationUtil.getFullyAuthenticatedUser(); + } + if (userName != null) + { + ServiceRegistry services = getServiceRegistry(); + NodeRef person = services.getPersonService().getPerson(userName); + if(person !=null) + { + return new ActivitiScriptNode(person, services); + } + } + return null; } - public void setScript(Expression script) { - this.script = script; - } + public void setScript(Expression script) + { + this.script = script; + } - public void setRunAs(Expression runAs) { - this.runAs = runAs; - } + public void setRunAs(Expression runAs) + { + this.runAs = runAs; + } - public void setScriptProcessor(Expression scriptProcessor) { - this.scriptProcessor = scriptProcessor; - } + public void setScriptProcessor(Expression scriptProcessor) + { + this.scriptProcessor = scriptProcessor; + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/script/AlfrescoScriptDelegate.java b/source/java/org/alfresco/repo/workflow/activiti/script/AlfrescoScriptDelegate.java index 5e75e47391..660db674db 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/script/AlfrescoScriptDelegate.java +++ b/source/java/org/alfresco/repo/workflow/activiti/script/AlfrescoScriptDelegate.java @@ -33,12 +33,13 @@ import org.alfresco.service.cmr.repository.ScriptService; * currently logged in (eg. flow triggered by timer) the system user will be used instead. * * @author Frederik Heremans - * @since 3.5 + * @since 4.0 */ -public class AlfrescoScriptDelegate extends DelegateExecutionScriptBase implements JavaDelegate { - - @Override - public void execute(DelegateExecution execution) throws Exception { - runScript(execution); - } +public class AlfrescoScriptDelegate extends DelegateExecutionScriptBase implements JavaDelegate +{ + @Override + public void execute(DelegateExecution execution) throws Exception + { + runScript(execution); + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/script/DelegateExecutionScriptBase.java b/source/java/org/alfresco/repo/workflow/activiti/script/DelegateExecutionScriptBase.java index feaf198337..850b0b492e 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/script/DelegateExecutionScriptBase.java +++ b/source/java/org/alfresco/repo/workflow/activiti/script/DelegateExecutionScriptBase.java @@ -39,70 +39,71 @@ import org.alfresco.service.namespace.NamespaceService; * {@link DelegateExecution} context. * * @author Frederik Heremans - * + * @since 4.0 */ -public class DelegateExecutionScriptBase extends ActivitiScriptBase { - - /** - * Run the script that is configured, using the given execution. - */ - protected void runScript(DelegateExecution execution) throws Exception { - if(script != null) +public class DelegateExecutionScriptBase extends ActivitiScriptBase +{ + /** + * Run the script that is configured, using the given execution. + */ + protected void runScript(DelegateExecution execution) throws Exception + { + if (script != null) { - String scriptString = getStringValue(script, execution); - String scriptProcessorName = getStringValue(scriptProcessor, execution); - String runAsUser = getStringValue(runAs, execution); - - // Make sure there is an authenticated user for the current thread, so when - // the script is executed using no 'runAs' from a job-executor thread, the workflow - // owner us used - boolean clearAuthenticationContext = checkFullyAuthenticatedUser(execution); - - // Get all activiti-defined objects - Map scriptModel = getInputMap(execution, runAsUser); - - // Add core alfresco objects to the input-map - getServiceRegistry().getScriptService().buildCoreModel(scriptModel); - - try - { - Object scriptOutput = executeScript(scriptString, scriptModel, scriptProcessorName, runAsUser); - - // TODO: What to do with the script-output? - if(scriptOutput != null) - { - // delegateTask.setVariableLocal("scriptOutput", scriptOutput); - } - } - finally - { - if(clearAuthenticationContext) - { - // If the current user has been set to the Task's assignee, we should clear it agian - AuthenticationUtil.clearCurrentSecurityContext(); - } - } + String scriptString = getStringValue(script, execution); + String scriptProcessorName = getStringValue(scriptProcessor, execution); + String runAsUser = getStringValue(runAs, execution); + + // Make sure there is an authenticated user for the current thread, so when + // the script is executed using no 'runAs' from a job-executor thread, the workflow + // owner us used + boolean clearAuthenticationContext = checkFullyAuthenticatedUser(execution); + + // Get all activiti-defined objects + Map scriptModel = getInputMap(execution, runAsUser); + + // Add core alfresco objects to the input-map + getServiceRegistry().getScriptService().buildCoreModel(scriptModel); + + try + { + Object scriptOutput = executeScript(scriptString, scriptModel, scriptProcessorName, runAsUser); + + // TODO: What to do with the script-output? + if (scriptOutput != null) + { + // delegateTask.setVariableLocal("scriptOutput", scriptOutput); + } + } + finally + { + if (clearAuthenticationContext) + { + // If the current user has been set to the Task's assignee, we should clear it agian + AuthenticationUtil.clearCurrentSecurityContext(); + } + } } else { - throw new IllegalArgumentException("The field 'script' should be set on the TaskListener"); + throw new IllegalArgumentException("The field 'script' should be set on the TaskListener"); } - } - - protected Map getInputMap(DelegateExecution execution, String runAsUser) - { - HashMap scriptModel = new HashMap(1); + } + + protected Map getInputMap(DelegateExecution execution, String runAsUser) + { + HashMap scriptModel = new HashMap(1); // Add current logged-in user and it's user home ActivitiScriptNode personNode = getPersonNode(runAsUser); - if(personNode != null) + if (personNode != null) { - ServiceRegistry registry = getServiceRegistry(); - scriptModel.put(PERSON_BINDING_NAME, personNode); - NodeRef userHomeNode = (NodeRef) registry.getNodeService().getProperty(personNode.getNodeRef(), ContentModel.PROP_HOMEFOLDER); + ServiceRegistry registry = getServiceRegistry(); + scriptModel.put(PERSON_BINDING_NAME, personNode); + NodeRef userHomeNode = (NodeRef) registry.getNodeService().getProperty(personNode.getNodeRef(), ContentModel.PROP_HOMEFOLDER); if (userHomeNode != null) { - scriptModel.put(USERHOME_BINDING_NAME, new ActivitiScriptNode(userHomeNode, registry)); + scriptModel.put(USERHOME_BINDING_NAME, new ActivitiScriptNode(userHomeNode, registry)); } } @@ -112,35 +113,35 @@ public class DelegateExecutionScriptBase extends ActivitiScriptBase { // Add all workflow variables to model Map variables = execution.getVariables(); - for(Entry varEntry : variables.entrySet()) + for (Entry varEntry : variables.entrySet()) { - scriptModel.put(varEntry.getKey(), varEntry.getValue()); + scriptModel.put(varEntry.getKey(), varEntry.getValue()); } return scriptModel; - } - - /** - * Checks a valid Fully Authenticated User is set. - * If none is set then attempts to set the workflow owner - * @param execution the execution - * @return true if the Fully Authenticated User was changed, otherwise false. - */ - private boolean checkFullyAuthenticatedUser(final DelegateExecution execution) { - if(AuthenticationUtil.getFullyAuthenticatedUser() == null) - { - NamespaceService namespaceService = getServiceRegistry().getNamespaceService(); - WorkflowQNameConverter qNameConverter = new WorkflowQNameConverter(namespaceService); - String ownerVariableName = qNameConverter.mapQNameToName(ContentModel.PROP_OWNER); - - String userName = (String) execution.getVariable(ownerVariableName); - if (userName != null) - { - AuthenticationUtil.setFullyAuthenticatedUser(userName); - return true; - } - } - return false; - } + } + /** + * Checks a valid Fully Authenticated User is set. + * If none is set then attempts to set the workflow owner + * @param execution the execution + * @return true if the Fully Authenticated User was changed, otherwise false. + */ + private boolean checkFullyAuthenticatedUser(final DelegateExecution execution) + { + if (AuthenticationUtil.getFullyAuthenticatedUser() == null) + { + NamespaceService namespaceService = getServiceRegistry().getNamespaceService(); + WorkflowQNameConverter qNameConverter = new WorkflowQNameConverter(namespaceService); + String ownerVariableName = qNameConverter.mapQNameToName(ContentModel.PROP_OWNER); + + String userName = (String) execution.getVariable(ownerVariableName); + if (userName != null) + { + AuthenticationUtil.setFullyAuthenticatedUser(userName); + return true; + } + } + return false; + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/tasklistener/ScriptTaskListener.java b/source/java/org/alfresco/repo/workflow/activiti/tasklistener/ScriptTaskListener.java index ce33e19523..364f7f5e19 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/tasklistener/ScriptTaskListener.java +++ b/source/java/org/alfresco/repo/workflow/activiti/tasklistener/ScriptTaskListener.java @@ -53,63 +53,63 @@ public class ScriptTaskListener extends ActivitiScriptBase implements TaskListen @Override public void notify(DelegateTask delegateTask) { - if(script != null) + if (script != null) { - String scriptString = getStringValue(script, delegateTask); - String scriptProcessorName = getStringValue(scriptProcessor, delegateTask); - String runAsUser = getStringValue(runAs, delegateTask); - - - // Make sure there is an authenticated user for the current thread, so when - // the script is executed using no 'runAs' from a job-executor thread, the task's assignee - // will be the authenticated user. - boolean clearAuthenticationContext = checkFullyAuthenticatedUser(delegateTask); - - // Get all activiti-defined objects - Map scriptModel = getInputMap(delegateTask, runAsUser); - - // Add core alfresco objects to the input-map - getServiceRegistry().getScriptService().buildCoreModel(scriptModel); - - try - { - Object scriptOutput = executeScript(scriptString, scriptModel, scriptProcessorName, runAsUser); - - // TODO: What to do with the script-output? - if(scriptOutput != null) - { - // delegateTask.setVariableLocal("scriptOutput", scriptOutput); - } - } - finally - { - if(clearAuthenticationContext) - { - // If the current user has been set to the Task's assignee, we should clear it agian - AuthenticationUtil.clearCurrentSecurityContext(); - } - } + String scriptString = getStringValue(script, delegateTask); + String scriptProcessorName = getStringValue(scriptProcessor, delegateTask); + String runAsUser = getStringValue(runAs, delegateTask); + + + // Make sure there is an authenticated user for the current thread, so when + // the script is executed using no 'runAs' from a job-executor thread, the task's assignee + // will be the authenticated user. + boolean clearAuthenticationContext = checkFullyAuthenticatedUser(delegateTask); + + // Get all activiti-defined objects + Map scriptModel = getInputMap(delegateTask, runAsUser); + + // Add core alfresco objects to the input-map + getServiceRegistry().getScriptService().buildCoreModel(scriptModel); + + try + { + Object scriptOutput = executeScript(scriptString, scriptModel, scriptProcessorName, runAsUser); + + // TODO: What to do with the script-output? + if (scriptOutput != null) + { + // delegateTask.setVariableLocal("scriptOutput", scriptOutput); + } + } + finally + { + if (clearAuthenticationContext) + { + // If the current user has been set to the Task's assignee, we should clear it agian + AuthenticationUtil.clearCurrentSecurityContext(); + } + } } else { - throw new IllegalArgumentException("The field 'script' should be set on the TaskListener"); + throw new IllegalArgumentException("The field 'script' should be set on the TaskListener"); } } - protected Map getInputMap(DelegateTask delegateTask, String runAsUser) - { - HashMap scriptModel = new HashMap(1); + protected Map getInputMap(DelegateTask delegateTask, String runAsUser) + { + HashMap scriptModel = new HashMap(1); // Add current logged-in user and it's user home ActivitiScriptNode personNode = getPersonNode(runAsUser); - if(personNode != null) + if (personNode != null) { - ServiceRegistry registry = getServiceRegistry(); - scriptModel.put(PERSON_BINDING_NAME, personNode); - NodeRef userHomeNode = (NodeRef) registry.getNodeService().getProperty(personNode.getNodeRef(), ContentModel.PROP_HOMEFOLDER); + ServiceRegistry registry = getServiceRegistry(); + scriptModel.put(PERSON_BINDING_NAME, personNode); + NodeRef userHomeNode = (NodeRef) registry.getNodeService().getProperty(personNode.getNodeRef(), ContentModel.PROP_HOMEFOLDER); if (userHomeNode != null) { - scriptModel.put(USERHOME_BINDING_NAME, new ActivitiScriptNode(userHomeNode, registry)); + scriptModel.put(USERHOME_BINDING_NAME, new ActivitiScriptNode(userHomeNode, registry)); } } @@ -120,29 +120,30 @@ public class ScriptTaskListener extends ActivitiScriptBase implements TaskListen // Add all workflow variables to model Map variables = delegateTask.getExecution().getVariables(); - for(Entry varEntry : variables.entrySet()) + for (Entry varEntry : variables.entrySet()) { - scriptModel.put(varEntry.getKey(), varEntry.getValue()); + scriptModel.put(varEntry.getKey(), varEntry.getValue()); } - return scriptModel; - } - - /** - * Checks a valid Fully Authenticated User is set. - * If none is set then attempts to set the task assignee as the Fully Authenticated User. - * @param delegateTask the delegate task - * @return true if the Fully Authenticated User was changed, otherwise false. - */ - private boolean checkFullyAuthenticatedUser(final DelegateTask delegateTask) { - if(AuthenticationUtil.getFullyAuthenticatedUser() == null) - { - String userName = delegateTask.getAssignee(); - if (userName != null) - { - AuthenticationUtil.setFullyAuthenticatedUser(userName); - return true; - } - } - return false; - } + return scriptModel; + } + + /** + * Checks a valid Fully Authenticated User is set. + * If none is set then attempts to set the task assignee as the Fully Authenticated User. + * @param delegateTask the delegate task + * @return true if the Fully Authenticated User was changed, otherwise false. + */ + private boolean checkFullyAuthenticatedUser(final DelegateTask delegateTask) + { + if (AuthenticationUtil.getFullyAuthenticatedUser() == null) + { + String userName = delegateTask.getAssignee(); + if (userName != null) + { + AuthenticationUtil.setFullyAuthenticatedUser(userName); + return true; + } + } + return false; + } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/tasklistener/TaskCompleteListener.java b/source/java/org/alfresco/repo/workflow/activiti/tasklistener/TaskCompleteListener.java index 2d6fec5cd5..81a0235df8 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/tasklistener/TaskCompleteListener.java +++ b/source/java/org/alfresco/repo/workflow/activiti/tasklistener/TaskCompleteListener.java @@ -53,10 +53,10 @@ public class TaskCompleteListener implements TaskListener @Override public void notify(DelegateTask task) { - // Check all mandatory properties are set. This is checked here instead of in - // the completeTask() to allow taskListeners to set variable values before checking - propertyConverter.checkMandatoryProperties(task); - + // Check all mandatory properties are set. This is checked here instead of in + // the completeTask() to allow taskListeners to set variable values before checking + propertyConverter.checkMandatoryProperties(task); + // Set properties for ended task Map endTaskVariables = new HashMap(); @@ -72,26 +72,26 @@ public class TaskCompleteListener implements TaskListener } private void addPooledActorsAsVariable(DelegateTask task, - Map variables) { - - List links = ((TaskEntity)task).getIdentityLinks(); - if(links.size() > 0) + Map variables) + { + List links = ((TaskEntity)task).getIdentityLinks(); + if (links.size() > 0) { - // Add to list of IdentityLink - List identityLinks = new ArrayList(); - identityLinks.addAll(links); - - List pooledActorRefs = propertyConverter.getPooledActorsReference(identityLinks); - - // Save references as a variable - List nodeIds = new ArrayList(); - for(NodeRef ref : pooledActorRefs) - { - nodeIds.add(ref.toString()); - } - variables.put(ActivitiConstants.PROP_POOLED_ACTORS_HISTORY, nodeIds); + // Add to list of IdentityLink + List identityLinks = new ArrayList(); + identityLinks.addAll(links); + + List pooledActorRefs = propertyConverter.getPooledActorsReference(identityLinks); + + // Save references as a variable + List nodeIds = new ArrayList(); + for (NodeRef ref : pooledActorRefs) + { + nodeIds.add(ref.toString()); + } + variables.put(ActivitiConstants.PROP_POOLED_ACTORS_HISTORY, nodeIds); } - } + } public void setNamespaceService(NamespaceService namespaceService) { diff --git a/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeListVariableType.java b/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeListVariableType.java index e6faa6f667..50129fe4fd 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeListVariableType.java +++ b/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeListVariableType.java @@ -60,7 +60,7 @@ public class ScriptNodeListVariableType extends SerializableType @Override public boolean isAbleToStore(Object value) { - if(value == null) + if (value == null) { return true; } @@ -70,9 +70,9 @@ public class ScriptNodeListVariableType extends SerializableType @Override public void setValue(Object value, ValueFields valueFields) { - if(value != null) + if (value != null) { - if(!(value instanceof ActivitiScriptNodeList)) + if (!(value instanceof ActivitiScriptNodeList)) { throw new ActivitiException("Passed value is not an instance of ActivitiScriptNodeList, cannot set variable value."); } @@ -89,12 +89,12 @@ public class ScriptNodeListVariableType extends SerializableType public Object getValue(ValueFields valueFields) { Object serializable = super.getValue(valueFields); - if(serializable == null) + if (serializable == null) { return null; } - if(!(serializable instanceof List)) + if (!(serializable instanceof List)) { throw new ActivitiException("Serializable stored in variable is not instance of List, cannot get value."); } @@ -102,7 +102,7 @@ public class ScriptNodeListVariableType extends SerializableType ActivitiScriptNodeList scriptNodes = new ActivitiScriptNodeList(); // Wrap all node references in an ActivitiScriptNode List nodeRefs =(List) serializable; - for(NodeRef ref : nodeRefs) + for (NodeRef ref : nodeRefs) { scriptNodes.add(new ActivitiScriptNode(ref, serviceRegistry)); } diff --git a/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeVariableType.java b/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeVariableType.java index 067f3b9349..3371e78315 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeVariableType.java +++ b/source/java/org/alfresco/repo/workflow/activiti/variable/ScriptNodeVariableType.java @@ -58,7 +58,7 @@ public class ScriptNodeVariableType implements VariableType @Override public boolean isAbleToStore(Object value) { - if(value == null) + if (value == null) { return true; } @@ -69,14 +69,14 @@ public class ScriptNodeVariableType implements VariableType public void setValue(Object value, ValueFields valueFields) { String textValue = null; - if(value != null) + if (value != null) { - if(!(value instanceof ActivitiScriptNode)) + if (!(value instanceof ActivitiScriptNode)) { throw new ActivitiException("Passed value is not an instance of ActivitiScriptNode, cannot set variable value."); } NodeRef reference = (((ActivitiScriptNode)value).getNodeRef()); - if(reference != null) + if (reference != null) { // Use the string representation of the NodeRef textValue = reference.toString(); @@ -90,7 +90,7 @@ public class ScriptNodeVariableType implements VariableType { ScriptNode scriptNode = null; String nodeRefString = valueFields.getTextValue(); - if(nodeRefString != null) + if (nodeRefString != null) { scriptNode = new ActivitiScriptNode(new NodeRef(nodeRefString), serviceRegistry); } diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScript.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScript.java index f44f26a282..aa8eeaadb3 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScript.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScript.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -109,99 +109,108 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler } } - private Object executeExpression(String expression, ExecutionContext executionContext, List variableAccesses) { - boolean userChanged = checkFullyAuthenticatedUser(executionContext); - Object result = executeScript(expression, executionContext, variableAccesses); - if(userChanged) - { - AuthenticationUtil.clearCurrentSecurityContext(); - } - return result; - } - - private Object executeScript(String expression, - ExecutionContext executionContext, - List variableAccesses) - { - String user = AuthenticationUtil.getFullyAuthenticatedUser(); - if (runas == null && user !=null) - { - return executeScript(executionContext, services, expression, variableAccesses, companyHome); - } - else + private Object executeExpression(String expression, ExecutionContext executionContext, List variableAccesses) + { + boolean userChanged = checkFullyAuthenticatedUser(executionContext); + Object result = executeScript(expression, executionContext, variableAccesses); + if(userChanged) { - String runAsUser = runas; - if(runAsUser == null) - { - runAsUser = AuthenticationUtil.getSystemUserName(); - } else - { - validateRunAsUser(); - } - return executeScriptAs(runAsUser, expression, executionContext, variableAccesses); + AuthenticationUtil.clearCurrentSecurityContext(); } - } + return result; + } - private Object executeScriptAs(String runAsUser, - final String expression, - final ExecutionContext executionContext, - final List variableAccesses) { - // execute as specified runAsUser - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public Object doWork() throws Exception - { - return executeScript(executionContext, services, expression, variableAccesses,companyHome); - } - }, runAsUser); - } + private Object executeScript(String expression, + ExecutionContext executionContext, + List variableAccesses) + { + String user = AuthenticationUtil.getFullyAuthenticatedUser(); + if (runas == null && user !=null) + { + return executeScript(executionContext, services, expression, variableAccesses, companyHome); + } + else + { + String runAsUser = runas; + if(runAsUser == null) + { + runAsUser = AuthenticationUtil.getSystemUserName(); + } + else + { + validateRunAsUser(); + } + return executeScriptAs(runAsUser, expression, executionContext, variableAccesses); + } + } - /** - * Checks a valid Fully Authenticated User is set. - * If none is set then attempts to set the task assignee as the Fully Authenticated User. - * @param executionContext - * @return true if the Fully Authenticated User was changes, otherwise false. - */ - private boolean checkFullyAuthenticatedUser(final ExecutionContext executionContext) { - if(AuthenticationUtil.getFullyAuthenticatedUser()!= null) - return false; - TaskInstance taskInstance = executionContext.getTaskInstance(); - if(taskInstance!=null) - { - String userName = taskInstance.getActorId(); - if (userName != null) - { - AuthenticationUtil.setFullyAuthenticatedUser(userName); - return true; - } - } - return false; - } + private Object executeScriptAs(String runAsUser, + final String expression, + final ExecutionContext executionContext, + final List variableAccesses) + { + // execute as specified runAsUser + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public Object doWork() throws Exception + { + return executeScript(executionContext, services, expression, variableAccesses,companyHome); + } + }, runAsUser); + } - /** - * Checks that the specified 'runas' field - * specifies a valid username. - */ - private void validateRunAsUser() { - Boolean runAsExists = AuthenticationUtil.runAs(new RunAsWork() - { // Validate using System user to ensure sufficient permissions available to access person node. - - public Boolean doWork() throws Exception { - return services.getPersonService().personExists(runas); - } - }, AuthenticationUtil.getSystemUserName()); - if (!runAsExists) - { - throw new WorkflowException("runas user '" + runas + "' does not exist."); - } - } + /** + * Checks a valid Fully Authenticated User is set. + * If none is set then attempts to set the task assignee as the Fully Authenticated User. + * @param executionContext + * @return true if the Fully Authenticated User was changes, otherwise false. + */ + private boolean checkFullyAuthenticatedUser(final ExecutionContext executionContext) + { + if(AuthenticationUtil.getFullyAuthenticatedUser()!= null) + return false; + + TaskInstance taskInstance = executionContext.getTaskInstance(); + if(taskInstance!=null) + { + String userName = taskInstance.getActorId(); + if (userName != null) + { + AuthenticationUtil.setFullyAuthenticatedUser(userName); + return true; + } + } + return false; + } + + /** + * Checks that the specified 'runas' field + * specifies a valid username. + */ + private void validateRunAsUser() + { + Boolean runAsExists = AuthenticationUtil.runAs(new RunAsWork() + { + // Validate using System user to ensure sufficient permissions available to access person node. + + public Boolean doWork() throws Exception + { + return services.getPersonService().personExists(runas); + } + }, AuthenticationUtil.getSystemUserName()); + if (!runAsExists) + { + throw new WorkflowException("runas user '" + runas + "' does not exist."); + } + } /** * Gets the expression {@link String} from the script. * @param isTextOnly Is the script text only or is it XML? * @return the expression {@link String}. */ - private String getExpression(boolean isTextOnly) { + private String getExpression(boolean isTextOnly) + { if (isTextOnly) { return script.getText().trim(); @@ -215,26 +224,28 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler } return expressionElement.getText().trim(); } - } + } - @SuppressWarnings("unchecked") - private List getVariableAccessors(boolean isTextOnly) { - if(isTextOnly) + @SuppressWarnings("unchecked") + private List getVariableAccessors(boolean isTextOnly) + { + if (isTextOnly) { - return null; + return null; } else { - return jpdlReader.readVariableAccesses(script); + return jpdlReader.readVariableAccesses(script); } - } + } /** * Is the script specified as text only, or as explicit expression, variable elements * @return */ - @SuppressWarnings("unchecked") - private boolean isScriptOnlyText() { + @SuppressWarnings("unchecked") + private boolean isScriptOnlyText() + { Iterator iter = script.elementIterator(); while (iter.hasNext()) { @@ -244,8 +255,8 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler return false; } } - return true; - } + return true; + } /** @@ -358,7 +369,7 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler inputMap.put("executionContext", executionContext); inputMap.put("token", token); Node node = executionContext.getNode(); - if (node != null) + if (node != null) { inputMap.put("node", node); } @@ -368,7 +379,7 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler inputMap.put("task", task); } TaskInstance taskInstance = executionContext.getTaskInstance(); - if (taskInstance != null) + if (taskInstance != null) { inputMap.put("taskInstance", taskInstance); } @@ -408,16 +419,16 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler } - private static NodeRef getPersonNode(ServiceRegistry services) { - String userName = AuthenticationUtil.getFullyAuthenticatedUser(); - if(userName != null) - { - NodeRef person = services.getPersonService().getPerson(userName); - return person; - } - return null; - } - + private static NodeRef getPersonNode(ServiceRegistry services) + { + String userName = AuthenticationUtil.getFullyAuthenticatedUser(); + if (userName != null) + { + NodeRef person = services.getPersonService().getPerson(userName); + return person; + } + return null; + } /** * Determine if there are variables to read from the process context @@ -467,12 +478,13 @@ public class AlfrescoJavaScript extends JBPMSpringActionHandler return writable; } - public void setScript(Element script) { - this.script = script; - } - - public void setRunas(String runas) { - this.runas = runas; - } + public void setScript(Element script) + { + this.script = script; + } + public void setRunas(String runas) + { + this.runas = runas; + } } diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScriptIntegrationTest.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScriptIntegrationTest.java index a8b95a99f5..c88c026aca 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScriptIntegrationTest.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJavaScriptIntegrationTest.java @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2005-2011 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.workflow.jbpm; import static org.mockito.Matchers.any; @@ -39,123 +57,127 @@ import org.mockito.stubbing.Answer; public class AlfrescoJavaScriptIntegrationTest extends BaseAlfrescoSpringTest { - private static final QName fooName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "Foo"); - private static final QName barName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "Bar"); - private static final QName docName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "Doc"); - private static final String BASIC_USER = "basic"+GUID.generate(); - private static String systemUser = AuthenticationUtil.getSystemUserName(); - - private ServiceRegistry services; - private ExecutionContext context; - private HashMap variables; - private PersonService personService; + private static final QName fooName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "Foo"); + private static final QName barName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "Bar"); + private static final QName docName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "Doc"); + private static final String BASIC_USER = "basic"+GUID.generate(); + private static String systemUser = AuthenticationUtil.getSystemUserName(); + + private ServiceRegistry services; + private ExecutionContext context; + private HashMap variables; + private PersonService personService; private Repository repository; - /** - * Test that JavaScript can still be run even if no Authentication is provided. - * This can occur if, e.g. the action is executed as part of an asynchronous task. - * @throws Exception - */ - public void testRunsWithoutAuthentication() throws Exception { - NodeRef systemNode = personService.getPerson(systemUser); - NodeRef baseUserNode = personService.getPerson(BASIC_USER); - TestUserStore userStore = new TestUserStore(); - variables.put("userStore", userStore); - Element script = buildScript("userStore.storeUsers(person)"); - - // Check authentication cleared. - AuthenticationUtil.clearCurrentSecurityContext(); - assertNull(AuthenticationUtil.getFullyAuthenticatedUser()); - assertNull(AuthenticationUtil.getRunAsUser()); - - // Check uses system user when no authentication set and no task assignee. - AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); - scriptHandler.setScript(script); - scriptHandler.execute(context); - assertEquals(systemUser, userStore.runAsUser); - assertEquals(systemUser, userStore.fullUser); - assertEquals(systemNode, userStore.person.getNodeRef()); + /** + * Test that JavaScript can still be run even if no Authentication is provided. + * This can occur if, e.g. the action is executed as part of an asynchronous task. + * @throws Exception + */ + public void testRunsWithoutAuthentication() throws Exception + { + NodeRef systemNode = personService.getPerson(systemUser); + NodeRef baseUserNode = personService.getPerson(BASIC_USER); + TestUserStore userStore = new TestUserStore(); + variables.put("userStore", userStore); + Element script = buildScript("userStore.storeUsers(person)"); + + // Check authentication cleared. + AuthenticationUtil.clearCurrentSecurityContext(); + assertNull(AuthenticationUtil.getFullyAuthenticatedUser()); + assertNull(AuthenticationUtil.getRunAsUser()); + + // Check uses system user when no authentication set and no task assignee. + AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); + scriptHandler.setScript(script); + scriptHandler.execute(context); + assertEquals(systemUser, userStore.runAsUser); + assertEquals(systemUser, userStore.fullUser); + assertEquals(systemNode, userStore.person.getNodeRef()); + + // Check authentication is correctly reset. + assertNull(AuthenticationUtil.getFullyAuthenticatedUser()); + assertNull(AuthenticationUtil.getRunAsUser()); + + // Check that when a task assignee exists, then he/she is used for authentication. + TaskInstance taskInstance = mock(TaskInstance.class); + when(taskInstance.getActorId()).thenReturn(BASIC_USER); + when(context.getTaskInstance()).thenReturn(taskInstance); + scriptHandler = new AlfrescoJavaScript(); + scriptHandler.setScript(script); + scriptHandler.execute(context); + assertEquals(BASIC_USER, userStore.runAsUser); + assertEquals(BASIC_USER, userStore.fullUser); + assertEquals(baseUserNode, userStore.person.getNodeRef()); + + // Check authentication is correctly reset. + assertNull(AuthenticationUtil.getFullyAuthenticatedUser()); + assertNull(AuthenticationUtil.getRunAsUser()); + } - // Check authentication is correctly reset. - assertNull(AuthenticationUtil.getFullyAuthenticatedUser()); - assertNull(AuthenticationUtil.getRunAsUser()); + /** + * See Jira issue ALF-657. + * @throws Exception + */ + public void testRunAsAdminMoveContent() throws Exception + { + NodeRef fooFolder = nodeService.createNode(rootNodeRef, + ContentModel.ASSOC_CONTAINS, + fooName, + ContentModel.TYPE_FOLDER).getChildRef(); + + NodeRef barFolder = nodeService.createNode(rootNodeRef, + ContentModel.ASSOC_CONTAINS, + barName, + ContentModel.TYPE_FOLDER).getChildRef(); + + NodeRef doc = nodeService.createNode(fooFolder, + ContentModel.ASSOC_CONTAINS, + docName, + ContentModel.TYPE_CONTENT).getChildRef(); + PermissionService permissions = services.getPermissionService(); + permissions.setPermission(doc, BASIC_USER, PermissionService.ALL_PERMISSIONS, true); + AuthenticationUtil.setFullyAuthenticatedUser(BASIC_USER); + + Element script = buildScript("doc.move(bar)"); + + variables.put("doc", new JBPMNode(doc, services)); + variables.put("bar", new JBPMNode(barFolder, services)); + assertEquals(fooFolder, nodeService.getPrimaryParent(doc).getParentRef()); + try + { + AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); + scriptHandler.setScript(script); + scriptHandler.execute(context); + fail("The user should not have permission to write to bar!"); + } + catch (ScriptException e) + { + // Do nothing. + } + + assertEquals(fooFolder, nodeService.getPrimaryParent(doc).getParentRef()); + + AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); + scriptHandler.setScript(script); + scriptHandler.setRunas(AuthenticationUtil.getAdminUserName()); + scriptHandler.execute(context); + assertEquals(barFolder, nodeService.getPrimaryParent(doc).getParentRef()); + } + + /** + * See Jira issue ALF-5346. + * @throws Exception + */ + public void testRunAsAdminMoveContentBetweenSites() throws Exception + { + SiteService siteService = services.getSiteService(); + FileFolderService fileFolderService = services.getFileFolderService(); - // Check that when a task assignee exists, then he/she is used for authentication. - TaskInstance taskInstance = mock(TaskInstance.class); - when(taskInstance.getActorId()).thenReturn(BASIC_USER); - when(context.getTaskInstance()).thenReturn(taskInstance); - scriptHandler = new AlfrescoJavaScript(); - scriptHandler.setScript(script); - scriptHandler.execute(context); - assertEquals(BASIC_USER, userStore.runAsUser); - assertEquals(BASIC_USER, userStore.fullUser); - assertEquals(baseUserNode, userStore.person.getNodeRef()); - - // Check authentication is correctly reset. - assertNull(AuthenticationUtil.getFullyAuthenticatedUser()); - assertNull(AuthenticationUtil.getRunAsUser()); - } - - /** - * See Jira issue ALF-657. - * @throws Exception - */ - public void testRunAsAdminMoveContent() throws Exception { - NodeRef fooFolder = nodeService.createNode(rootNodeRef, - ContentModel.ASSOC_CONTAINS, - fooName, - ContentModel.TYPE_FOLDER).getChildRef(); - - NodeRef barFolder = nodeService.createNode(rootNodeRef, - ContentModel.ASSOC_CONTAINS, - barName, - ContentModel.TYPE_FOLDER).getChildRef(); - - NodeRef doc = nodeService.createNode(fooFolder, - ContentModel.ASSOC_CONTAINS, - docName, - ContentModel.TYPE_CONTENT).getChildRef(); - PermissionService permissions = services.getPermissionService(); - permissions.setPermission(doc, BASIC_USER, PermissionService.ALL_PERMISSIONS, true); - AuthenticationUtil.setFullyAuthenticatedUser(BASIC_USER); + String siteAName = "siteA"+GUID.generate(); + String siteBName = "siteB"+GUID.generate(); - Element script = buildScript("doc.move(bar)"); - - variables.put("doc", new JBPMNode(doc, services)); - variables.put("bar", new JBPMNode(barFolder, services)); - assertEquals(fooFolder, nodeService.getPrimaryParent(doc).getParentRef()); - try - { - AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); - scriptHandler.setScript(script); - scriptHandler.execute(context); - fail("The user should not have permission to write to bar!"); - } catch(ScriptException e) - { - // Do nothing. - } - - assertEquals(fooFolder, nodeService.getPrimaryParent(doc).getParentRef()); - - AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); - scriptHandler.setScript(script); - scriptHandler.setRunas(AuthenticationUtil.getAdminUserName()); - scriptHandler.execute(context); - assertEquals(barFolder, nodeService.getPrimaryParent(doc).getParentRef()); - } - - /** - * See Jira issue ALF-5346. - * @throws Exception - */ - public void testRunAsAdminMoveContentBetweenSites() throws Exception { - SiteService siteService = services.getSiteService(); - FileFolderService fileFolderService = services.getFileFolderService(); - - String siteAName = "siteA"+GUID.generate(); - String siteBName = "siteB"+GUID.generate(); - - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); siteService.createSite( "testSitePreset", siteAName, "title", "description", SiteVisibility.PRIVATE); @@ -171,38 +193,38 @@ public class AlfrescoJavaScriptIntegrationTest extends BaseAlfrescoSpringTest ContentWriter writer = fileFolderService.getWriter(doc); writer.putContent("Just some old content that doesn't mean anything"); - AuthenticationUtil.setFullyAuthenticatedUser(BASIC_USER); - - Element script = buildScript("doc.move(companyhome.childByNamePath(\"Sites/"+ siteBName +"/documentLibrary\"))"); - - NodeRef companyHome = repository.getCompanyHome(); - variables.put("companyhome", new JBPMNode(companyHome, services)); - variables.put("doc", new JBPMNode(doc, services)); - assertEquals(docLibA, nodeService.getPrimaryParent(doc).getParentRef()); - try - { - AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); - scriptHandler.setScript(script); - scriptHandler.execute(context); - fail("The user should not have permission to write to Site B!"); - } catch(ScriptException e) - { - // Do nothing. - } - - assertEquals(docLibA, nodeService.getPrimaryParent(doc).getParentRef()); - - AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); - scriptHandler.setScript(script); - scriptHandler.setRunas(AuthenticationUtil.getAdminUserName()); - scriptHandler.execute(context); - assertEquals(docLibB, nodeService.getPrimaryParent(doc).getParentRef()); - } + AuthenticationUtil.setFullyAuthenticatedUser(BASIC_USER); + + Element script = buildScript("doc.move(companyhome.childByNamePath(\"Sites/"+ siteBName +"/documentLibrary\"))"); + + NodeRef companyHome = repository.getCompanyHome(); + variables.put("companyhome", new JBPMNode(companyHome, services)); + variables.put("doc", new JBPMNode(doc, services)); + assertEquals(docLibA, nodeService.getPrimaryParent(doc).getParentRef()); + try + { + AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); + scriptHandler.setScript(script); + scriptHandler.execute(context); + fail("The user should not have permission to write to Site B!"); + } catch(ScriptException e) + { + // Do nothing. + } + + assertEquals(docLibA, nodeService.getPrimaryParent(doc).getParentRef()); + + AlfrescoJavaScript scriptHandler = new AlfrescoJavaScript(); + scriptHandler.setScript(script); + scriptHandler.setRunas(AuthenticationUtil.getAdminUserName()); + scriptHandler.execute(context); + assertEquals(docLibB, nodeService.getPrimaryParent(doc).getParentRef()); + } - public void testScopeVariables() throws Exception + public void testScopeVariables() throws Exception { - String admin = AuthenticationUtil.getAdminUserName(); - AuthenticationUtil.setFullyAuthenticatedUser(admin); + String admin = AuthenticationUtil.getAdminUserName(); + AuthenticationUtil.setFullyAuthenticatedUser(admin); NodeRef person = personService.getPerson(admin); Serializable userHome = nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER); @@ -231,31 +253,33 @@ public class AlfrescoJavaScriptIntegrationTest extends BaseAlfrescoSpringTest value = (ScriptNode) variables.get(key); assertEquals(companyHome, value.getNodeRef()); } - - private Element buildScript(String expression) { - Element script = DocumentHelper.createElement("script"); - script.setText(expression); - return script; - } - @Override - @SuppressWarnings("deprecation") - protected void onSetUp() throws Exception { - super.onSetUp(); - - this.services = (ServiceRegistry) applicationContext.getBean("ServiceRegistry"); - repository = (Repository) applicationContext.getBean("repositoryHelper"); - personService = services.getPersonService(); - createUser(BASIC_USER); - - // Sets up the Execution Context - context = mock(ExecutionContext.class); - ContextInstance contextInstance = mock(ContextInstance.class); - when(context.getContextInstance()).thenReturn(contextInstance); - variables = new HashMap(); - when(contextInstance.getVariables()).thenReturn(variables); - when(contextInstance.getVariables( any(Token.class))).thenReturn(variables); - when(context.getVariable(anyString())).thenAnswer(new Answer() + private Element buildScript(String expression) + { + Element script = DocumentHelper.createElement("script"); + script.setText(expression); + return script; + } + + @Override + @SuppressWarnings("deprecation") + protected void onSetUp() throws Exception + { + super.onSetUp(); + + this.services = (ServiceRegistry) applicationContext.getBean("ServiceRegistry"); + repository = (Repository) applicationContext.getBean("repositoryHelper"); + personService = services.getPersonService(); + createUser(BASIC_USER); + + // Sets up the Execution Context + context = mock(ExecutionContext.class); + ContextInstance contextInstance = mock(ContextInstance.class); + when(context.getContextInstance()).thenReturn(contextInstance); + variables = new HashMap(); + when(contextInstance.getVariables()).thenReturn(variables); + when(contextInstance.getVariables( any(Token.class))).thenReturn(variables); + when(context.getVariable(anyString())).thenAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { @@ -263,7 +287,7 @@ public class AlfrescoJavaScriptIntegrationTest extends BaseAlfrescoSpringTest return variables.get(key); } }); - doAnswer(new Answer() + doAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { @@ -273,8 +297,8 @@ public class AlfrescoJavaScriptIntegrationTest extends BaseAlfrescoSpringTest return null; } }).when(context).setVariable(anyString(), any()); - } - + } + private void createUser(String userName) { if (this.authenticationService.authenticationExists(userName) == false) @@ -291,16 +315,17 @@ public class AlfrescoJavaScriptIntegrationTest extends BaseAlfrescoSpringTest } } - public static class TestUserStore { - private String runAsUser; - private String fullUser; - private ScriptNode person = null; - - public void storeUsers(ScriptNode user) - { - fullUser = AuthenticationUtil.getFullyAuthenticatedUser(); - runAsUser = AuthenticationUtil.getRunAsUser(); - this.person = user; - } + public static class TestUserStore + { + private String runAsUser; + private String fullUser; + private ScriptNode person = null; + + public void storeUsers(ScriptNode user) + { + fullUser = AuthenticationUtil.getFullyAuthenticatedUser(); + runAsUser = AuthenticationUtil.getRunAsUser(); + this.person = user; + } } } diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java index 6f2a9f71b1..f3e0691c33 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -82,7 +82,7 @@ public class AlfrescoTimer extends Timer && taskInstance.isOpen()) { taskInstance.setSignalling(false); - taskInstance.end(); + taskInstance.end(); } return deleteTimer; } diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java index 15f1cadf54..db9bf05e77 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -786,10 +786,10 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine { throw getStartWorkflowException(workflowDefinitionId, e); } - catch (DataAccessException e) - { - throw getStartWorkflowException(workflowDefinitionId, e); - } + catch (DataAccessException e) + { + throw getStartWorkflowException(workflowDefinitionId, e); + } } private WorkflowException getStartWorkflowException(final String workflowDefinitionId, Exception e) @@ -1859,21 +1859,21 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine private Object[] getProcessIds(List processList) { - ArrayList ids = new ArrayList(processList.size()); - if (processList.isEmpty()) - { - ids.add(new Long(-1)); - } - else - { - for (Object obj : processList) - { - ProcessInstance instance = (ProcessInstance) obj; - ids.add(instance.getId()); - } - } - return ids.toArray(); - } + ArrayList ids = new ArrayList(processList.size()); + if (processList.isEmpty()) + { + ids.add(new Long(-1)); + } + else + { + for (Object obj : processList) + { + ProcessInstance instance = (ProcessInstance) obj; + ids.add(instance.getId()); + } + } + return ids.toArray(); + } /** * Create process-specific query criteria @@ -1999,7 +1999,7 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine return (WorkflowTask) jbpmTemplate.execute(new JbpmCallback() { @SuppressWarnings("unchecked") - public Object doInJbpm(JbpmContext context) + public Object doInJbpm(JbpmContext context) { // retrieve task TaskMgmtSession taskSession = context.getTaskMgmtSession(); @@ -2443,11 +2443,11 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine @SuppressWarnings("unchecked") protected Map getTaskProperties(TaskInstance instance, boolean localProperties, Map variablesCache) { - // retrieve type definition for task + // retrieve type definition for task TypeDefinition taskDef = getFullTaskDefinition(instance); Map taskProperties = taskDef.getProperties(); Map taskAssocs = taskDef.getAssociations(); - + // build properties from jBPM context (visit all tokens to the root) Map vars = instance.getVariablesLocally(); if (!localProperties) @@ -2492,8 +2492,8 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine boolean isAssoc = taskAssocs.containsKey(qname); if (taskProperties.containsKey(qname) || isAssoc || instance.hasVariableLocally(key)) { - Serializable value = convertValue(entry.getValue()); - properties.put(qname, value); + Serializable value = convertValue(entry.getValue()); + properties.put(qname, value); } } @@ -2654,7 +2654,7 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine Session session = context.getSession(); for (Object obj: comments) { - Comment comment = (Comment) obj; + Comment comment = (Comment) obj; comment.getToken().getComments().remove(comment); session.delete(comment); } @@ -2975,7 +2975,7 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine * @return JBPMNodeList or JBPMNode */ @SuppressWarnings("unchecked") - private Serializable convertNodeRefs(boolean isMany, Serializable value) + private Serializable convertNodeRefs(boolean isMany, Serializable value) { if (value instanceof NodeRef) { @@ -3395,11 +3395,11 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine TaskInstance taskInstance = timer.getTaskInstance(); if (taskInstance != null) { - workflowTask = createWorkflowTask(taskInstance); + workflowTask = createWorkflowTask(taskInstance); } return factory.createWorkflowTimer(new Long(timer.getId()).toString(), timer.getName(), - timer.getException(), timer.getDueDate(), path, workflowTask); + timer.getException(), timer.getDueDate(), path, workflowTask); } /** diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java index 3dee83c622..ff1df20906 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -174,8 +174,8 @@ public class JBPMEngineTest extends BaseAlfrescoSpringTest assertEquals(path.getInstance().getId(), instance.getId()); workflowComponent.cancelWorkflow(instance.getId()); - WorkflowInstance result = workflowComponent.getWorkflowById(instance.getId()); - assertNull("The workflow isntance should be null!", result); + WorkflowInstance result = workflowComponent.getWorkflowById(instance.getId()); + assertNull("The workflow isntance should be null!", result); } @@ -330,7 +330,7 @@ public class JBPMEngineTest extends BaseAlfrescoSpringTest public void testCancelWorkflowInstance() throws Exception { - WorkflowDefinition workflowDef = getTestDefinition(); + WorkflowDefinition workflowDef = getTestDefinition(); workflowComponent.startWorkflow(workflowDef.getId(), null); List instances1 = workflowComponent.getActiveWorkflows(workflowDef.getId()); assertNotNull(instances1); diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JbpmWorkflowServiceIntegrationTest.java b/source/java/org/alfresco/repo/workflow/jbpm/JbpmWorkflowServiceIntegrationTest.java index e6b96718d9..97d4eef5cc 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JbpmWorkflowServiceIntegrationTest.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JbpmWorkflowServiceIntegrationTest.java @@ -139,15 +139,15 @@ public class JbpmWorkflowServiceIntegrationTest extends AbstractWorkflowServiceI return "alfresco/workflow/parallelreview_processdefinition.xml"; } - @Override - protected String getTestTimerDefinitionPath() - { - return "jbpmresources/test_timer.xml"; - } + @Override + protected String getTestTimerDefinitionPath() + { + return "jbpmresources/test_timer.xml"; + } - @Override - protected QName getAdhocProcessName() - { - return QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "adhoc"); - } + @Override + protected QName getAdhocProcessName() + { + return QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "adhoc"); + } } diff --git a/source/java/org/alfresco/service/cmr/blog/BlogService.java b/source/java/org/alfresco/service/cmr/blog/BlogService.java index d4f072aa87..72d4070dc5 100644 --- a/source/java/org/alfresco/service/cmr/blog/BlogService.java +++ b/source/java/org/alfresco/service/cmr/blog/BlogService.java @@ -54,8 +54,7 @@ public interface BlogService * * @see SiteService#getContainer(String, String) to retrieve the blogContainerNode */ - BlogPostInfo createBlogPost(NodeRef blogContainerNode, String blogTitle, - String blogContent, boolean isDraft); + BlogPostInfo createBlogPost(NodeRef blogContainerNode, String blogTitle, String blogContent, boolean isDraft); /** * Gets the draft blog posts created by the specified user. diff --git a/source/java/org/alfresco/service/cmr/calendar/CalendarEntry.java b/source/java/org/alfresco/service/cmr/calendar/CalendarEntry.java index 8addac1676..300172c0e5 100644 --- a/source/java/org/alfresco/service/cmr/calendar/CalendarEntry.java +++ b/source/java/org/alfresco/service/cmr/calendar/CalendarEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,7 +31,8 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Burch * @since 4.0 */ -public interface CalendarEntry extends Serializable, PermissionCheckValue { +public interface CalendarEntry extends Serializable, PermissionCheckValue +{ /** * @return the NodeRef of the underlying calendar entry */ diff --git a/source/java/org/alfresco/service/cmr/calendar/CalendarEntryDTO.java b/source/java/org/alfresco/service/cmr/calendar/CalendarEntryDTO.java index f416ed51d9..e189e2d473 100644 --- a/source/java/org/alfresco/service/cmr/calendar/CalendarEntryDTO.java +++ b/source/java/org/alfresco/service/cmr/calendar/CalendarEntryDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -32,7 +32,8 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Burch * @since 4.0 */ -public class CalendarEntryDTO implements CalendarEntry, Serializable { +public class CalendarEntryDTO implements CalendarEntry, Serializable +{ private static final long serialVersionUID = -7997650453677545845L; private NodeRef nodeRef; @@ -281,7 +282,7 @@ public class CalendarEntryDTO implements CalendarEntry, Serializable { */ public static boolean isAllDay(CalendarEntry entry) { - if(entry.getStart() == null || entry.getEnd() == null) + if (entry.getStart() == null || entry.getEnd() == null) { // One or both dates is missing return false; @@ -292,12 +293,12 @@ public class CalendarEntryDTO implements CalendarEntry, Serializable { start.setTime(entry.getStart()); end.setTime(entry.getEnd()); - if(start.get(Calendar.HOUR_OF_DAY) == 0 && - start.get(Calendar.MINUTE) == 0 && - start.get(Calendar.SECOND) == 0 && - end.get(Calendar.HOUR_OF_DAY) == 0 && - end.get(Calendar.MINUTE) == 0 && - end.get(Calendar.SECOND) == 0) + if (start.get(Calendar.HOUR_OF_DAY) == 0 && + start.get(Calendar.MINUTE) == 0 && + start.get(Calendar.SECOND) == 0 && + end.get(Calendar.HOUR_OF_DAY) == 0 && + end.get(Calendar.MINUTE) == 0 && + end.get(Calendar.SECOND) == 0) { // Both midnight, counts as all day return true; diff --git a/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java b/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java index 027456c7fb..2938a486ba 100644 --- a/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java +++ b/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -46,7 +46,8 @@ public class CalendarRecurrenceHelper private static Log logger = LogFactory.getLog(CalendarRecurrenceHelper.class); private static Map d2cd; - static { + static + { d2cd = new HashMap(); d2cd.put("SU", Calendar.SUNDAY); d2cd.put("MO", Calendar.MONDAY); @@ -56,6 +57,7 @@ public class CalendarRecurrenceHelper d2cd.put("FR", Calendar.FRIDAY); d2cd.put("SA", Calendar.SATURDAY); } + /** * The lookup from the day strings to Calendar Day entries */ @@ -90,6 +92,7 @@ public class CalendarRecurrenceHelper { return extractRecurrenceRule(entry.getRecurrenceRule()); } + /** * Returns the parsed calendar recurrence rule * WARNING - Alfresco use only. Return type will likely shift to @@ -97,17 +100,17 @@ public class CalendarRecurrenceHelper */ private static Map extractRecurrenceRule(String recurrenceRule) { - if(recurrenceRule == null) + if (recurrenceRule == null) { return null; } // Turn the string into a useful map Map params = new HashMap(); - for(String rule : recurrenceRule.split(";")) + for (String rule : recurrenceRule.split(";")) { String[] parts = rule.split("="); - if(parts.length != 2) + if (parts.length != 2) { logger.warn("Invalid rule '" + rule + "' in recurrence: " + recurrenceRule); } @@ -133,8 +136,7 @@ public class CalendarRecurrenceHelper { return getRecurrencesOnOrAfter( entry.getRecurrenceRule(), entry.getStart(), entry.getEnd(), - entry.getLastRecurrence(), onOrAfter, until, firstOnly - ); + entry.getLastRecurrence(), onOrAfter, until, firstOnly); } /** @@ -149,7 +151,7 @@ public class CalendarRecurrenceHelper Date eventEnd, Date lastRecurrence, Date onOrAfter, Date until, boolean firstOnly) { - if(recurrenceRule == null) + if (recurrenceRule == null) { // No recurrence return null; @@ -157,22 +159,22 @@ public class CalendarRecurrenceHelper // See if we're past the last recurrence date // Note - we rely on this being set for us, rather than checking the count - if(lastRecurrence != null && lastRecurrence.before(onOrAfter)) + if (lastRecurrence != null && lastRecurrence.before(onOrAfter)) { // Recurrence has stopped by this point return null; } // Work until the earlier of the last event and the limit - if(lastRecurrence != null) + if (lastRecurrence != null) { - if(until == null) + if (until == null) { until = lastRecurrence; } else { - if(lastRecurrence.before(until)) + if (lastRecurrence.before(until)) { // Last recurrence is earlier, use that until = lastRecurrence; @@ -181,7 +183,7 @@ public class CalendarRecurrenceHelper } // Safety limit - don't recurse for ever! - if(lastRecurrence == null && !firstOnly && until == null) + if (lastRecurrence == null && !firstOnly && until == null) { logger.info("No end date set on the recurring event, and no end date " + "specified, only fetching first instance"); @@ -193,12 +195,12 @@ public class CalendarRecurrenceHelper // Handle the different frequencies Map params = extractRecurrenceRule(recurrenceRule); - if(params.containsKey("FREQ")) + if (params.containsKey("FREQ")) { String freq = params.get("FREQ"); String intervalS = params.get("INTERVAL"); int interval = 1; - if(intervalS != null) + if (intervalS != null) { try { @@ -248,17 +250,17 @@ public class CalendarRecurrenceHelper Map params, Date onOrAfter, Date until, boolean firstOnly, int interval) { // Nice and easy - while(currentDate.getTime().before(onOrAfter)) + while (currentDate.getTime().before(onOrAfter)) { currentDate.add(Calendar.DATE, 1); } - if(firstOnly) + if (firstOnly) { // Save the first date, if valid - if(until != null) + if (until != null) { - if(currentDate.getTime().before(until)) + if (currentDate.getTime().before(until)) { dates.add(currentDate.getTime()); } @@ -271,7 +273,7 @@ public class CalendarRecurrenceHelper else { // Run until the end - while(currentDate.getTime().before(until)) + while (currentDate.getTime().before(until)) { dates.add(currentDate.getTime()); currentDate.add(Calendar.DATE, 1); @@ -284,10 +286,10 @@ public class CalendarRecurrenceHelper { // Get a sorted list of the days it applies to List daysOfWeek = new ArrayList(); - for(String dayS : params.get("BYDAY").split(",")) + for (String dayS : params.get("BYDAY").split(",")) { Integer day = DAY_NAMES_TO_CALENDAR_DAYS.get(dayS); - if(day == null) + if (day == null) { logger.warn("Invalid day " + dayS); } @@ -302,19 +304,19 @@ public class CalendarRecurrenceHelper boolean going = true; boolean valid = false; Date origDate = currentDate.getTime(); - while(going) + while (going) { // Check each day - for(int day : daysOfWeek) + for (int day : daysOfWeek) { currentDate.set(Calendar.DAY_OF_WEEK, day); - if(!valid) + if (!valid) { - if(currentDate.getTime().before(onOrAfter)) + if (currentDate.getTime().before(onOrAfter)) { // To early } - else if(currentDate.getTime().before(origDate)) + else if (currentDate.getTime().before(origDate)) { // Too early } @@ -324,11 +326,11 @@ public class CalendarRecurrenceHelper valid = true; } } - if(valid) + if (valid) { - if(until != null) + if (until != null) { - if(currentDate.getTime().after(until)) + if (currentDate.getTime().after(until)) { // Too late going = false; @@ -336,7 +338,7 @@ public class CalendarRecurrenceHelper } } dates.add(currentDate.getTime()); - if(firstOnly) + if (firstOnly) { going = false; break; @@ -357,7 +359,7 @@ public class CalendarRecurrenceHelper { // eg the 15th of each month int dayOfMonth = Integer.parseInt(params.get("BYMONTHDAY")); - if(currentDate.get(Calendar.DAY_OF_MONTH) > dayOfMonth) + if (currentDate.get(Calendar.DAY_OF_MONTH) > dayOfMonth) { // Move forward to start of the next month addMonthToDayOfMonth(currentDate, dayOfMonth); @@ -369,15 +371,15 @@ public class CalendarRecurrenceHelper } // Go until in the ok range - while(currentDate.getTime().before(onOrAfter)) + while (currentDate.getTime().before(onOrAfter)) { addMonthToDayOfMonth(currentDate, dayOfMonth); } - while(true) + while (true) { - if(until != null) + if (until != null) { - if(currentDate.getTime().after(until)) + if (currentDate.getTime().after(until)) { break; } @@ -396,38 +398,38 @@ public class CalendarRecurrenceHelper { // eg the first Thursday of the month int dayOfWeek = DAY_NAMES_TO_CALENDAR_DAYS.get(params.get("BYSETPOS")); - if(currentDate.get(Calendar.DAY_OF_MONTH) > 8) + if (currentDate.get(Calendar.DAY_OF_MONTH) > 8) { // Move to start, in next month addMonthToFirstDayOfWeek(currentDate, dayOfWeek); } - else if(currentDate.get(Calendar.DAY_OF_WEEK) != dayOfWeek) + else if (currentDate.get(Calendar.DAY_OF_WEEK) != dayOfWeek) { // Move forward to start Date t = currentDate.getTime(); currentDate.set(Calendar.DAY_OF_WEEK, dayOfWeek); - if(currentDate.getTime().before(t)) + if (currentDate.getTime().before(t)) { currentDate.add(Calendar.DATE, 7); } } - while(currentDate.getTime().before(onOrAfter)) + while (currentDate.getTime().before(onOrAfter)) { addMonthToFirstDayOfWeek(currentDate, dayOfWeek); } - while(true) + while (true) { - if(until != null) + if (until != null) { - if(currentDate.getTime().after(until)) + if (currentDate.getTime().after(until)) { break; } } dates.add(currentDate.getTime()); - if(firstOnly) + if (firstOnly) { break; } @@ -446,7 +448,7 @@ public class CalendarRecurrenceHelper { // eg the 2nd of March every year int dayOfMonth = Integer.parseInt(params.get("BYMONTHDAY")); - if(currentDate.get(Calendar.MONTH) == month && + if (currentDate.get(Calendar.MONTH) == month && currentDate.get(Calendar.DAY_OF_MONTH) == dayOfMonth) { // Correct start time @@ -458,24 +460,24 @@ public class CalendarRecurrenceHelper currentDate.set(Calendar.DAY_OF_MONTH, dayOfMonth); } - while(currentDate.getTime().before(onOrAfter)) + while (currentDate.getTime().before(onOrAfter)) { currentDate.set(Calendar.YEAR, currentDate.get(Calendar.YEAR) + 1); currentDate.set(Calendar.MONTH, month); currentDate.set(Calendar.DAY_OF_MONTH, dayOfMonth); } - while(true) + while (true) { - if(until != null) + if (until != null) { - if(currentDate.getTime().after(until)) + if (currentDate.getTime().after(until)) { break; } } dates.add(currentDate.getTime()); - if(firstOnly) + if (firstOnly) { break; } @@ -493,7 +495,6 @@ public class CalendarRecurrenceHelper } } - private static void addMonthToDayOfMonth(Calendar c, int dayOfMonth) { // Set it to the 1st @@ -503,6 +504,7 @@ public class CalendarRecurrenceHelper // Set to the requred day in the month c.set(Calendar.DAY_OF_MONTH, dayOfMonth); } + private static void addMonthToFirstDayOfWeek(Calendar c, int dayOfWeek) { // Go forward to the 1st of next month @@ -512,7 +514,7 @@ public class CalendarRecurrenceHelper Date t = c.getTime(); c.set(Calendar.DAY_OF_WEEK, dayOfWeek); // If we went back, go forward a week - if(c.getTime().before(t)) + if (c.getTime().before(t)) { c.add(Calendar.DATE, 7); } diff --git a/source/java/org/alfresco/service/cmr/calendar/CalendarService.java b/source/java/org/alfresco/service/cmr/calendar/CalendarService.java index 1501c540a7..5169187233 100644 --- a/source/java/org/alfresco/service/cmr/calendar/CalendarService.java +++ b/source/java/org/alfresco/service/cmr/calendar/CalendarService.java @@ -30,7 +30,8 @@ import org.alfresco.service.NotAuditable; * @author Nick Burch * @since 4.0 */ -public interface CalendarService { +public interface CalendarService +{ /** * Stores a new {@link CalendarEntry} into the given site. * The concrete class {@link CalendarEntryDTO} can be used diff --git a/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java b/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java index c31e0dbe25..8f276afa3f 100644 --- a/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java +++ b/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java @@ -33,7 +33,8 @@ import org.alfresco.util.Pair; * @author Nick Burch * @since 4.0 */ -public interface DiscussionService { +public interface DiscussionService +{ /** * Creates a new {@link PostInfo} in the given topic, * with the specified contents. @@ -153,7 +154,6 @@ public interface DiscussionService { @NotAuditable TopicInfo getTopic(NodeRef parentNodeRef, String topicName); - /** * Retrieves all topics in a site, sorted by either oldest * or newest topics first. @@ -209,7 +209,6 @@ public interface DiscussionService { */ @NotAuditable PagingResults findTopics(NodeRef nodeRef, String username, String tag, boolean sortAscending, PagingRequest paging); - /** * Finds topics which have had replies since the specified date, and @@ -227,7 +226,6 @@ public interface DiscussionService { @NotAuditable PagingResults> listHotTopics(NodeRef nodeRef, Date since, PagingRequest paging); - /** * Retrieves all posts in a topic, ordered by creation date */ diff --git a/source/java/org/alfresco/service/cmr/discussion/PostInfo.java b/source/java/org/alfresco/service/cmr/discussion/PostInfo.java index ee2120bdcd..c3c8c637d0 100644 --- a/source/java/org/alfresco/service/cmr/discussion/PostInfo.java +++ b/source/java/org/alfresco/service/cmr/discussion/PostInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -33,7 +33,8 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Burch * @since 4.0 */ -public interface PostInfo extends Serializable, PermissionCheckValue { +public interface PostInfo extends Serializable, PermissionCheckValue +{ /** * @return the NodeRef of the underlying post */ diff --git a/source/java/org/alfresco/service/cmr/discussion/PostWithReplies.java b/source/java/org/alfresco/service/cmr/discussion/PostWithReplies.java index 1b8af32cb5..66e73df48f 100644 --- a/source/java/org/alfresco/service/cmr/discussion/PostWithReplies.java +++ b/source/java/org/alfresco/service/cmr/discussion/PostWithReplies.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/service/cmr/discussion/TopicInfo.java b/source/java/org/alfresco/service/cmr/discussion/TopicInfo.java index 110046ab5e..987e0f2a75 100644 --- a/source/java/org/alfresco/service/cmr/discussion/TopicInfo.java +++ b/source/java/org/alfresco/service/cmr/discussion/TopicInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -35,7 +35,8 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Burch * @since 4.0 */ -public interface TopicInfo extends Serializable, PermissionCheckValue { +public interface TopicInfo extends Serializable, PermissionCheckValue +{ /** * @return the NodeRef of the underlying topic */ diff --git a/source/java/org/alfresco/service/cmr/links/LinkInfo.java b/source/java/org/alfresco/service/cmr/links/LinkInfo.java index 84ec1885a8..8b50072c90 100644 --- a/source/java/org/alfresco/service/cmr/links/LinkInfo.java +++ b/source/java/org/alfresco/service/cmr/links/LinkInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,7 +31,8 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Burch * @since 4.0 */ -public interface LinkInfo extends Serializable, PermissionCheckValue { +public interface LinkInfo extends Serializable, PermissionCheckValue +{ /** * @return the NodeRef of the underlying link */ diff --git a/source/java/org/alfresco/service/cmr/links/LinksService.java b/source/java/org/alfresco/service/cmr/links/LinksService.java index 035421f38e..27ceaee8f8 100644 --- a/source/java/org/alfresco/service/cmr/links/LinksService.java +++ b/source/java/org/alfresco/service/cmr/links/LinksService.java @@ -30,7 +30,8 @@ import org.alfresco.service.NotAuditable; * @author Nick Burch * @since 4.0 */ -public interface LinksService { +public interface LinksService +{ /** * Creates a new {@link LinkInfo} in the given site, with the * specified settings @@ -38,8 +39,7 @@ public interface LinksService { * @return The newly created {@link LinkInfo} */ @NotAuditable - LinkInfo createLink(String siteShortName, String title, - String description, String url, boolean internal); + LinkInfo createLink(String siteShortName, String title, String description, String url, boolean internal); /** * Updates an existing {@link LinkInfo} in the repository. diff --git a/source/java/org/alfresco/service/cmr/notification/NotificationContext.java b/source/java/org/alfresco/service/cmr/notification/NotificationContext.java index 5803b236be..2385dd1ba5 100644 --- a/source/java/org/alfresco/service/cmr/notification/NotificationContext.java +++ b/source/java/org/alfresco/service/cmr/notification/NotificationContext.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -29,6 +29,7 @@ import org.alfresco.service.cmr.repository.NodeRef; * Notification context. Provides the contextual information about a notification. * * @author Roy Wetherall + * @since 4.0 */ public class NotificationContext { @@ -58,7 +59,7 @@ public class NotificationContext /** Indicates whether the notification should be sent asynchronously or not */ private boolean asyncNotification = false; - + /** * Default constructor */ diff --git a/source/java/org/alfresco/service/cmr/notification/NotificationProvider.java b/source/java/org/alfresco/service/cmr/notification/NotificationProvider.java index fa7f56bf7c..f95854a054 100644 --- a/source/java/org/alfresco/service/cmr/notification/NotificationProvider.java +++ b/source/java/org/alfresco/service/cmr/notification/NotificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,6 +24,7 @@ import org.alfresco.service.NotAuditable; * Notification Provider interface. * * @author Roy Wetherall + * @since 4.0 */ public interface NotificationProvider { @@ -33,14 +34,13 @@ public interface NotificationProvider * @return notification provider name */ @NotAuditable - String getName(); - + String getName(); + /** * Sends a notification using the notification provider. * * @param notificationContext notification context */ @NotAuditable - void sendNotification(NotificationContext notificationContext); - + void sendNotification(NotificationContext notificationContext); } diff --git a/source/java/org/alfresco/service/cmr/notification/NotificationService.java b/source/java/org/alfresco/service/cmr/notification/NotificationService.java index 41a610397a..5bcf2adcbb 100644 --- a/source/java/org/alfresco/service/cmr/notification/NotificationService.java +++ b/source/java/org/alfresco/service/cmr/notification/NotificationService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -27,6 +27,7 @@ import org.alfresco.service.NotAuditable; * Notification Service Interface. * * @author Roy Wetherall + * @since 4.0 */ public interface NotificationService { @@ -36,16 +37,16 @@ public interface NotificationService * @param notificationProvider notification provider */ @NotAuditable - void register(NotificationProvider notificationProvider); - + void register(NotificationProvider notificationProvider); + /** * Gets a list of all the currently available notification providers. * * @return {@link List}<{@link String}> notification provider names */ @NotAuditable - List getNotificationProviders(); - + List getNotificationProviders(); + /** * Indicates whether a notification provider exists or not. * @@ -53,8 +54,8 @@ public interface NotificationService * @return boolean true if exists, false otherwise */ @NotAuditable - boolean exists(String notificationProvider); - + boolean exists(String notificationProvider); + /** * Send notification using the names notification provider and notification context. * @@ -62,5 +63,5 @@ public interface NotificationService * @param notificationContext notification context */ @NotAuditable - void sendNotification(String notificationProvider, NotificationContext notificationContext); + void sendNotification(String notificationProvider, NotificationContext notificationContext); } diff --git a/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java b/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java index d7a9a383b0..2026c295ec 100644 --- a/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java +++ b/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,7 +24,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public abstract class BaseNodePublishStatus implements NodePublishStatus { diff --git a/source/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java b/source/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java index 21f89b26f8..800a935e2c 100644 --- a/source/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java +++ b/source/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -23,8 +23,9 @@ import java.util.Calendar; /** * An extension of the {@link PublishingEvent} interface that allows some changes to be made. + * * @author Brian - * + * @since 4.0 */ public interface MutablePublishingEvent extends PublishingEvent { diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java index 2d83262549..0260139e36 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,6 +24,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith + * @since 4.0 */ public interface NodePublishStatus { diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java index bf8893a867..93dc8a1187 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -23,7 +23,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @since 4.0 */ public class NodePublishStatusNotPublished extends BaseNodePublishStatus { @@ -52,5 +52,4 @@ public class NodePublishStatusNotPublished extends BaseNodePublishStatus { return Status.NOT_PUBLISHED; } - } diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java index 96735ea21f..c3319928a4 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,7 +24,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public class NodePublishStatusOnQueue extends BaseNodePublishStatus { diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java index 30e0c0a6e9..dfe782eb4c 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -23,7 +23,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @since 4.0 */ public class NodePublishStatusPublished extends BaseNodePublishStatus { @@ -62,5 +62,4 @@ public class NodePublishStatusPublished extends BaseNodePublishStatus { return Status.PUBLISHED; } - } diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java index 09d22c329b..79a9312528 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -23,7 +23,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @since 4.0 */ public class NodePublishStatusPublishedAndOnQueue extends BaseNodePublishStatus { diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java index bddb072f14..c492e46c7c 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -21,8 +21,9 @@ package org.alfresco.service.cmr.publishing; /** * An interface that enables the use of the Visitor pattern on {@link NodePublishStatus} objects. + * * @author Brian - * + * @since 4.0 */ public interface NodePublishStatusVisitor { diff --git a/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java b/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java index bd8a706721..b19c9a1c4b 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -30,7 +30,6 @@ import org.alfresco.service.namespace.QName; * @author Brian * @author Nick Smith * @since 4.0 - * */ public interface NodeSnapshot { diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingDetails.java b/source/java/org/alfresco/service/cmr/publishing/PublishingDetails.java index 3b225c0b04..cdb493c4c7 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingDetails.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingDetails.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -91,5 +91,4 @@ public interface PublishingDetails * @return a {@link Set} of all the {@link NodeRef}s to be unpublished. */ Set getNodesToUnpublish(); - } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java b/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java index 6b6036e735..45801aacd0 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -29,6 +29,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith + * @since 4.0 */ public interface PublishingEvent extends Comparable { diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java b/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java index 327d487d35..84cacdab8f 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -26,7 +26,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @since 4.0 */ public interface PublishingEventFilter { diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java b/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java index b03429ebbd..96d7879e11 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -24,6 +24,10 @@ import java.util.Set; import org.alfresco.service.cmr.repository.NodeRef; +/** + * @author Brian + * @since 4.0 + */ public interface PublishingPackage { /** diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.java b/source/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.java index 11675b4952..cbc8847795 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -23,7 +23,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @since 4.0 */ public interface PublishingPackageEntry { diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java b/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java index 76b3df1b9f..c16d00255e 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -19,7 +19,10 @@ package org.alfresco.service.cmr.publishing; - +/** + * @author Brian + * @since 4.0 + */ public interface PublishingQueue { /** diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingService.java b/source/java/org/alfresco/service/cmr/publishing/PublishingService.java index f22c91ce18..52924d551e 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingService.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -25,7 +25,10 @@ import java.util.Map; import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.repository.NodeRef; - +/** + * @author Brian + * @since 4.0 + */ public interface PublishingService { /** diff --git a/source/java/org/alfresco/service/cmr/publishing/Status.java b/source/java/org/alfresco/service/cmr/publishing/Status.java index f872549712..3a4bba0afe 100644 --- a/source/java/org/alfresco/service/cmr/publishing/Status.java +++ b/source/java/org/alfresco/service/cmr/publishing/Status.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -19,9 +19,15 @@ package org.alfresco.service.cmr.publishing; -public enum Status { +/** + * @author Brian + * @since 4.0 + */ +public enum Status +{ SCHEDULED, IN_PROGRESS, CANCEL_REQUESTED, COMPLETED, - FAILED} \ No newline at end of file + FAILED +} \ No newline at end of file diff --git a/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java b/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java index 49a6c1e9f5..e2c812811d 100644 --- a/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java +++ b/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -27,7 +27,6 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Nick Smith * @since 4.0 - * */ public interface StatusUpdate { diff --git a/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java b/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java index 2266d71c8d..35d5e4ba56 100644 --- a/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java +++ b/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -28,6 +28,7 @@ import org.alfresco.service.namespace.QName; /** * @author Brian * @author Nick Smith + * @since 4.0 */ public interface Channel { diff --git a/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java b/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java index bb23673df7..1e217897e9 100644 --- a/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java +++ b/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -29,7 +29,7 @@ import org.alfresco.service.namespace.QName; /** * @author Brian * @author Nick Smith - * + * @since 4.0 */ public interface ChannelService { diff --git a/source/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java b/source/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java index a9123a347c..7fa7eff502 100644 --- a/source/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java +++ b/source/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,7 +31,7 @@ import org.springframework.core.io.Resource; /** * @author Brian - * + * @since 4.0 */ public interface ChannelType { diff --git a/source/java/org/alfresco/service/cmr/rating/Rating.java b/source/java/org/alfresco/service/cmr/rating/Rating.java index 705a5e0a9a..5be3d3dd45 100644 --- a/source/java/org/alfresco/service/cmr/rating/Rating.java +++ b/source/java/org/alfresco/service/cmr/rating/Rating.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/service/cmr/rating/RatingScheme.java b/source/java/org/alfresco/service/cmr/rating/RatingScheme.java index 1b2072a009..7b6e64351d 100644 --- a/source/java/org/alfresco/service/cmr/rating/RatingScheme.java +++ b/source/java/org/alfresco/service/cmr/rating/RatingScheme.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/source/java/org/alfresco/service/cmr/rating/RatingService.java b/source/java/org/alfresco/service/cmr/rating/RatingService.java index b7df6b4b49..3b4ff131f0 100644 --- a/source/java/org/alfresco/service/cmr/rating/RatingService.java +++ b/source/java/org/alfresco/service/cmr/rating/RatingService.java @@ -25,7 +25,6 @@ import java.util.Map; import org.alfresco.repo.rating.AbstractRatingRollupAlgorithm; import org.alfresco.service.NotAuditable; -import org.alfresco.service.PublicService; import org.alfresco.service.cmr.repository.NodeRef; /** diff --git a/source/java/org/alfresco/service/cmr/rating/RatingServiceException.java b/source/java/org/alfresco/service/cmr/rating/RatingServiceException.java index 6d1dc7dbba..d2b4ea250c 100644 --- a/source/java/org/alfresco/service/cmr/rating/RatingServiceException.java +++ b/source/java/org/alfresco/service/cmr/rating/RatingServiceException.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,23 +31,23 @@ public class RatingServiceException extends AlfrescoRuntimeException private static final long serialVersionUID = 6035456870472850041L; /** - * Constructs a Rating Service Exception with the specified message. - * - * @param message the message string - */ - public RatingServiceException(String message) - { - super(message); - } + * Constructs a Rating Service Exception with the specified message. + * + * @param message the message string + */ + public RatingServiceException(String message) + { + super(message); + } /** * Constructs a Rating Service Exception with the specified message and source exception. * * @param message the message string - * @param source the source exception - */ - public RatingServiceException(String message, Throwable source) - { - super(message, source); - } + * @param source the source exception + */ + public RatingServiceException(String message, Throwable source) + { + super(message, source); + } } diff --git a/source/java/org/alfresco/service/cmr/wiki/WikiPageInfo.java b/source/java/org/alfresco/service/cmr/wiki/WikiPageInfo.java index dbc67f38a5..c6fdc62275 100644 --- a/source/java/org/alfresco/service/cmr/wiki/WikiPageInfo.java +++ b/source/java/org/alfresco/service/cmr/wiki/WikiPageInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -31,7 +31,8 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Burch * @since 4.0 */ -public interface WikiPageInfo extends Serializable, PermissionCheckValue { +public interface WikiPageInfo extends Serializable, PermissionCheckValue +{ /** * @return the NodeRef of the underlying wiki page */ diff --git a/source/java/org/alfresco/service/cmr/wiki/WikiService.java b/source/java/org/alfresco/service/cmr/wiki/WikiService.java index 454917e3c3..c767779ac6 100644 --- a/source/java/org/alfresco/service/cmr/wiki/WikiService.java +++ b/source/java/org/alfresco/service/cmr/wiki/WikiService.java @@ -30,7 +30,8 @@ import org.alfresco.service.NotAuditable; * @author Nick Burch * @since 4.0 */ -public interface WikiService { +public interface WikiService +{ /** * Creates a new {@link WikiPageInfo} in the given site, with the * specified contents @@ -38,8 +39,7 @@ public interface WikiService { * @return The newly created {@link WikiPageInfo} */ @NotAuditable - WikiPageInfo createWikiPage(String siteShortName, String title, - String contents); + WikiPageInfo createWikiPage(String siteShortName, String title, String contents); /** * Updates an existing {@link WikiPageInfo} in the repository.