Example usage for org.apache.solr.common.params CommonParams NAME

List of usage examples for org.apache.solr.common.params CommonParams NAME

Introduction

In this page you can find the example usage for org.apache.solr.common.params CommonParams NAME.

Prototype

String NAME

To view the source code for org.apache.solr.common.params CommonParams NAME.

Click Source Link

Usage

From source file:org.apache.sentry.binding.solr.authz.SolrAuthzUtil.java

License:Apache License

/**
 * This method returns a collection of {@linkplain Config} entities associated with the current
 * operation.//from w w  w .  j a v  a  2  s  .  c om
 */
static Collection<Config> getConfigAuthorizables(AuthorizationContext ctx) {
    List<Config> result = new ArrayList<>(1);
    if (ctx.getHandler() instanceof ConfigSetsHandler) { // For Solr configset APIs
        String name = ctx.getParams().get(CommonParams.NAME);
        if (name != null) {
            result.add(new Config(name));
        }
    } else { // For Solr config APIs
        for (CollectionRequest r : ctx.getCollectionRequests()) {
            result.add(new Config(r.collectionName));
        }
    }
    if (result.isEmpty()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Missing collection name for the config operation with authorization context {}."
                    + " Using * permissions for authorization check", toString(ctx));
        }
        result.add(Config.ALL);
    }

    return result;
}

From source file:org.apache.sentry.binding.solr.authz.SolrAuthzUtil.java

License:Apache License

/**
 * This method extracts the {@linkplain org.apache.sentry.core.model.solr.Collection} entities
 * associated with this admin request and return a mapping of entity_name -> expected_auth_action.
 * This is used by Solr/Sentry authorization plugin to further restrict Solr admin operations.
 *//*from  w  ww  .  ja  va2s . c  o m*/
static Map<String, SolrModelAction> getCollectionsForAdminOp(AuthorizationContext ctx) {
    String actionName = ctx.getParams().get(CoreAdminParams.ACTION);
    CollectionAction action = CollectionAction.get(actionName);
    if (action != null) {
        switch (action) {
        case LISTSNAPSHOTS:
        case BACKUP: {
            String name = ctx.getParams().get(CollectionAdminParams.COLLECTION);
            return (name != null) ? Collections.singletonMap(name, SolrModelAction.QUERY)
                    : Collections.emptyMap();
        }

        case MIGRATE: {
            Map<String, SolrModelAction> result = new HashMap<>();
            String source = ctx.getParams().get(CollectionAdminParams.COLLECTION);
            String target = ctx.getParams().get("target." + CollectionAdminParams.COLLECTION);
            if (source != null) {
                result.put(source, SolrModelAction.QUERY);
            }
            if (target != null) {
                result.put(source, SolrModelAction.UPDATE);
            }
            return result;
        }

        case DELETE:
        case DELETEALIAS:
        case CREATESHARD:
        case DELETESHARD:
        case SPLITSHARD:
        case RELOAD:
        case CREATE: {
            String name = ctx.getParams().get(CommonParams.NAME);
            return (name != null) ? Collections.singletonMap(name, SolrModelAction.UPDATE)
                    : Collections.emptyMap();
        }

        case DELETESNAPSHOT:
        case CREATESNAPSHOT:
        case SYNCSHARD:
        case MOVEREPLICA:
        case RESTORE:
        case MIGRATESTATEFORMAT:
        case FORCELEADER:
        case REBALANCELEADERS:
        case BALANCESHARDUNIQUE:
        case ADDREPLICAPROP:
        case DELETEREPLICAPROP:
        case ADDREPLICA:
        case DELETEREPLICA:
        case MODIFYCOLLECTION: {
            String name = ctx.getParams().get(CollectionAdminParams.COLLECTION);
            return (name != null) ? Collections.singletonMap(name, SolrModelAction.UPDATE)
                    : Collections.emptyMap();
        }

        case MOCK_COLL_TASK:
        case MOCK_REPLICA_TASK:
        case MOCK_SHARD_TASK:
        case REPLACENODE:
        case DELETENODE:
        case ADDROLE:
        case REMOVEROLE:
        case CREATEALIAS:
        case REQUESTSTATUS:
        case DELETESTATUS:
        case LIST:
        case LISTALIASES:
        case CLUSTERPROP:
        case OVERSEERSTATUS:
        case CLUSTERSTATUS: {
            return Collections.emptyMap();
        }
        }
    }

    return Collections.emptyMap();
}