ensured deployment is stopped, if application cannot be read
This commit is contained in:
@ -22,6 +22,7 @@ import de.muehlencord.shared.account.util.AccountPU;
|
||||
import de.muehlencord.shared.account.util.Permission;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
@ -50,6 +51,9 @@ public class ApplicationPermissionControl implements Serializable {
|
||||
ApplicationEntity application;
|
||||
|
||||
public List<ApplicationPermissionEntity> getApplicationPermissions(ApplicationEntity app) {
|
||||
if (application == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
Query query = em.createNamedQuery("ApplicationPermissionEntity.findAll");
|
||||
query.setParameter("application", app);
|
||||
List<ApplicationPermissionEntity> permissionList = query.getResultList();
|
||||
@ -124,6 +128,9 @@ public class ApplicationPermissionControl implements Serializable {
|
||||
|
||||
@Transactional
|
||||
public void setupPermissions(List<Permission> permissions) {
|
||||
if (application == null) {
|
||||
LOGGER.error("Application not initialized, cannot setup permissions");
|
||||
} else {
|
||||
for (Permission permission : permissions) {
|
||||
ApplicationPermissionEntity existingPermission = findByName(application, permission.getName());
|
||||
if (existingPermission == null) {
|
||||
@ -155,3 +162,4 @@ public class ApplicationPermissionControl implements Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,6 @@ public class StartupBean {
|
||||
public void shutdown() {
|
||||
LOGGER.info("Shutting down application {}", application.getApplicationName());
|
||||
|
||||
|
||||
LOGGER.info("Application shutdown complete");
|
||||
}
|
||||
|
||||
|
||||
@ -76,13 +76,13 @@ public class ApplicationController {
|
||||
version = "??";
|
||||
buildDate = "??";
|
||||
uuid = null;
|
||||
LOGGER.error("Application id not readable, application will not be able to run");
|
||||
throw new RuntimeException("Application id not readable, application will not be able to run");
|
||||
}
|
||||
|
||||
if (uuid != null) {
|
||||
this.application = applicationService.findById(uuid);
|
||||
if (application == null) {
|
||||
LOGGER.error("Could not find application with id ");
|
||||
throw new RuntimeException("ApplicationId "+uuid.toString()+" not readable, application will not be able to run. You need to setup application in account database first.");
|
||||
} else {
|
||||
LOGGER.info("Found application {} with id {}", application.getApplicationName(), uuid.toString());
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class ApplicationController {
|
||||
|
||||
/**
|
||||
* needs to return link to "Account UI" and not to current selected application
|
||||
* TODO: ensure only Account UI can call functions where appliction can be handed in - all other applications need to call the function which use the injected application
|
||||
* TODO: ensure only Account UI can call functions where application can be handed in - all other applications need to call the function which use the injected application
|
||||
*/
|
||||
@Produces
|
||||
public ApplicationEntity getApplication() {
|
||||
|
||||
Reference in New Issue
Block a user