RestComm / Restcomm-Connect

The Open Source Cloud Communications Platform
http://www.restcomm.com/
GNU Affero General Public License v3.0
244 stars 215 forks source link

Parser should try to validate attribute properties #2477

Open gvagenas opened 7 years ago

gvagenas commented 7 years ago

at https://github.com/RestComm/Restcomm-Connect/blob/e7f8a9382d5fecc47088333b67e3bffc17388a98/restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/rcml/Parser.java#L120 RC checks if the tag is a verb, next it should check if there are attributes

validations :

etc

carloseluna commented 7 years ago

hello, I was reading this topic, but I don't get the request, can you provide me more information about what is required?

carloseluna commented 7 years ago

Hello

i was reading the code and I think this is what you need, I only made a validation for "Record", let me know if is this that you need in otder to continue with other Verbs

/**from Restcomm-Connect/restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/rcml/Parser.java ****/

private Tag next() {

    boolean shouldContinue=true;
    List<Attribute> mapKeys;  // takes the attributes
    if (iterator != null) {
        while (iterator.hasNext()) {
            final Tag tag = iterator.next();
            if (Verbs.isVerb(tag)) {

                /********************** add validations to verbs******/
                if (tag.hasAttributes()) {

                    mapKeys=tag.attributes();

                    if (tag.name().equals("Record")) {

                        for (Attribute e : mapKeys) {
                             String eName=e.name();
                             double eValue=Double.parseDouble(e.value());

                             if(eName.equals("maxLength")) {
                                 if ( (eValue<0) ||(eValue>100) ) {
                                     // this set maxLength between 0 and 100 sec
                                     //if is set tour of those values the process will not go
                                     shouldContinue=false;
                                 }
                              }

                            }

                } 
            }       
           /******************** end validations ***************/   

                if (current != null && current.hasChildren() && shouldContinue) {
                    final List<Tag> children = current.children();
                    if (children.contains(tag)) {
                        continue;
                    }
                }
                current = tag;
                return current;
            }
        }
    } else {
        if(logger.isInfoEnabled()){
            logger.info("iterator is null");
        }
    }
    return null;
} 
carloseluna commented 7 years ago

Hello Guys

I ha been working in this issue, and I attach a file (in txt) with a solution, please review the code and feel free to give me feedback any time

Perser.txt

regards

deruelle commented 7 years ago

@carloseluna please make sure to read the Open Source playbook and do a Pull request instead which is the proper procedure for a peer review

deruelle commented 7 years ago

@carloseluna Also can you please sign the contributor license agreement at https://telestax.com/open-source/#Contribute ?

carloseluna commented 7 years ago

hello guys,

I had opened a PR in the link above ,just in case I put it here again https://github.com/RestComm/Restcomm-Connect/pull/2516 , thank you in advance