Java Code Examples for org.apache.commons.collections.MapUtils#isEmpty()

The following examples show how to use org.apache.commons.collections.MapUtils#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComplianceController.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the issues details.Request expects asssetGroup and domain as
 * mandatory, ruleId as optional.If API receives assetGroup and domain as
 * request parameter, it gives details of all open issues for all the rules
 * associated to that domain. If API receives assetGroup, domain and ruleId
 * as request parameter,it gives only open issues of that rule associated to
 * that domain. SearchText is used to match any text you are looking
 * for.From and size are for the pagination
 *
 * @param request request body
 * @return issues
 */

@RequestMapping(path = "/v1/issues", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<Object> getIssues(@RequestBody(required = false) Request request) {
    String assetGroup = request.getAg();
    Map<String, String> filters = request.getFilter();

    if (Strings.isNullOrEmpty(assetGroup) || MapUtils.isEmpty(filters)
            || Strings.isNullOrEmpty(filters.get(DOMAIN))) {
        return ResponseUtils.buildFailureResponse(new Exception(ASSET_GROUP_DOMAIN));
    }
    ResponseWithOrder response = null;
    try {
        response = complianceService.getIssues(request);
    } catch (ServiceException e) {
       return complianceService.formatException(e);
    }

    return ResponseUtils.buildSucessResponse(response);
}
 
Example 2
Source File: ResultHelper.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static <T> List<HighlightEntry<T>> convertAndAddHighlightQueryResponseToResultPage(QueryResponse response,
		SolrResultPage<T> page) {
	if (response == null || MapUtils.isEmpty(response.getHighlighting()) || page == null) {
		return Collections.emptyList();
	}

	List<HighlightEntry<T>> mappedHighlights = new ArrayList<HighlightEntry<T>>(page.getSize());
	Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();

	for (T item : page) {
		HighlightEntry<T> highlightEntry = processHighlightingForPageEntry(highlighting, item);
		mappedHighlights.add(highlightEntry);
	}
	page.setHighlighted(mappedHighlights);
	return mappedHighlights;
}
 
Example 3
Source File: EntityGraphRetriever.java    From atlas with Apache License 2.0 6 votes vote down vote up
private Map<String, AtlasObjectId> mapVertexToMapForSoftRef(AtlasVertex entityVertex,  AtlasAttribute attribute, AtlasEntityExtInfo entityExtInfo, final boolean isMinExtInfo) {
    Map<String, AtlasObjectId> ret        = null;
    Map                        softRefVal = entityVertex.getProperty(attribute.getVertexPropertyName(), Map.class);

    if (MapUtils.isEmpty(softRefVal)) {
        return softRefVal;
    } else {
        ret = new HashMap<>();

        for (Object mapKey : softRefVal.keySet()) {
            AtlasObjectId objectId = getAtlasObjectIdFromSoftRefFormat(Objects.toString(softRefVal.get(mapKey)), attribute, entityExtInfo, isMinExtInfo);

            if (objectId != null) {
                ret.put(Objects.toString(mapKey), objectId);
            }
        }
    }
    return ret;
}
 
Example 4
Source File: TeTopologyManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private void mergeLinks(Map<TeLinkTpKey, TeLink> teLinks, TeTopology topology) {
    if (!MapUtils.isEmpty(topology.teLinks())) {
        for (Map.Entry<TeLinkTpKey, TeLink> entry : topology.teLinks().entrySet()) {
            TeLink srcLink = entry.getValue();
            updateSourceTeLink(teLinks, topology.teTopologyId(), srcLink,
                               mergedTopology != null);
        }
    }
}
 
Example 5
Source File: RequestValidator.java    From sunbird-lms-service with MIT License 5 votes vote down vote up
public static void validateSendMail(Request request) {
  if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.SUBJECT))) {
    throw new ProjectCommonException(
        ResponseCode.emailSubjectError.getErrorCode(),
        ResponseCode.emailSubjectError.getErrorMessage(),
        ERROR_CODE);
  }
  if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.BODY))) {
    throw new ProjectCommonException(
        ResponseCode.emailBodyError.getErrorCode(),
        ResponseCode.emailBodyError.getErrorMessage(),
        ERROR_CODE);
  }
  if (CollectionUtils.isEmpty((List<String>) (request.getRequest().get(JsonKey.RECIPIENT_EMAILS)))
      && CollectionUtils.isEmpty(
          (List<String>) (request.getRequest().get(JsonKey.RECIPIENT_USERIDS)))
      && MapUtils.isEmpty(
          (Map<String, Object>) (request.getRequest().get(JsonKey.RECIPIENT_SEARCH_QUERY)))
      && CollectionUtils.isEmpty(
          (List<String>) (request.getRequest().get(JsonKey.RECIPIENT_PHONES)))) {
    throw new ProjectCommonException(
        ResponseCode.mandatoryParamsMissing.getErrorCode(),
        MessageFormat.format(
            ResponseCode.mandatoryParamsMissing.getErrorMessage(),
            StringFormatter.joinByOr(
                StringFormatter.joinByComma(
                    JsonKey.RECIPIENT_EMAILS,
                    JsonKey.RECIPIENT_USERIDS,
                    JsonKey.RECIPIENT_PHONES),
                JsonKey.RECIPIENT_SEARCH_QUERY)),
        ERROR_CODE);
  }
}
 
Example 6
Source File: ConsumerConnectionState.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
public void handleAddConsumers() {
    if (MapUtils.isEmpty(consumerMap)) {
        return;
    }
    try {
        for (Map.Entry<String, Set<String>> entry : consumerMap.entrySet()) {
            doHandleAddConsumers(Lists.newArrayList(entry.getValue()), entry.getKey());
        }
    } catch (Exception e) {
        logger.error("add consumer exception, consumerMap: {}", consumerMap, e);
        consumerMap.clear();
    }
}
 
Example 7
Source File: DirectDownloadManagerImpl.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
/**
 * Return HTTP headers from template details
 * @param templateDetails
 * @return
 */
protected Map<String, String> getHeadersFromDetails(Map<String, String> templateDetails) {
    if (MapUtils.isEmpty(templateDetails)) {
        return new HashMap<>();
    }
    Map<String, String> headers = new HashMap<>();
    for (String key : templateDetails.keySet()) {
        if (key.startsWith(httpHeaderDetailKey)) {
            String header = key.split(":")[1];
            String value = templateDetails.get(key);
            headers.put(header, value);
        }
    }
    return headers;
}
 
Example 8
Source File: PropertiesUtil.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
public static Properties map2Properties(Map<?, ?> map) {
    Properties properties = new Properties();
    if (!MapUtils.isEmpty(map)) {
        for (Object key : map.keySet()) {
            properties.put(key, map.get(key));
        }
    }
    return properties;
}
 
Example 9
Source File: EntityAuditListener.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void restoreEntityAttributes(Referenceable entity, Map<String, Object> prunedAttributes) throws AtlasException {
    if (MapUtils.isEmpty(prunedAttributes)) {
        return;
    }

    AtlasEntityType     entityType       = typeRegistry.getEntityTypeByName(entity.getTypeName());

    if (entityType != null && MapUtils.isNotEmpty(entityType.getAllAttributes())) {
        Map<String, Object> entityAttributes = entity.getValuesMap();

        for (AtlasStructType.AtlasAttribute attribute : entityType.getAllAttributes().values()) {
            String attrName  = attribute.getName();
            Object attrValue = entityAttributes.get(attrName);

            if (prunedAttributes.containsKey(attrName)) {
                entity.set(attrName, prunedAttributes.get(attrName));
            } else if (attribute.isOwnedRef()) {
                if (attrValue instanceof Collection) {
                    for (Object arrElem : (Collection) attrValue) {
                        if (arrElem instanceof Referenceable) {
                            restoreAttributes(prunedAttributes, (Referenceable) arrElem);
                        }
                    }
                } else if (attrValue instanceof Referenceable) {
                    restoreAttributes(prunedAttributes, (Referenceable) attrValue);
                }
            }
        }
    }
}
 
Example 10
Source File: RedisGetAll.java    From ECFileCache with Apache License 2.0 5 votes vote down vote up
@Override
protected int doRequest(Jedis jedis, String redisAddress) {
  Map<byte[], byte[]> redisData = jedis.hgetAll(key.getBytes());
  redisDataList[index] = redisData;
  if (MapUtils.isEmpty(redisData)) {
    String verbose = String.format("get all for key [%s] from [%s] is empty", key, redisAddress);
    LOGGER.debug(verbose);
    return 1;
  }
  return 0;
}
 
Example 11
Source File: FeedProcessorImpl.java    From rufus with MIT License 5 votes vote down vote up
private List<Article> articlesFromChannelMap(long userId, Map<Channel, List<Document>> channelMap, int limit) {
    if (MapUtils.isEmpty(channelMap)) {
        return Collections.emptyList();
    }
    Map<Channel, List<Document>> filteredMap = new HashMap<>();
    channelMap.entrySet().forEach(e -> filteredMap.put(e.getKey(), e.getValue().stream().limit(limit).collect(Collectors.toList())));

    List<Article> articles = new ArrayList<>();
    filteredMap.entrySet().forEach(e -> articles.addAll(Article.of(e.getKey(), e.getValue().stream().collect(Collectors.toList()))));

    FeedUtils.markBookmarks(articles, articleDao.getBookmarked(userId));
    return FeedUtils.sort(articles);
}
 
Example 12
Source File: DefaultCoordinatorMonitorService.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
protected ConcurrentMap<String, GroupMemberMetadata> formatCoordinatorGroupMembers(GroupMetadata group, String topic) {
    if (MapUtils.isEmpty(group.getMembers())) {
        return null;
    }
    ConcurrentMap<String, GroupMemberMetadata> result = Maps.newConcurrentMap();
    for (Map.Entry<String, GroupMemberMetadata> entry : group.getMembers().entrySet()) {
        GroupMemberMetadata sourceMember = entry.getValue();

        if (StringUtils.isNotBlank(topic) && sourceMember.getAssignments() != null && !sourceMember.getAssignments().containsKey(topic)) {
            continue;
        }

        GroupMemberMetadata member = new GroupMemberMetadata();
        member.setId(sourceMember.getId());
        member.setGroupId(sourceMember.getGroupId());
        member.setConnectionId(sourceMember.getConnectionId());
        member.setConnectionHost(sourceMember.getConnectionHost());
        member.setLatestHeartbeat(sourceMember.getLatestHeartbeat());
        member.setSessionTimeout(sourceMember.getSessionTimeout());

        if (StringUtils.isBlank(topic)) {
            member.setAssignments(sourceMember.getAssignments());
        } else if (MapUtils.isNotEmpty(sourceMember.getAssignments())) {
            member.setAssignmentList(sourceMember.getAssignments().get(topic));
        }
        result.put(entry.getKey(), member);
    }
    return result;
}
 
Example 13
Source File: SAMLAssertionClaimsCallback.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
private static Map<String, Object> getClaimsFromUserStore(OAuthAuthzReqMessageContext requestMsgCtx)
        throws IdentityApplicationManagementException, IdentityException, UserStoreException,
        ClaimManagementException {

    AuthenticatedUser user = requestMsgCtx.getAuthorizationReqDTO().getUser();
    String tenantDomain = requestMsgCtx.getAuthorizationReqDTO().getUser().getTenantDomain();

    UserRealm realm;
    List<String> claimURIList = new ArrayList<String>();
    Map<String, Object> mappedAppClaims = new HashMap<String, Object>();

    ApplicationManagementService applicationMgtService = OAuth2ServiceComponentHolder.getApplicationMgtService();
    String spName = applicationMgtService
            .getServiceProviderNameByClientId(requestMsgCtx.getAuthorizationReqDTO().getConsumerKey(),
                    INBOUND_AUTH2_TYPE, tenantDomain);
    ServiceProvider serviceProvider = applicationMgtService.getApplicationExcludingFileBasedSPs(spName,
            tenantDomain);
    if (serviceProvider == null) {
        return mappedAppClaims;
    }

    realm = IdentityTenantUtil.getRealm(tenantDomain, user.toString());
    if (realm == null) {
        log.warn("No valid tenant domain provider. Empty claim returned back for tenant " + tenantDomain
                + " and user " + user);
        return new HashMap<>();
    }

    Map<String, String> spToLocalClaimMappings;
    UserStoreManager userStoreManager = realm.getUserStoreManager();
    ClaimMapping[] requestedLocalClaimMap = serviceProvider.getClaimConfig().getClaimMappings();

    if (requestedLocalClaimMap != null && requestedLocalClaimMap.length > 0) {

        for (ClaimMapping mapping : requestedLocalClaimMap) {
            if (mapping.isRequested()) {
                claimURIList.add(mapping.getLocalClaim().getClaimUri());
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("Requested number of local claims: " + claimURIList.size());
        }

        spToLocalClaimMappings = ClaimManagerHandler.getInstance().getMappingsMapFromOtherDialectToCarbon(
                SP_DIALECT, null, tenantDomain, false);

        Map<String, String> userClaims = null;
        try {
            userClaims = userStoreManager.getUserClaimValues(UserCoreUtil.addDomainToName(user.getUserName(),
                    user.getUserStoreDomain()), claimURIList.toArray(new String[claimURIList.size()]),null);
        } catch (UserStoreException e) {
            if (e.getMessage().contains("UserNotFound")) {
                if (log.isDebugEnabled()) {
                    log.debug("User " + user + " not found in user store");
                }
            } else {
                throw e;
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("Number of user claims retrieved from user store: " + userClaims.size());
        }

        if (MapUtils.isEmpty(userClaims)) {
            return new HashMap<>();
        }

        for (Iterator<Map.Entry<String, String>> iterator = spToLocalClaimMappings.entrySet().iterator(); iterator
                .hasNext(); ) {
            Map.Entry<String, String> entry = iterator.next();
            String value = userClaims.get(entry.getValue());
            if (value != null) {
                mappedAppClaims.put(entry.getKey(), value);
                if (log.isDebugEnabled() &&
                        IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
                    log.debug("Mapped claim: key -  " + entry.getKey() + " value -" + value);
                }
            }
        }

        RealmConfiguration realmConfiguration = userStoreManager.getSecondaryUserStoreManager(user.getUserStoreDomain())
                .getRealmConfiguration();

        String claimSeparator = realmConfiguration.getUserStoreProperty(
                IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
        if (StringUtils.isNotBlank(claimSeparator)) {
            mappedAppClaims.put(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR, claimSeparator);
        }
    }
    return mappedAppClaims;
}
 
Example 14
Source File: KontoCache.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public boolean isEmpty()
{
  checkRefresh();
  return MapUtils.isEmpty(accountMapById);
}
 
Example 15
Source File: ProvisioningUtil.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
public static Map<ClaimMapping, List<String>> getMappedClaims(String outboundClaimDialect,
                                                              Map<String, String> inboundClaimValueMap, ClaimMapping[] inboundClaimMappings,
                                                              Map<ClaimMapping, List<String>> outboundClaimValueMappings, String tenantDomain)
        throws IdentityApplicationManagementException {

    try {

        // we do have in-bound claim mapping - but no out-bound claim mapping - no out-bound
        // default values.since we do not know the out-bound claim mapping - whatever in the
        // in-bound claims will be mapped into the out-bound claim dialect.

        if (MapUtils.isEmpty(inboundClaimValueMap)) {
            // we do not have out-bound claim mapping - and a default values to worry about.
            // just return what we got.
            return outboundClaimValueMappings;
        }

        Map<String, String> claimMap = null;

        // out-bound is not in wso2 carbon dialect. we need to find how it maps to wso2
        // carbon dialect.
        Map<String, String> outBoundToCarbonClaimMapppings = null;

        // we only know the dialect - it is a standard claim dialect.
        // this returns back a map - having carbon claim dialect as the key.
        // null argument is passed - because we do not know the required attributes for
        // out-bound provisioning. This will find carbon claim mappings for the entire out-bound
        // claim dialect.
        outBoundToCarbonClaimMapppings = ClaimMetadataHandler.getInstance()
                .getMappingsMapFromOtherDialectToCarbon(outboundClaimDialect, null,
                        tenantDomain, true);

        if (outBoundToCarbonClaimMapppings == null) {
            // we did not find any carbon claim mappings corresponding to the out-bound claim
            // dialect - we cannot map the in-bound claim dialect to out-bound claim dialect.
            // just return what we got.
            return outboundClaimValueMappings;
        }

        // {in-bound-claim-uri / out-bound-claim-uri
        claimMap = new HashMap<String, String>();

        for (ClaimMapping inboundClaimMapping : inboundClaimMappings) {
            // there can be a claim mapping without a mapped local claim.
            // if that is the case - we cannot map it to an out-bound claim.
            if (inboundClaimMapping.getLocalClaim() == null
                    || inboundClaimMapping.getLocalClaim().getClaimUri() == null) {
                if (log.isDebugEnabled()) {
                    log.debug("Inbound claim - local claim is null");
                }
                continue;
            }

            // get the out-bound claim corresponding to the carbon dialect - which is the key.
            String outboundClaim = outBoundToCarbonClaimMapppings.get(inboundClaimMapping
                    .getLocalClaim().getClaimUri());

            if (outboundClaim != null) {
                // in-bound claim uri / out-bound claim uri.
                if (inboundClaimMapping.getRemoteClaim() != null
                        && inboundClaimMapping.getRemoteClaim().getClaimUri() != null) {
                    claimMap.put(inboundClaimMapping.getRemoteClaim().getClaimUri(),
                            outboundClaim);
                }
            }
        }

        if (claimMap.isEmpty()) {
            // we do not have a claim map.
            // return what we got.
            return outboundClaimValueMappings;
        }

        for (Iterator<Map.Entry<String, String>> iterator = claimMap.entrySet().iterator(); iterator
                .hasNext(); ) {
            Map.Entry<String, String> entry = iterator.next();

            String inboundClaimUri = entry.getKey();
            String outboundClaimUri = entry.getValue();
            String claimValue = null;

            if (outboundClaimUri != null) {
                claimValue = inboundClaimValueMap.get(inboundClaimUri);
            }
            // null value goes there because we do not have an out-bound claim mapping - and
            // also default values.
            if (claimValue != null) {
                outboundClaimValueMappings.put(
                        ClaimMapping.build(inboundClaimUri, outboundClaimUri, null, false),
                        Arrays.asList(new String[]{claimValue}));
            }
        }

    } catch (Exception e) {
        throw new IdentityApplicationManagementException("Error while loading claim mappings.",
                e);
    }

    return outboundClaimValueMappings;
}
 
Example 16
Source File: EmailServiceActor.java    From sunbird-lms-service with MIT License 4 votes vote down vote up
private void getUserEmailsFromSearchQuery(
    Map<String, Object> request, List<String> emails, List<String> userIds) {
  Map<String, Object> recipientSearchQuery =
      (Map<String, Object>) request.get(JsonKey.RECIPIENT_SEARCH_QUERY);
  if (MapUtils.isNotEmpty(recipientSearchQuery)) {

    if (MapUtils.isEmpty((Map<String, Object>) recipientSearchQuery.get(JsonKey.FILTERS))) {
      ProjectCommonException.throwClientErrorException(
          ResponseCode.invalidParameterValue,
          MessageFormat.format(
              ResponseCode.invalidParameterValue.getErrorMessage(),
              recipientSearchQuery,
              JsonKey.RECIPIENT_SEARCH_QUERY));
      return;
    }

    List<String> fields = new ArrayList<>();
    fields.add(JsonKey.USER_ID);
    fields.add(JsonKey.EMAIL);
    recipientSearchQuery.put(JsonKey.FIELDS, fields);
    Map<String, Object> esResult = Collections.emptyMap();
    try {
      Future<Map<String, Object>> esResultF =
          esService.search(
              ElasticSearchHelper.createSearchDTO(recipientSearchQuery),
              EsType.user.getTypeName());
      esResult = (Map<String, Object>) ElasticSearchHelper.getResponseFromFuture(esResultF);
    } catch (Exception ex) {
      ProjectLogger.log(
          "EmailServiceActor:getUserEmailsFromSearchQuery: Exception occurred with error message = "
              + ex.getMessage(),
          ex);
      ProjectCommonException.throwClientErrorException(
          ResponseCode.invalidParameterValue,
          MessageFormat.format(
              ResponseCode.invalidParameterValue.getErrorMessage(),
              recipientSearchQuery,
              JsonKey.RECIPIENT_SEARCH_QUERY));
      return;
    }
    if (MapUtils.isNotEmpty(esResult)
        && CollectionUtils.isNotEmpty((List) esResult.get(JsonKey.CONTENT))) {
      List<Map<String, Object>> usersList =
          (List<Map<String, Object>>) esResult.get(JsonKey.CONTENT);
      usersList.forEach(
          user -> {
            if (StringUtils.isNotBlank((String) user.get(JsonKey.EMAIL))) {
              String email = decryptionService.decryptData((String) user.get(JsonKey.EMAIL));
              if (ProjectUtil.isEmailvalid(email)) {
                emails.add(email);
              } else {
                ProjectLogger.log(
                    "EmailServiceActor:sendMail: Email decryption failed for userId = "
                        + user.get(JsonKey.USER_ID));
              }
            } else {
              // If email is blank (or private) then fetch email from cassandra
              userIds.add((String) user.get(JsonKey.USER_ID));
            }
          });
    }
  }
}
 
Example 17
Source File: UserRoleActor.java    From sunbird-lms-service with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void assignRoles(Request actorMessage) {
  ProjectLogger.log("UserRoleActor: assignRoles called");

  Map<String, Object> requestMap = actorMessage.getRequest();
  RoleService.validateRoles((List<String>) requestMap.get(JsonKey.ROLES));

  boolean orgNotFound = initializeHashTagIdFromOrg(requestMap);
  if (orgNotFound) return;

  String userId = (String) requestMap.get(JsonKey.USER_ID);
  String hashTagId = (String) requestMap.get(JsonKey.HASHTAGID);
  String organisationId = (String) requestMap.get(JsonKey.ORGANISATION_ID);
  // update userOrg role with requested roles.
  Map<String, Object> userOrgDBMap = new HashMap<>();

  Map<String, Object> searchMap = new HashMap<>();
  searchMap.put(JsonKey.USER_ID, userId);
  searchMap.put(JsonKey.ORGANISATION_ID, organisationId);
  searchMap.put(JsonKey.IS_DELETED, false);
  Response res =
      cassandraOperation.getRecordsByProperties(JsonKey.SUNBIRD, JsonKey.USER_ORG, searchMap);
  List<Map<String, Object>> responseList = (List<Map<String, Object>>) res.get(JsonKey.RESPONSE);
  if (CollectionUtils.isNotEmpty(responseList)) {
    userOrgDBMap.put(JsonKey.ORGANISATION, responseList.get(0));
  }

  if (MapUtils.isEmpty(userOrgDBMap)) {
    ProjectCommonException.throwClientErrorException(ResponseCode.invalidUsrOrgData, null);
  }

  UserOrg userOrg = prepareUserOrg(requestMap, hashTagId, userOrgDBMap);
  UserOrgDao userOrgDao = UserOrgDaoImpl.getInstance();

  Response response = userOrgDao.updateUserOrg(userOrg);
  sender().tell(response, self());
  if (((String) response.get(JsonKey.RESPONSE)).equalsIgnoreCase(JsonKey.SUCCESS)) {
    syncUserRoles(requestMap, JsonKey.ORGANISATION, userId, organisationId);
  } else {
    ProjectLogger.log("UserRoleActor: No ES call to save user roles");
  }
  generateTelemetryEvent(requestMap, userId, "userLevel", actorMessage.getContext());
}
 
Example 18
Source File: MapUtil.java    From smart-framework with Apache License 2.0 4 votes vote down vote up
/**
 * 判断 Map 是否为空
 */
public static boolean isEmpty(Map<?, ?> map) {
    return MapUtils.isEmpty(map);
}
 
Example 19
Source File: EntityGraphMapper.java    From atlas with Apache License 2.0 4 votes vote down vote up
public void setBusinessAttributes(AtlasVertex entityVertex, AtlasEntityType entityType, Map<String, Map<String, Object>> businessAttributes) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> setBusinessAttributes(entityVertex={}, entityType={}, businessAttributes={}", entityVertex, entityType.getTypeName(), businessAttributes);
    }

    Map<String, Map<String, AtlasBusinessAttribute>> entityTypeBusinessAttributes = entityType.getBusinessAttributes();
    Map<String, Map<String, Object>>                 updatedBusinessAttributes    = new HashMap<>();

    for (Map.Entry<String, Map<String, AtlasBusinessAttribute>> entry : entityTypeBusinessAttributes.entrySet()) {
        String                              bmName             = entry.getKey();
        Map<String, AtlasBusinessAttribute> bmAttributes       = entry.getValue();
        Map<String, Object>                 entityBmAttributes = MapUtils.isEmpty(businessAttributes) ? null : businessAttributes.get(bmName);

        for (AtlasBusinessAttribute bmAttribute : bmAttributes.values()) {
            String bmAttrName          = bmAttribute.getName();
            Object bmAttrExistingValue = entityVertex.getProperty(bmAttribute.getVertexPropertyName(), Object.class);
            Object bmAttrNewValue      = MapUtils.isEmpty(entityBmAttributes) ? null : entityBmAttributes.get(bmAttrName);

            if (bmAttrExistingValue == null) {
                if (bmAttrNewValue != null) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("setBusinessAttributes(): adding {}.{}={}", bmName, bmAttribute.getName(), bmAttrNewValue);
                    }

                    mapAttribute(bmAttribute, bmAttrNewValue, entityVertex, CREATE, new EntityMutationContext());

                    addToUpdatedBusinessAttributes(updatedBusinessAttributes, bmAttribute, bmAttrNewValue);
                }
            } else {
                if (bmAttrNewValue != null) {
                    if (!Objects.equals(bmAttrExistingValue, bmAttrNewValue)) {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("setBusinessAttributes(): updating {}.{}={}", bmName, bmAttribute.getName(), bmAttrNewValue);
                        }

                        mapAttribute(bmAttribute, bmAttrNewValue, entityVertex, UPDATE, new EntityMutationContext());

                        addToUpdatedBusinessAttributes(updatedBusinessAttributes, bmAttribute, bmAttrNewValue);
                    }
                } else {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("setBusinessAttributes(): removing {}.{}", bmName, bmAttribute.getName());
                    }

                    entityVertex.removeProperty(bmAttribute.getVertexPropertyName());

                    addToUpdatedBusinessAttributes(updatedBusinessAttributes, bmAttribute, bmAttrNewValue);
                }
            }
        }
    }

    if (MapUtils.isNotEmpty(updatedBusinessAttributes)) {
        entityChangeNotifier.onBusinessAttributesUpdated(AtlasGraphUtilsV2.getIdFromVertex(entityVertex), updatedBusinessAttributes);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== setBusinessAttributes(entityVertex={}, entityType={}, businessAttributes={}", entityVertex, entityType.getTypeName(), businessAttributes);
    }
}
 
Example 20
Source File: PermissionInterceptor.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (MapUtils.isEmpty(nonMatchURIMap)) throw new IllegalArgumentException("property 'nonMatchURIMap' is empty!");

}