Search in sources :

Example 11 with UpgradeException

use of com.thinkbiganalytics.server.upgrade.UpgradeException in project kylo by Teradata.

the class VersionableFeedUpgradeAction method upgradeTo.

@Override
public void upgradeTo(final KyloVersion startingVersion) {
    log.info("Upgrading feeds as versionable for version: {}", startingVersion);
    feedProvider.getFeeds().forEach(feed -> {
        JcrFeed jcrFeed = (JcrFeed) feed;
        Node summaryNode = jcrFeed.getFeedSummary().get().getNode();
        try {
            summaryNode.addMixin("mix:versionable");
        } catch (Exception e) {
            log.error("Failed to set a feed as versionable: {}", feed.getName(), e);
            ;
            throw new UpgradeException("Failed to set a feed summary node as versionable: " + summaryNode, e);
        }
    });
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) Node(javax.jcr.Node) UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException)

Example 12 with UpgradeException

use of com.thinkbiganalytics.server.upgrade.UpgradeException in project kylo by Teradata.

the class FeedSchemaUpgradeAction method moveNode.

private void moveNode(Session session, Node node, Node parentNode) {
    try {
        if ((node != null) && (parentNode != null)) {
            // Path may not be accurate if parent node moved recently
            final String srcPath = node.getParent().getPath() + "/" + StringUtils.substringAfterLast(node.getPath(), "/");
            session.move(srcPath, parentNode.getPath() + "/" + node.getName());
        }
    } catch (RepositoryException e) {
        throw new UpgradeException("Failed to moved node " + node + " under parent " + parentNode, e);
    }
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) RepositoryException(javax.jcr.RepositoryException)

Example 13 with UpgradeException

use of com.thinkbiganalytics.server.upgrade.UpgradeException in project kylo by Teradata.

the class FeedSchemaUpgradeAction method moveProperty.

/**
 * move a property from one node to another
 *
 * @param propName     the name of the property to move
 * @param fromNode     the node to move from
 * @param toNode       the node to move to
 * @param propertyType Optional.  This is the new property type, or null if unchanged
 */
private void moveProperty(String propName, Node fromNode, Node toNode, Integer propertyType) {
    try {
        if ((fromNode != null) && (toNode != null)) {
            if (fromNode.hasProperty(propName)) {
                Property prop = fromNode.getProperty(propName);
                if (propertyType == null) {
                    propertyType = prop.getType();
                }
                if (propertyType != prop.getType()) {
                    log.info("Property type for {} on Node {} is changing from {} to {} ", propName, fromNode.getName(), prop.getType(), propertyType);
                }
                if (prop.isMultiple()) {
                    toNode.setProperty(propName, prop.getValues(), propertyType);
                } else {
                    toNode.setProperty(propName, prop.getValue(), propertyType);
                }
                prop.remove();
            }
        }
    } catch (RepositoryException e) {
        throw new UpgradeException("Failed to moved property " + propName + " from " + fromNode + " to " + toNode, e);
    }
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) RepositoryException(javax.jcr.RepositoryException) Property(javax.jcr.Property)

Example 14 with UpgradeException

use of com.thinkbiganalytics.server.upgrade.UpgradeException in project kylo by Teradata.

the class ReindexUpgradeAction method upgradeTo.

@Override
public void upgradeTo(final KyloVersion startingVersion) {
    log.info("Re-indexing metadata for version:: {}", startingVersion);
    try {
        Workspace workspace = (Workspace) JcrMetadataAccess.getActiveSession().getWorkspace();
        workspace.reindex();
    } catch (RepositoryException e) {
        log.error("Failed to re-index metadata", e);
        throw new UpgradeException("Failed to re-index metadata", e);
    }
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) RepositoryException(javax.jcr.RepositoryException) Workspace(org.modeshape.jcr.api.Workspace)

Example 15 with UpgradeException

use of com.thinkbiganalytics.server.upgrade.UpgradeException in project kylo by Teradata.

the class CreateDefaultUsersGroupsAction method upgradeTo.

/* (non-Javadoc)
     * @see com.thinkbiganalytics.metadata.upgrade.UpgradeState#upgradeFrom(com.thinkbiganalytics.metadata.api.app.KyloVersion)
     */
@Override
public void upgradeTo(KyloVersion version) {
    log.info("Creating default users/groups for version: " + version);
    User dladmin = createDefaultUser("dladmin", "Data Lake Administrator", null);
    User analyst = createDefaultUser("analyst", "Analyst", null);
    User designer = createDefaultUser("designer", "Designer", null);
    User operator = createDefaultUser("operator", "Operator", null);
    // Create default groups if they don't exist.
    UserGroup adminsGroup = createDefaultGroup("admin", "Administrators");
    UserGroup opsGroup = createDefaultGroup("operations", "Operations");
    UserGroup designersGroup = createDefaultGroup("designers", "Designers");
    UserGroup analystsGroup = createDefaultGroup("analysts", "Analysts");
    UserGroup usersGroup = createDefaultGroup("user", "Users");
    // Add default users to their respective groups
    adminsGroup.addUser(dladmin);
    designersGroup.addUser(designer);
    analystsGroup.addUser(analyst);
    opsGroup.addUser(operator);
    usersGroup.addUser(dladmin);
    usersGroup.addUser(analyst);
    usersGroup.addUser(designer);
    usersGroup.addUser(operator);
    // Setup initial group access control.  Administrators group already has all rights.
    actionsProvider.getAllowedActions(AllowedActions.SERVICES).ifPresent((allowed) -> {
        allowed.enable(opsGroup.getRootPrincial(), OperationsAccessControl.ADMIN_OPS, FeedServicesAccessControl.ACCESS_CATEGORIES, FeedServicesAccessControl.ACCESS_FEEDS, FeedServicesAccessControl.ACCESS_TEMPLATES, FeedServicesAccessControl.ACCESS_TABLES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS);
        allowed.enable(designersGroup.getRootPrincial(), OperationsAccessControl.ACCESS_OPS, FeedServicesAccessControl.EDIT_FEEDS, FeedServicesAccessControl.ACCESS_TABLES, FeedServicesAccessControl.IMPORT_FEEDS, FeedServicesAccessControl.EXPORT_FEEDS, FeedServicesAccessControl.EDIT_CATEGORIES, FeedServicesAccessControl.EDIT_DATASOURCES, FeedServicesAccessControl.EDIT_TEMPLATES, FeedServicesAccessControl.ACCESS_CATALOG, FeedServicesAccessControl.ADMIN_CONNECTORS, FeedServicesAccessControl.IMPORT_TEMPLATES, FeedServicesAccessControl.EXPORT_TEMPLATES, FeedServicesAccessControl.ADMIN_TEMPLATES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.ACCESS_GLOBAL_SEARCH);
        allowed.enable(analystsGroup.getRootPrincial(), OperationsAccessControl.ACCESS_OPS, FeedServicesAccessControl.EDIT_FEEDS, FeedServicesAccessControl.ACCESS_TABLES, FeedServicesAccessControl.IMPORT_FEEDS, FeedServicesAccessControl.EXPORT_FEEDS, FeedServicesAccessControl.EDIT_CATEGORIES, FeedServicesAccessControl.ACCESS_TEMPLATES, FeedServicesAccessControl.ACCESS_CATALOG, FeedServicesAccessControl.ACCESS_CONNECTORS, FeedServicesAccessControl.ACCESS_DATASOURCES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.ACCESS_GLOBAL_SEARCH);
    });
    try {
        Workspace workspace = (Workspace) JcrMetadataAccess.getActiveSession().getWorkspace();
        workspace.reindex("/users");
        workspace.reindex("/groups");
    } catch (RepositoryException e) {
        log.error("Failed to re-index metadata", e);
        throw new UpgradeException("Failed to re-index metadata", e);
    }
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) User(com.thinkbiganalytics.metadata.api.user.User) RepositoryException(javax.jcr.RepositoryException) UserGroup(com.thinkbiganalytics.metadata.api.user.UserGroup) Workspace(org.modeshape.jcr.api.Workspace)

Aggregations

UpgradeException (com.thinkbiganalytics.server.upgrade.UpgradeException)15 RepositoryException (javax.jcr.RepositoryException)11 Node (javax.jcr.Node)7 JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)5 Workspace (org.modeshape.jcr.api.Workspace)4 KyloVersion (com.thinkbiganalytics.KyloVersion)3 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)3 JcrUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrUtil)3 KyloUpgrader (com.thinkbiganalytics.server.upgrade.KyloUpgrader)3 Arrays (java.util.Arrays)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Session (javax.jcr.Session)3 NodeType (javax.jcr.nodetype.NodeType)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Profile (org.springframework.context.annotation.Profile)3 Component (org.springframework.stereotype.Component)3 JcrCategory (com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)2 JcrVersionUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrVersionUtil)2