stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From imesh <...@git.apache.org>
Subject [GitHub] stratos pull request: Service group validation
Date Sat, 09 May 2015 16:56:29 GMT
Github user imesh commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/296#discussion_r29994326
  
    --- Diff: components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
---
    @@ -980,50 +981,41 @@ public static void addServiceGroup(GroupBean serviceGroupDefinition)
throws Rest
                 List<String> groupNames;
                 String[] cartridgeGroupNames;
     
    -            // if any cartridges are specified in the group, they should be already deployed
    -            if (serviceGroupDefinition.getCartridges() != null) {
    +            if (log.isDebugEnabled()) {
    +                log.debug("checking cartridges in cartridge group " + serviceGroupDefinition.getName());
    +            }
     
    -                if (log.isDebugEnabled()) {
    -                    log.debug("checking cartridges in cartridge group " + serviceGroupDefinition.getName());
    -                }
    +            findCartridgesInGroupBean(serviceGroupDefinition, cartridgeTypes);
     
    -                findCartridgesInGroupBean(serviceGroupDefinition, cartridgeTypes);
    +            //validate the group definition to check if cartridges duplicate in any groups
defined
    +            validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
     
    -                Set<String> duplicates = findDuplicates(cartridgeTypes);
    -                if (duplicates.size() > 0) {
    -                    StringBuilder duplicatesOutput = new StringBuilder();
    -                    for (String dup : duplicates) {
    -                        duplicatesOutput.append(dup).append(" ");
    -                    }
    -                    if (log.isDebugEnabled()) {
    -                        log.debug("duplicate cartridges defined: " + duplicatesOutput.toString());
    -                    }
    -                    throw new RestAPIException("Invalid Service Group definition, duplicate
cartridges defined:" +
    -                            duplicatesOutput.toString());
    -                }
    +            //validate the group definition to check if groups duplicate in any groups
and
    +            //validate the group definition to check for cyclic group behaviour
    +            validateGroupDuplicationInGroupDefinition(serviceGroupDefinition, new ArrayList<String>());
    --- End diff --
    
    Still I think we could introduce a method overload to avoid passing a new object of ArrayList<String>:
    validateGroupDuplicationInGroupDefinition(serviceGroupDefinition)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message