CCM NG: Shortcuts module now deploys successfully
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4147 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
572db42a15
commit
e4f8ca3b97
|
|
@ -36,6 +36,9 @@
|
||||||
<Logger name="org.libreccm.core.AbstractEntityRepository"
|
<Logger name="org.libreccm.core.AbstractEntityRepository"
|
||||||
level="debug">
|
level="debug">
|
||||||
</Logger>
|
</Logger>
|
||||||
|
<Logger name="org.libreccm.modules.CcmIntegrator"
|
||||||
|
level="debug">
|
||||||
|
</Logger>
|
||||||
<Logger name="org.libreccm.security.OneTimeAuthTokenCleaner"
|
<Logger name="org.libreccm.security.OneTimeAuthTokenCleaner"
|
||||||
level="debug">
|
level="debug">
|
||||||
</Logger>
|
</Logger>
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,15 @@ public class CcmIntegrator implements Integrator {
|
||||||
final List<TreeNode> tree = treeManager.generateTree(modules);
|
final List<TreeNode> tree = treeManager.generateTree(modules);
|
||||||
final List<TreeNode> orderedNodes = treeManager.orderModules(tree);
|
final List<TreeNode> orderedNodes = treeManager.orderModules(tree);
|
||||||
|
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("Ordered list of modules:");
|
||||||
|
orderedNodes.forEach(m -> {
|
||||||
|
LOGGER.debug("\t{}-{}",
|
||||||
|
m.getModuleInfo().getModuleName(),
|
||||||
|
m.getModuleInfo().getModuleVersion());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// //Get DataSource and Connection from the sessionFactory of
|
// //Get DataSource and Connection from the sessionFactory of
|
||||||
// //Hibernate.
|
// //Hibernate.
|
||||||
final DataSource dataSource = (DataSource) sessionFactory.
|
final DataSource dataSource = (DataSource) sessionFactory.
|
||||||
|
|
@ -119,6 +128,9 @@ public class CcmIntegrator implements Integrator {
|
||||||
|
|
||||||
//Migrate the modules
|
//Migrate the modules
|
||||||
for (final TreeNode node : orderedNodes) {
|
for (final TreeNode node : orderedNodes) {
|
||||||
|
LOGGER.debug("Applying migrations for module {}-{}",
|
||||||
|
node.getModuleInfo().getModuleName(),
|
||||||
|
node.getModuleInfo().getModuleVersion());
|
||||||
migrateModule(node.getModule().getClass(), dataSource);
|
migrateModule(node.getModule().getClass(), dataSource);
|
||||||
|
|
||||||
// for (Class<?> entity : node.getModuleInfo().getModuleEntities()) {
|
// for (Class<?> entity : node.getModuleInfo().getModuleEntities()) {
|
||||||
|
|
@ -190,8 +202,7 @@ public class CcmIntegrator implements Integrator {
|
||||||
* @param buffer Buffer for the location string.
|
* @param buffer Buffer for the location string.
|
||||||
* @param connection The JDBC connection object.
|
* @param connection The JDBC connection object.
|
||||||
*
|
*
|
||||||
* @throws SQLException If an error occurs while accessing the
|
* @throws SQLException If an error occurs while accessing the database.
|
||||||
* database.
|
|
||||||
* @throws IntegrationException If the database is not supported yet.
|
* @throws IntegrationException If the database is not supported yet.
|
||||||
*/
|
*/
|
||||||
private void appendDbLocation(final StringBuffer buffer,
|
private void appendDbLocation(final StringBuffer buffer,
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package org.libreccm.modules;
|
package org.libreccm.modules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.security;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import org.libreccm.shortcuts.ShortcutsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ShortcutsRolesSetup {
|
||||||
|
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
public ShortcutsRolesSetup(final EntityManager entityManager) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupShortcutsRoles() {
|
||||||
|
final Role shortcutsManager = new Role();
|
||||||
|
shortcutsManager.setName("shortcuts-manager");
|
||||||
|
entityManager.persist(shortcutsManager);
|
||||||
|
|
||||||
|
final Permission permission = new Permission();
|
||||||
|
permission.setGrantee(shortcutsManager);
|
||||||
|
permission.setGrantedPrivilege(
|
||||||
|
ShortcutsConstants.SHORTSCUT_MANAGE_PRIVILEGE);
|
||||||
|
permission.setObject(null);
|
||||||
|
|
||||||
|
entityManager.persist(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -18,10 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.shortcuts;
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
|
import org.libreccm.core.CcmCore;
|
||||||
import org.libreccm.modules.CcmModule;
|
import org.libreccm.modules.CcmModule;
|
||||||
import org.libreccm.modules.InitEvent;
|
import org.libreccm.modules.InitEvent;
|
||||||
import org.libreccm.modules.InstallEvent;
|
import org.libreccm.modules.InstallEvent;
|
||||||
import org.libreccm.modules.Module;
|
import org.libreccm.modules.Module;
|
||||||
|
import org.libreccm.modules.RequiredModule;
|
||||||
import org.libreccm.modules.ShutdownEvent;
|
import org.libreccm.modules.ShutdownEvent;
|
||||||
import org.libreccm.modules.UnInstallEvent;
|
import org.libreccm.modules.UnInstallEvent;
|
||||||
import org.libreccm.web.ApplicationType;
|
import org.libreccm.web.ApplicationType;
|
||||||
|
|
@ -30,7 +32,11 @@ import org.libreccm.web.ApplicationType;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@Module(applicationTypes = {
|
@Module(
|
||||||
|
requiredModules = {
|
||||||
|
@RequiredModule(module = CcmCore.class)
|
||||||
|
},
|
||||||
|
applicationTypes = {
|
||||||
@ApplicationType(name = ShortcutsConstants.SHORTCUTS_APP_TYPE,
|
@ApplicationType(name = ShortcutsConstants.SHORTCUTS_APP_TYPE,
|
||||||
descBundle = "org.libreccm.shortcuts.ShortcutsResources",
|
descBundle = "org.libreccm.shortcuts.ShortcutsResources",
|
||||||
singleton = true,
|
singleton = true,
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,6 @@ public final class ShortcutsConstants {
|
||||||
*/
|
*/
|
||||||
public static final String SHORTCUTS_PRIMARY_URL = "/shortcuts/";
|
public static final String SHORTCUTS_PRIMARY_URL = "/shortcuts/";
|
||||||
|
|
||||||
|
public static final String SHORTSCUT_MANAGE_PRIVILEGE = "manage_shortcuts";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.shortcuts;
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.modules.InstallEvent;
|
import org.libreccm.modules.InstallEvent;
|
||||||
import org.libreccm.security.PermissionManager;
|
|
||||||
import org.libreccm.security.Role;
|
|
||||||
import org.libreccm.security.RoleManager;
|
|
||||||
import org.libreccm.security.RoleRepository;
|
|
||||||
import org.libreccm.web.AbstractCcmApplicationSetup;
|
import org.libreccm.web.AbstractCcmApplicationSetup;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.libreccm.security.ShortcutsRolesSetup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -47,16 +43,17 @@ public class ShortcutsSetup extends AbstractCcmApplicationSetup {
|
||||||
shortcuts.setPrimaryUrl(ShortcutsConstants.SHORTCUTS_PRIMARY_URL);
|
shortcuts.setPrimaryUrl(ShortcutsConstants.SHORTCUTS_PRIMARY_URL);
|
||||||
getEntityManager().persist(shortcuts);
|
getEntityManager().persist(shortcuts);
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final ShortcutsRolesSetup rolesSetup = new ShortcutsRolesSetup(
|
||||||
final RoleRepository roleRepository = cdiUtil.findBean(
|
getEntityManager());
|
||||||
RoleRepository.class);
|
rolesSetup.setupShortcutsRoles();
|
||||||
final Role shortcutsManager = new Role();
|
|
||||||
shortcutsManager.setName("shortcuts-manager");
|
|
||||||
roleRepository.save(shortcutsManager);
|
|
||||||
|
|
||||||
final PermissionManager permissionManager = cdiUtil.findBean(
|
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
PermissionManager.class);
|
// final RoleRepository roleRepository = cdiUtil.findBean(
|
||||||
permissionManager.grantPrivilege("manage_shortcuts", shortcutsManager);
|
// RoleRepository.class);
|
||||||
|
// roleRepository.save(shortcutsManager);
|
||||||
|
// final PermissionManager permissionManager = cdiUtil.findBean(
|
||||||
|
// PermissionManager.class);
|
||||||
|
// permissionManager.grantPrivilege("manage_shortcuts", shortcutsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
create table SHORTCUTS (
|
|
||||||
shortcut_id bigint generated by default as identity,
|
|
||||||
redirect varchar(1024),
|
|
||||||
url_key varchar(1024),
|
|
||||||
primary key (shortcut_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
alter table CCM_SHORTCUTS.SHORTCUTS
|
|
||||||
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
create table SHORTCUTS (
|
|
||||||
shortcut_id number(19,0) not null,
|
|
||||||
redirect varchar2(1024 char),
|
|
||||||
url_key varchar2(1024 char),
|
|
||||||
primary key (shortcut_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table SHORTCUTS_APP (
|
|
||||||
object_id number(19,0) not null,
|
|
||||||
primary key (object_id)
|
|
||||||
);
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
create table SHORTCUTS (
|
|
||||||
shortcut_id int8 not null,
|
|
||||||
redirect varchar(1024),
|
|
||||||
url_key varchar(1024),
|
|
||||||
primary key (shortcut_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
alter table CCM_SHORTCUTS.SHORTCUTS
|
|
||||||
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
|
|
||||||
Loading…
Reference in New Issue