@@ -415,22 +415,22 @@ public String execute() throws BaseException {
415
415
getProjectPrizesToBeUpdated (request , project , createdPrize , updatedPrize , removedPrize );
416
416
417
417
Phase [] projectPhases ;
418
- boolean updated = false ;
419
418
boolean phaseUpdated = false ;
420
419
boolean resourceUpdated = false ;
421
420
boolean prizeUpdated = false ;
422
421
boolean submissionUpdated = false ;
423
422
if (!ActionsHelper .isErrorsPresent (request )) {
424
423
// Save the project phases
425
424
projectPhases = saveProjectPhases (newProject , request , project , phasesJsMap , phasesToDelete );
426
- phaseUpdated = true ;
425
+ if (!ActionsHelper .isErrorsPresent (request )) {
426
+ phaseUpdated = true ;
427
+ }
427
428
} else {
428
429
// Retrieve and sort project phases
429
430
projectPhases = ActionsHelper .getPhasesForProject (ActionsHelper .createPhaseManager (false ), project );
430
431
Arrays .sort (projectPhases , new Comparators .ProjectPhaseComparer ());
431
432
}
432
433
if (!ActionsHelper .isErrorsPresent (request )) {
433
- updated = true ;
434
434
// The project has been saved, so pre-populate last modification timestamp
435
435
getModel ().set ("last_modification_time" ,
436
436
ActionsHelper .getLastModificationTime (project , projectPhases ).getTime ());
@@ -439,8 +439,7 @@ public String execute() throws BaseException {
439
439
// resources must be saved even if there are validation errors to validate resources
440
440
if (!ActionsHelper .isErrorsPresent (request )) {
441
441
// Save the project resources
442
- saveResources (request , project , projectPhases , phasesJsMap );
443
- resourceUpdated = true ;
442
+ resourceUpdated = saveResources (request , project , projectPhases , phasesJsMap );
444
443
}
445
444
446
445
if (!ActionsHelper .isErrorsPresent (request )) {
@@ -476,11 +475,9 @@ public String execute() throws BaseException {
476
475
prizeUpdated = true ;
477
476
}
478
477
}
479
- if (updated ) {
480
- GrpcHelper .getSyncServiceRpc ().saveProjectSync (project .getId (), statusHasChanged , categoryHasChanged ,
481
- externalRefIdHasChanged , directProjectIdHasChanged , phaseUpdated , resourceUpdated , prizeUpdated ,
482
- submissionUpdated );
483
- }
478
+ GrpcHelper .getSyncServiceRpc ().saveProjectSync (project .getId (), statusHasChanged , categoryHasChanged ,
479
+ externalRefIdHasChanged , directProjectIdHasChanged , phaseUpdated , resourceUpdated , prizeUpdated ,
480
+ submissionUpdated );
484
481
// Check if there are any validation errors and return appropriate forward
485
482
if (ActionsHelper .isErrorsPresent (request )) {
486
483
// Check if the form is really for new project
@@ -1521,7 +1518,7 @@ private boolean checkUserChallengeEligibility(HttpServletRequest request, int re
1521
1518
* @param phasesJsMap the phasesJsMap
1522
1519
* @throws BaseException if any error occurs
1523
1520
*/
1524
- private void saveResources (HttpServletRequest request ,
1521
+ private boolean saveResources (HttpServletRequest request ,
1525
1522
Project project , Phase [] projectPhases , Map <Object , Phase > phasesJsMap ) throws BaseException {
1526
1523
// Obtain the instance of the User Retrieval
1527
1524
UserRetrieval userRetrieval = ActionsHelper .createUserRetrieval (request );
@@ -1532,19 +1529,21 @@ private void saveResources(HttpServletRequest request,
1532
1529
String [] resourceNames = (String []) getModel ().get ("resources_name" );
1533
1530
1534
1531
// HashSet used to identify resource of new user
1535
- Set <Long > newUsers = new HashSet <Long >();
1536
- Set <Long > newModerators = new HashSet <Long >();
1537
- Set <Long > oldUsers = new HashSet <Long >();
1538
- Set <Long > deletedUsers = new HashSet <Long >();
1532
+ // Set<Long> newUsers = new HashSet<Long>();
1533
+ // Set<Long> newModerators = new HashSet<Long>();
1534
+ // Set<Long> oldUsers = new HashSet<Long>();
1535
+ // Set<Long> deletedUsers = new HashSet<Long>();
1539
1536
Set <Long > newSubmitters = new HashSet <Long >();
1540
- Set <Long > newUsersForumWatch = new HashSet <Long >();
1537
+ // Set<Long> newUsersForumWatch = new HashSet<Long>();
1541
1538
1542
1539
Set <Long > newUsersForNotification = new HashSet <Long >();
1543
1540
Set <Long > deletedUsersForNotification = new HashSet <Long >();
1544
- Set <Long > deletedUsersForForumWatch = new HashSet <Long >();
1541
+ //Set<Long> deletedUsersForForumWatch = new HashSet<Long>();
1542
+ boolean resourcesUpdated = false ;
1545
1543
1546
1544
// 0-index resource is skipped as it is a "dummy" one
1547
1545
boolean allResourcesValid = true ;
1546
+ ExternalUser [] externalUsers = new ExternalUser [resourceNames .length ];
1548
1547
for (int i = 1 ; i < resourceNames .length ; i ++) {
1549
1548
1550
1549
if (resourceNames [i ] == null || resourceNames [i ].trim ().length () == 0 ) {
@@ -1556,6 +1555,7 @@ private void saveResources(HttpServletRequest request,
1556
1555
1557
1556
// Get info about user with the specified handle
1558
1557
ExternalUser user = userRetrieval .retrieveUser (resourceNames [i ]);
1558
+ externalUsers [i ] = user ;
1559
1559
1560
1560
// If there is no user with such handle, indicate an error
1561
1561
if (user == null ) {
@@ -1568,7 +1568,7 @@ private void saveResources(HttpServletRequest request,
1568
1568
// validate resources have correct terms of use
1569
1569
try {
1570
1570
allResourcesValid = allResourcesValid && validateResourceTermsOfUse (request , project , userRetrieval , resourceNames );
1571
- allResourcesValid = allResourcesValid && validateResourceEligibility (request , project , userRetrieval , resourceNames );
1571
+ allResourcesValid = allResourcesValid && validateResourceEligibility (request , project , userRetrieval , resourceNames , externalUsers );
1572
1572
} catch (ContestEligibilityValidatorException e ) {
1573
1573
throw new BaseException (e );
1574
1574
}
@@ -1798,14 +1798,14 @@ private void saveResources(HttpServletRequest request,
1798
1798
1799
1799
// No resources are updated if at least one of them is incorrect.
1800
1800
if (!allResourcesValid ) {
1801
- return ;
1801
+ return resourcesUpdated ;
1802
1802
}
1803
1803
1804
1804
// 0-index resource is skipped as it is a "dummy" one
1805
1805
for (int i = 1 ; i < resourceNames .length ; i ++) {
1806
1806
1807
1807
// Get info about user with the specified handle
1808
- ExternalUser user = userRetrieval . retrieveUser ( resourceNames [i ]) ;
1808
+ ExternalUser user = externalUsers [i ];
1809
1809
1810
1810
Resource resource ;
1811
1811
@@ -1818,7 +1818,8 @@ private void saveResources(HttpServletRequest request,
1818
1818
1819
1819
resource .setProperty ("Registration Date" , DATE_FORMAT .format (new Date ()));
1820
1820
1821
- newUsers .add (user .getId ());
1821
+ //newUsers.add(user.getId());
1822
+ resourcesUpdated = true ;
1822
1823
1823
1824
ResourceRole role = LookupHelper .getResourceRole ((Long ) getModel ().get ("resources_role" , i ));
1824
1825
if (!role .getName ().equals ("Observer" ) || Boolean .parseBoolean (retrieveUserPreference (user .getId (), GLOBAL_TIMELINE_NOTIFICATION ))) {
@@ -1832,20 +1833,20 @@ private void saveResources(HttpServletRequest request,
1832
1833
if (resourceId != -1 ) {
1833
1834
// Retrieve the resource with the specified id
1834
1835
resource = resourceManager .getResource (resourceId );
1835
- oldUsers .add (user .getId ());
1836
+ // oldUsers.add(user.getId());
1836
1837
//System.out.println("REMOVE:" + user.getId());
1837
1838
} else {
1838
1839
// -1 value as id marks the resources that were't persisted in DB yet
1839
1840
// and so should be skipped for actions other then "add"
1840
- oldUsers .add (user .getId ());
1841
+ // oldUsers.add(user.getId());
1841
1842
//System.out.println("REMOVE:" + user.getId());
1842
1843
continue ;
1843
1844
}
1844
1845
}
1845
1846
1846
1847
// If action is "delete", delete the resource and proceed to the next one
1847
1848
if ("delete" .equals (resourceAction )) {
1848
- deletedUsers .add (user .getId ());
1849
+ // deletedUsers.add(user.getId());
1849
1850
1850
1851
// delete project payments
1851
1852
for (ProjectPayment payment : allPayments ) {
@@ -1884,13 +1885,13 @@ private void saveResources(HttpServletRequest request,
1884
1885
}
1885
1886
1886
1887
if (!Boolean .parseBoolean (retrieveUserPreference (user .getId (), GLOBAL_FORUM_WATCH ))) {
1887
- deletedUsersForForumWatch .add (user .getId ());
1888
+ // deletedUsersForForumWatch.add(user.getId());
1888
1889
}
1889
1890
}
1890
1891
if (resource .getResourceRole ().getName ().equals ("Observer" )) {
1891
1892
// change from observer to other role
1892
1893
// add forum watch & notification anyway
1893
- newUsersForumWatch .add (user .getId ());
1894
+ // newUsersForumWatch.add(user.getId());
1894
1895
newUsersForNotification .add (user .getId ());
1895
1896
}
1896
1897
}
@@ -1933,7 +1934,7 @@ private void saveResources(HttpServletRequest request,
1933
1934
// add "Appeals Completed Early" flag.
1934
1935
resource .setProperty (Constants .APPEALS_COMPLETED_EARLY_PROPERTY_KEY , Constants .NO_VALUE );
1935
1936
}
1936
-
1937
+ /*
1937
1938
if ("add".equals(resourceAction)) {
1938
1939
1939
1940
if (resourceRole.equals("Manager") || resourceRole.equals("Observer")
@@ -1947,22 +1948,23 @@ private void saveResources(HttpServletRequest request,
1947
1948
if (!resourceRole.equals("Observer")
1948
1949
|| Boolean.parseBoolean(retrieveUserPreference(
1949
1950
user.getId(), GLOBAL_FORUM_WATCH))) {
1950
- newUsersForumWatch .add (user .getId ());
1951
+ // newUsersForumWatch.add(user.getId());
1951
1952
}
1952
1953
}
1953
1954
1954
1955
}
1955
1956
}
1956
-
1957
+ */
1957
1958
// client manager and copilot have moderator role
1959
+ /*
1958
1960
if (resourceRole.equals("Client Manager") || resourceRole.equals("Copilot")
1959
1961
|| resourceRole.equals("Observer") || resourceRole.equals("Designer"))
1960
1962
{
1961
- newUsers .remove (user .getId ());
1962
- newModerators .add (user .getId ());
1963
+ // newUsers.remove(user.getId());
1964
+ // newModerators.add(user.getId());
1963
1965
1964
1966
}
1965
-
1967
+ */
1966
1968
// make sure "Appeals Completed Early" flag is not set if the role is not submitter.
1967
1969
if (resourceRoleChanged && !resourceRole .equals (Constants .SUBMITTER_ROLE_NAME )) {
1968
1970
resource .setProperty (Constants .APPEALS_COMPLETED_EARLY_PROPERTY_KEY , null );
@@ -1978,7 +1980,8 @@ private void saveResources(HttpServletRequest request,
1978
1980
1979
1981
// check the list of users to delete and remove those still have other roles
1980
1982
Resource [] allProjectResources = ActionsHelper .getAllResourcesForProject (project );
1981
- Set <Long > usersToKeep = new HashSet <Long >();
1983
+ //Set<Long> usersToKeep = new HashSet<Long>();
1984
+ /*
1982
1985
for (Long id : deletedUsers) {
1983
1986
for (Resource projectResource : allProjectResources) {
1984
1987
Long userId = projectResource.getUserId();
@@ -1989,12 +1992,14 @@ private void saveResources(HttpServletRequest request,
1989
1992
}
1990
1993
}
1991
1994
}
1992
- deletedUsers . removeAll ( usersToKeep );
1993
-
1995
+ */
1996
+ //deletedUsers.removeAll(usersToKeep);
1994
1997
1998
+ /*
1995
1999
for (Long id : oldUsers) {
1996
2000
newUsers.remove(id);
1997
2001
}
2002
+ */
1998
2003
1999
2004
// Populate project_result and component_inquiry for new submitters
2000
2005
ActionsHelper .populateProjectResult (project , newSubmitters );
@@ -2031,6 +2036,7 @@ private void saveResources(HttpServletRequest request,
2031
2036
resourceManager .addNotifications (userIds , project .getId (),
2032
2037
timelineNotificationId , Long .toString (AuthorizationHelper .getLoggedInUserId (request )));
2033
2038
}
2039
+ return resourcesUpdated ;
2034
2040
}
2035
2041
2036
2042
/**
@@ -2126,7 +2132,7 @@ private boolean validateResourceTermsOfUse(HttpServletRequest request,
2126
2132
* @return true if all resources are valid
2127
2133
*/
2128
2134
private boolean validateResourceEligibility (HttpServletRequest request ,
2129
- Project project , UserRetrieval userRetrieval , String [] resourceNames )
2135
+ Project project , UserRetrieval userRetrieval , String [] resourceNames , ExternalUser [] externalUsers )
2130
2136
throws BaseException , ContestEligibilityValidatorException {
2131
2137
2132
2138
boolean allResourcesValid = true ;
@@ -2136,7 +2142,7 @@ private boolean validateResourceEligibility(HttpServletRequest request,
2136
2142
// 0-index resource is skipped as it is a "dummy" one
2137
2143
for (int i = 1 ; i < resourceNames .length ; i ++) {
2138
2144
if (resourceNames [i ] != null && resourceNames [i ].trim ().length () > 0 ) {
2139
- ExternalUser user = userRetrieval . retrieveUser ( resourceNames [i ]) ;
2145
+ ExternalUser user = externalUsers [i ];
2140
2146
String resourceAction = (String ) getModel ().get ("resources_action" , i );
2141
2147
// check for additions or modifications
2142
2148
if (!"delete" .equals (resourceAction )) {
0 commit comments