public Set<Constraint> addConstraints(P2PServiceBaseType service) { // Add requested capacity. NumAttrConstraint capacity = new NumAttrConstraint(); capacity.setAttrName(Point2PointTypes.CAPACITY); capacity.setValue(service.getCapacity()); constraints.add((AttrConstraint) capacity); // Add directionality. StringAttrConstraint directionality = new StringAttrConstraint(); directionality.setAttrName(Point2PointTypes.DIRECTIONALITY); directionality.setValue(DirectionalityType.BIDIRECTIONAL.name()); if (service.getDirectionality() != null) { directionality.setValue(service.getDirectionality().name()); } constraints.add(directionality); // Add symmetric path if service is bidirectional. if (service.getDirectionality() != null && service.getDirectionality() == DirectionalityType.BIDIRECTIONAL) { BooleanAttrConstraint symmetricPath = new BooleanAttrConstraint(); symmetricPath.setAttrName(Point2PointTypes.SYMMETRICPATH); symmetricPath.setValue(false); if (service.isSymmetricPath() != null) { symmetricPath.setValue(service.isSymmetricPath()); } constraints.add(symmetricPath); } // Add the source STP. if (service.getSourceSTP() != null && !service.getSourceSTP().isEmpty()) { StringAttrConstraint srcStp = new StringAttrConstraint(); srcStp.setAttrName(Point2PointTypes.SOURCESTP); srcStp.setValue(service.getSourceSTP()); constraints.add(srcStp); } else { throw new IllegalArgumentException( NsiError.getFindPathErrorString( NsiError.MISSING_PARAMETER, Point2PointTypes.getSourceStp().getNamespace(), Point2PointTypes.getSourceStp().getType(), "null")); } // Add the destination STP. if (service.getDestSTP() != null && !service.getDestSTP().isEmpty()) { StringAttrConstraint dstStp = new StringAttrConstraint(); dstStp.setAttrName(Point2PointTypes.DESTSTP); dstStp.setValue(service.getDestSTP()); constraints.add(dstStp); } else { throw new IllegalArgumentException( NsiError.getFindPathErrorString( NsiError.MISSING_PARAMETER, Point2PointTypes.getDestStp().getNamespace(), Point2PointTypes.getDestStp().getType(), "null")); } // TODO: Still need to add these.... // service.getEro(); // Now add all the generic parameters as string attributes. for (TypeValueType parameter : service.getParameter()) { StringAttrConstraint generic = new StringAttrConstraint(); generic.setAttrName(parameter.getType()); generic.setValue(parameter.getValue()); constraints.add(generic); } return constraints.get(); }