-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/maven/fixes/9.1' into maven/rele…
…ase/9.1
- Loading branch information
Showing
27 changed files
with
339 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 4 additions & 54 deletions
58
.../core/src/main/java/org/edu_sharing/repository/server/jobs/quartz/TimedPermissionJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,21 @@ | ||
package org.edu_sharing.repository.server.jobs.quartz; | ||
|
||
|
||
import org.alfresco.repo.security.authentication.AuthenticationUtil; | ||
import org.alfresco.repo.transaction.RetryingTransactionHelper; | ||
import org.alfresco.service.cmr.repository.NodeRef; | ||
import org.alfresco.service.cmr.repository.StoreRef; | ||
import org.alfresco.service.cmr.security.PermissionService; | ||
import org.edu_sharing.repository.server.jobs.quartz.annotation.JobDescription; | ||
import org.edu_sharing.service.permission.TimedPermission; | ||
import org.edu_sharing.service.permission.TimedPermissionMapper; | ||
import org.edu_sharing.service.permission.PermissionService; | ||
import org.quartz.JobExecutionContext; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@JobDescription(description = "") | ||
@JobDescription(description = "Updates permission of timed permissions") | ||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") | ||
public class TimedPermissionJob extends AbstractInterruptableJob { | ||
|
||
@Autowired | ||
private TimedPermissionMapper timedPermissionMapper; | ||
|
||
@Autowired | ||
private PermissionService permissionService; | ||
|
||
@Autowired | ||
private RetryingTransactionHelper retryingTransactionHelper; | ||
|
||
@Override | ||
protected void executeInterruptable(JobExecutionContext jobExecutionContext) { | ||
|
||
List<TimedPermission> permissionsToAdd = timedPermissionMapper.findAllByFromAfterAndNotActivated(new Date()); | ||
List<TimedPermission> permissionsToRemove = timedPermissionMapper.findAllByToBefore(new Date()); | ||
|
||
|
||
for (TimedPermission timedPermission : permissionsToAdd) { | ||
retryingTransactionHelper.doInTransaction(() -> | ||
AuthenticationUtil.runAsSystem(() -> { | ||
permissionService.setPermission( | ||
new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, timedPermission.getNode_id()), | ||
timedPermission.getAuthority(), | ||
timedPermission.getPermission(), | ||
true); | ||
|
||
if(timedPermission.getTo() == null){ | ||
timedPermissionMapper.delete(timedPermission); | ||
}else { | ||
timedPermission.setActivated(true); | ||
timedPermissionMapper.save(timedPermission); | ||
} | ||
return null; | ||
})); | ||
} | ||
|
||
for (TimedPermission timedPermission : permissionsToRemove) { | ||
retryingTransactionHelper.doInTransaction(() -> | ||
AuthenticationUtil.runAsSystem(() -> { | ||
permissionService.deletePermission( | ||
new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, timedPermission.getNode_id()), | ||
timedPermission.getAuthority(), | ||
timedPermission.getPermission()); | ||
|
||
timedPermissionMapper.delete(timedPermission); | ||
return null; | ||
})); | ||
} | ||
|
||
|
||
permissionService.updateTimedPermissions(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 10 additions & 9 deletions
19
...end/services/core/src/main/java/org/edu_sharing/service/permission/PermissionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
...vices/core/src/main/java/org/edu_sharing/service/permission/PermissionServiceAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.