Search in sources :

Example 1 with Owner

use of com.alibaba.dubbo.registry.common.domain.Owner in project dubbo by alibaba.

the class OwnerServiceImpl method toOverrideLiset.

private List<Owner> toOverrideLiset(List<Provider> pList, List<Override> cList) {
    Map<String, Owner> oList = new HashMap<String, Owner>();
    for (Provider p : pList) {
        if (p.getUsername() != null) {
            for (String username : Constants.COMMA_SPLIT_PATTERN.split(p.getUsername())) {
                Owner o = new Owner();
                o.setService(p.getService());
                o.setUsername(username);
                oList.put(o.getService() + "/" + o.getUsername(), o);
            }
        }
    }
    for (Override c : cList) {
        Map<String, String> params = StringUtils.parseQueryString(c.getParams());
        String usernames = params.get("owner");
        if (usernames != null && usernames.length() > 0) {
            for (String username : Constants.COMMA_SPLIT_PATTERN.split(usernames)) {
                Owner o = new Owner();
                o.setService(c.getService());
                o.setUsername(username);
                oList.put(o.getService() + "/" + o.getUsername(), o);
            }
        }
    }
    return new ArrayList<Owner>(oList.values());
}
Also used : Owner(com.alibaba.dubbo.registry.common.domain.Owner) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Override(com.alibaba.dubbo.registry.common.domain.Override) Provider(com.alibaba.dubbo.registry.common.domain.Provider)

Example 2 with Owner

use of com.alibaba.dubbo.registry.common.domain.Owner in project dubbo by alibaba.

the class Owners method delete.

public boolean delete(Long[] ids, Map<String, Object> context) {
    String service = (String) context.get("service");
    String username = (String) context.get("username");
    Owner owner = new Owner();
    owner.setService(service);
    owner.setUsername(username);
    if (service == null || service.length() == 0 || username == null || username.length() == 0) {
        context.put("message", getMessage("NoSuchOperationData"));
        return false;
    }
    if (!super.currentUser.hasServicePrivilege(service)) {
        context.put("message", getMessage("HaveNoServicePrivilege", service));
        return false;
    }
    ownerService.deleteOwner(owner);
    return true;
}
Also used : Owner(com.alibaba.dubbo.registry.common.domain.Owner)

Aggregations

Owner (com.alibaba.dubbo.registry.common.domain.Owner)2 Override (com.alibaba.dubbo.registry.common.domain.Override)1 Provider (com.alibaba.dubbo.registry.common.domain.Provider)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1