use of com.netflix.spinnaker.front50.model.application.ApplicationPermissionDAO in project front50 by spinnaker.
the class ApplicationPermissionsService method deleteApplicationPermission.
public void deleteApplicationPermission(@Nonnull String appName) {
Permission oldPerm;
try {
oldPerm = applicationPermissionDAO().findById(appName);
} catch (NotFoundException e) {
// Nothing to see here, we're all done already.
return;
}
performWrite(supportingEventListeners(Type.PRE_DELETE), supportingEventListeners(Type.POST_DELETE), (unused, newPerm) -> {
applicationPermissionDAO().delete(appName);
syncUsers(null, oldPerm);
return newPerm;
}, oldPerm, null);
}
use of com.netflix.spinnaker.front50.model.application.ApplicationPermissionDAO in project front50 by spinnaker.
the class ApplicationPermissionsService method getAllApplicationPermissions.
public Set<Permission> getAllApplicationPermissions() {
Map<String, Permission> actualPermissions = applicationPermissionDAO().all().stream().map(permission -> new SimpleEntry<>(permission.getName().toLowerCase(), permission)).collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue));
applicationDAO.all().stream().filter(app -> !actualPermissions.containsKey(app.getName().toLowerCase())).forEach(app -> {
Permission p = new Permission();
p.setName(app.getName());
p.setLastModified(-1L);
p.setLastModifiedBy("auto-generated");
actualPermissions.put(app.getName().toLowerCase(), p);
});
return new HashSet<>(actualPermissions.values());
}
use of com.netflix.spinnaker.front50.model.application.ApplicationPermissionDAO in project front50 by spinnaker.
the class GcsConfig method applicationPermissionDAO.
@Bean
public ApplicationPermissionDAO applicationPermissionDAO(Storage storage, StorageServiceConfigurationProperties storageServiceConfigurationProperties, Registry registry, CircuitBreakerRegistry circuitBreakerRegistry, GcsProperties gcsProperties) {
GcsStorageService service = googleCloudStorageService(storage, APPLICATION_PERMISSION_DATA_FILENAME, gcsProperties);
ObjectKeyLoader keyLoader = new DefaultObjectKeyLoader(service);
return new DefaultApplicationPermissionDAO(service, Schedulers.from(Executors.newFixedThreadPool(storageServiceConfigurationProperties.getApplicationPermission().getThreadPool())), keyLoader, storageServiceConfigurationProperties.getApplicationPermission().getRefreshMs(), storageServiceConfigurationProperties.getApplicationPermission().getShouldWarmCache(), registry, circuitBreakerRegistry);
}
use of com.netflix.spinnaker.front50.model.application.ApplicationPermissionDAO in project front50 by spinnaker.
the class ApplicationPermissionsService method createApplicationPermission.
public Permission createApplicationPermission(@Nonnull Permission newPermission) {
return performWrite(supportingEventListeners(Type.PRE_CREATE), supportingEventListeners(Type.POST_CREATE), (unused, newPerm) -> {
Permission perm = applicationPermissionDAO().create(newPerm.getId(), newPerm);
syncUsers(perm, null);
return perm;
}, null, newPermission);
}
use of com.netflix.spinnaker.front50.model.application.ApplicationPermissionDAO in project front50 by spinnaker.
the class ApplicationPermissionsService method update.
private Permission update(@Nonnull String appName, @Nonnull Permission newPermission) {
try {
Permission oldPerm = applicationPermissionDAO().findById(appName);
applicationPermissionDAO().update(appName, newPermission);
syncUsers(newPermission, oldPerm);
} catch (NotFoundException e) {
createApplicationPermission(newPermission);
}
return newPermission;
}
Aggregations