Commit 6fe724c6 authored by Matija Obreza's avatar Matija Obreza

AppUps: Removed upgrade code already executed on servers

parent e5e0f60f
......@@ -15,22 +15,14 @@
*/
package org.genesys2.server.component.listener;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.blocks.security.service.CustomAclService;
import org.genesys.blocks.util.ClassAclOid;
import org.genesys.blocks.util.CurrentApplicationContext;
import org.genesys.catalog.model.Partner;
import org.genesys.catalog.persistence.PartnerRepository;
import org.genesys2.server.component.security.AsAdminInvoker;
import org.genesys2.server.model.impl.FaoInstitute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.common.collect.Lists;
/**
* Declare sorts of things that upgrade the existing database
*
......@@ -55,39 +47,40 @@ public class ApplicationUpgrades implements InitializingBean {
*/
@Override
public void afterPropertiesSet() throws Exception {
aclEnsureClassOIDs();
aclMakePartnersPublic();
LOG.info("Executing {}", this.getClass().getName());
// aclEnsureClassOIDs();
// aclMakePartnersPublic();
}
@Autowired
private CustomAclService aclService;
private void aclEnsureClassOIDs() throws Exception {
asAdminInvoker.invoke(() -> {
LOG.warn("Making some Entities publicly readable by default");
for (Class<? extends AclAwareModel> clazz : Lists.newArrayList(Partner.class, FaoInstitute.class)) {
LOG.warn("Making {} publicly readable by default", clazz.getName());
aclService.createOrUpdatePermissions(ClassAclOid.forClass(clazz));
aclService.makePubliclyReadable(ClassAclOid.forClass(clazz), true);
}
// @Autowired
// private CustomAclService aclService;
return true;
});
}
// private void aclEnsureClassOIDs() throws Exception {
// asAdminInvoker.invoke(() -> {
// LOG.warn("Making some Entities publicly readable by default");
//
// for (Class<? extends AclAwareModel> clazz : Lists.newArrayList(Partner.class, FaoInstitute.class)) {
// LOG.warn("Making {} publicly readable by default", clazz.getName());
// aclService.createOrUpdatePermissions(ClassAclOid.forClass(clazz));
// aclService.makePubliclyReadable(ClassAclOid.forClass(clazz), true);
// }
//
// return true;
// });
// }
@Autowired
private PartnerRepository partnerRepository;
private void aclMakePartnersPublic() throws Exception {
asAdminInvoker.invoke(() -> {
LOG.warn("Making Partners publicly readable");
partnerRepository.findAll().forEach(partner -> {
LOG.warn("Making Partner {} publicly readable", partner.getShortName());
aclService.createOrUpdatePermissions(partner);
});
return true;
});
}
// @Autowired
// private PartnerRepository partnerRepository;
//
// private void aclMakePartnersPublic() throws Exception {
// asAdminInvoker.invoke(() -> {
// LOG.warn("Making Partners publicly readable");
//
// partnerRepository.findAll().forEach(partner -> {
// LOG.warn("Making Partner {} publicly readable", partner.getShortName());
// aclService.createOrUpdatePermissions(partner);
// });
// return true;
// });
// }
}
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