Commit 61a0978b authored by Matija Obreza's avatar Matija Obreza

Prepare KPI Executions for ACL

parent 46cf8694
......@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.spring.config;
package org.genesys2.server.component.listener;
import org.genesys.filerepository.migration.RepositoryUpgrade20180920;
import org.genesys.blocks.security.service.CustomAclService;
import org.genesys2.server.component.security.AsAdminInvoker;
import org.genesys2.server.persistence.kpi.ExecutionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
/**
* Declare sorts of things that upgrade the existing database
......@@ -31,7 +31,7 @@ import org.springframework.context.annotation.DependsOn;
* @author Matija Obreza
* @since 2.4
*/
@Configuration
@Component
public class ApplicationUpgrades implements InitializingBean {
/** The Constant LOG. */
......@@ -46,33 +46,23 @@ public class ApplicationUpgrades implements InitializingBean {
*/
@Override
public void afterPropertiesSet() throws Exception {
}
/**
* Repository upgrade 20180920.
*
* @return the repository upgrade 20180920
* @throws Exception
*/
// TODO Remove in 2.5
@Bean
@DependsOn({ "currentApplicationContext" })
protected RepositoryUpgrade20180920 repositoryUpgrade20180920() throws Exception {
return new RepositoryUpgrade20180920();
kpiEnsureACL();
}
@Autowired
private ExecutionRepository kpiExecutionRepository;
@Autowired
private CustomAclService aclService;
@Bean
protected RepositoryUpgrade20180920 afterRepositoryUpgrade20180920(RepositoryUpgrade20180920 repositoryUpgrade20180920) throws Exception {
protected void kpiEnsureACL() throws Exception {
asAdminInvoker.invoke(() -> {
LOG.warn("Running afterRepositoryUpgrade20180920");
LOG.warn("Adding ACL support to KPI Execution");
kpiExecutionRepository.findAll().forEach(execution -> {
LOG.warn("Making KPI Execution {} ACL-ready", execution.getName());
aclService.createOrUpdatePermissions(execution);
});
return true;
});
return null;
}
}
......@@ -34,7 +34,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Import;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
......@@ -44,7 +43,6 @@ import com.google.common.collect.Sets;
* Run things at startup and after application context is initialized.
*/
@Component
@Import({ ApplicationUpgrades.class })
public class ApplicationStartup implements InitializingBean {
private static final Logger LOG = LoggerFactory.getLogger(ApplicationStartup.class);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment