public override void Validate(SoaModel model) { foreach (Expression expression in model.Instances.OfType<Expression>().Where(expr => (expr.Parent == null))) { this.Validate_Expression(expression); } }
public XsdWsdlRefactor(SoaModel model, string wsdlFile) { this.Path = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(wsdlFile)); //this.FileName = "HelloNamespace.wsdl"; //this.FileName = @"\test50\hello_world_schema_import.wsdl"; this.FileName = System.IO.Path.GetFileName(wsdlFile); this.Logging = true; this.Model = model; //this.Model = new SoaModel(); }
/// <summary> /// Validate declaration and field name casing. /// </summary> /// <param name="model">The model to validate.</param> private void Validate_Casing(SoaModel model) { foreach (Declaration declaration in model.Instances.Where(obj => !obj.HasMetaInfo<SoaMetaModel.MetaInfo.HiddenInfo>()).OfType<Declaration>()) { if (!(declaration is ArrayType || declaration is NullableType)) { if (Char.IsLower(declaration.Name[0])) { Console.WriteLine(declaration.Name); Warning_NameLowerCase(declaration, declaration.Name); } } } foreach (Field field in model.Instances.OfType<Field>()) { if (Char.IsLower(field.Name[0])) { Warning_NameLowerCase(field, field.Name); } } }
/// <summary> /// Validate declaration name collision. /// </summary> /// <param name="model">The model to validate.</param> private void Validate_Collision(SoaModel model) { // Types involved in possible name collision HashSet<System.Type> collidable = new HashSet<System.Type> { typeof(StructType), typeof(EnumType), typeof(ExceptionType), typeof(ClaimsetType), typeof(Interface), typeof(Authorization), typeof(Contract), typeof(Endpoint) }; // The scope of name collision is a namespace foreach (Namespace ns in model.Instances.OfType<Namespace>()) { Dictionary<string, Declaration> declarations = new Dictionary<string, Declaration>(); foreach (Declaration declaration in ns.Declarations.Where(decl => collidable.Contains(decl.GetType()))) { if (declarations.ContainsKey(declaration.Name)) { Error_NameCollision(declaration, declarations[declaration.Name]); } else { declarations.Add(declaration.Name, declaration); } } } }
/// <summary> /// The main validator method. /// </summary> /// <param name="model">The model to validate.</param> public override void Validate(SoaModel model) { this.Validate_Collision(model); this.Validate_Casing(model); }
/// <summary> /// The main validator method. /// </summary> /// <param name="model">The model to validate.</param> public abstract void Validate(SoaModel model);
private static void Refactor(SoaModel model, Options options, ErrorReporter er) { foreach (string input in options.InputFiles) { Refactor(model, input, er); } }
public static void Main(string[] args) { try { /* string soalFile = @"..\..\soal\Hello.soal"; string projectName = @"HelloWeb"; //*/ /* string soalFile = @"..\..\soal\WsPerfTest.soal"; string projectName = @"WsPerfTest"; //*/ /* string soalFile = @"..\..\soal\WsPerfTestAdv.soal"; string projectName = @"WsPerfTestAdv"; //*/ /* string soalFile = @"..\..\soal\WsInteropTest.soal"; string projectName = @"WsInteropTest"; //*/ /* string soalFile = @"..\..\soal\Bank.soal"; string projectName = @"Bank"; //*/ /* string soalFile = @"..\..\soal\Calculator.soal"; string projectName = @"Calculator"; //*/ /* string soalFile = @"..\..\soal\TopDown.soal"; string projectName = @"TopDown"; //*/ /* string soalFile = @"..\..\soal\WineShop.soal"; string projectName = @"WineShop"; //*/ /* string soalFile = @"..\..\soal\SoiSamples1.soal"; string projectName = @"SoiSamples1"; //*/ /* string soalFile = @"..\..\soal\OrderProcess.soal"; string projectName = @"OrderProcess"; //*/ /* string soalFile = @"..\..\soal\SoiXmlWsApi.soal"; string projectName = @"SoiXmlWsApi"; //*/ /* string soalFile = @"..\..\soal\SeatReservation.soal"; string projectName = @"SeatReservation"; //*/ /* string soalFile = @"..\..\soal\BpelCinemaReservation.soal"; string projectName = @"CinemaReservation"; //*/ //string outputDir = @"..\..\soal\Output"; //args = new string[] { soalFile, "--no-implementation-delegates", /*"--generate-implementation-base",*/ "--output", outputDir, "--netbeans-project", projectName, "--jboss-project", projectName, "--tomcat-project", projectName, "--rad-project", projectName, "--oracle-project", projectName, "--visualstudio-project", projectName }; Options options = new Options(args); if (options.InputFiles == null || options.InputFiles.Length == 0) { Console.WriteLine("Usage:"); Console.WriteLine("SoaMM.exe input.soal [--output OutputDir] [--visualstudio-project VSProjectName] [--netbeans-project NBProjectName] [--jboss-project JBossProjectName] [--tomcat-project TomcatProjectName] [--rad-project IbmRadProjectName] [--oracle-project OracleProjectName] [--rest]"); return; } ErrorReporter er = new TextWriterReporter(); SoaModel model = new SoaModel(); using (new ModelContextScope<SoaModel>(model)) { Parse(model, options, er); // Refactor(model, options, er); Generate(model, options); } } catch (Exception e) { Console.WriteLine(e); } }
private static void Refactor(SoaModel model, string input, ErrorReporter er) { //XsdWsdlRefactor refactor = new XsdWsdlRefactor(); //refactor.Run(); }
private static void Parse(SoaModel model, string input, ErrorReporter er) { SoaLanguageContext lc = new SoaLanguageContext(new FileInfo(input).Name); dynamic root = SoaLanguage.Load().Parse(new StreamReader(input), er); new DeclarationParser(er, lc).Parse(root); new MemberParser(er, lc).Parse(root); new ExpressionParser(er, lc).Parse(root); new NameValidator(er, lc).Validate(model); new BindingValidator(er, lc).Validate(model); new ExpressionValidator(er, lc).Validate(model); }
private static void Generate(SoaModel model, Options options) { options.OutputDir = Path.GetFullPath(options.OutputDir); IEnumerable<SoaObject> visible = model.Instances.Where(obj => !obj.HasMetaInfo<SoaMetaModel.MetaInfo.HiddenInfo>()); if (options.GenerateXsdWsdl) { XsdWsdlGenerator xsdWsdlGenerator = new XsdWsdlGenerator(visible, new GeneratorContext()); xsdWsdlGenerator.Properties.OutputDir = options.OutputDir+"/common"; xsdWsdlGenerator.Execute(); xsdWsdlGenerator = new XsdWsdlGenerator(visible, new GeneratorContext()); xsdWsdlGenerator.Properties.OutputDir = options.OutputDir + "/common/single"; xsdWsdlGenerator.Properties.GenerateSingleWsdl = true; xsdWsdlGenerator.Properties.GenerateSeparateXsdWsdlFolder = false; xsdWsdlGenerator.Execute(); } if (options.GenerateNetbeans) { NetbeansGenerator netbeansGenerator = new NetbeansGenerator(visible, new GeneratorContext()); netbeansGenerator.Properties.OutputDir = options.OutputDir; netbeansGenerator.Properties.ProjectName = options.NetbeansProject; netbeansGenerator.Properties.NoImplementationDelegates = options.GenerateNoImplementationDelegates; netbeansGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; netbeansGenerator.Properties.GenerateImplementationBase = options.GenerateImplementationBase; netbeansGenerator.Properties.GenerateRestfulWebService = options.GenerateRestfulWebService; netbeansGenerator.Execute(); } if (options.GenerateJBoss) { JBossCxfGenerator jbossGenerator = new JBossCxfGenerator(visible, new GeneratorContext()); jbossGenerator.Properties.OutputDir = options.OutputDir; jbossGenerator.Properties.ProjectName = options.JBossProject; jbossGenerator.Properties.NoImplementationDelegates = options.GenerateNoImplementationDelegates; jbossGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; jbossGenerator.Properties.GenerateImplementationBase = options.GenerateImplementationBase; jbossGenerator.Properties.GenerateRestfulWebService = options.GenerateRestfulWebService; jbossGenerator.Execute(); } if (options.GenerateTomcat) { TomcatCxfGenerator tomcatGenerator = new TomcatCxfGenerator(visible, new GeneratorContext()); tomcatGenerator.Properties.OutputDir = options.OutputDir; tomcatGenerator.Properties.ProjectName = options.TomcatProject; tomcatGenerator.Properties.NoImplementationDelegates = options.GenerateNoImplementationDelegates; tomcatGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; tomcatGenerator.Properties.GenerateImplementationBase = options.GenerateImplementationBase; tomcatGenerator.Properties.GenerateRestfulWebService = options.GenerateRestfulWebService; tomcatGenerator.Execute(); } if (options.GenerateIbm) { IbmRadGenerator ibmGenerator = new IbmRadGenerator(visible, new GeneratorContext()); ibmGenerator.Properties.OutputDir = options.OutputDir; ibmGenerator.Properties.ProjectName = options.JBossProject; ibmGenerator.Properties.NoImplementationDelegates = options.GenerateNoImplementationDelegates; ibmGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; ibmGenerator.Properties.GenerateImplementationBase = options.GenerateImplementationBase; ibmGenerator.Properties.GenerateRestfulWebService = options.GenerateRestfulWebService; ibmGenerator.Execute(); } if (options.GenerateOracle) { OracleGenerator oracleGenerator = new OracleGenerator(visible, new GeneratorContext()); oracleGenerator.Properties.OutputDir = options.OutputDir; oracleGenerator.Properties.ProjectName = options.OracleProject; oracleGenerator.Properties.NoImplementationDelegates = options.GenerateNoImplementationDelegates; oracleGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; oracleGenerator.Properties.GenerateImplementationBase = options.GenerateImplementationBase; oracleGenerator.Properties.GenerateRestfulWebService = options.GenerateRestfulWebService; oracleGenerator.Execute(); } if (options.GenerateVS) { if (options.GenerateRestfulWebService) { VSRestGenerator vsRestGenerator = new VSRestGenerator(visible, new GeneratorContext()); vsRestGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; vsRestGenerator.Properties.OutputDir = options.OutputDir; vsRestGenerator.Properties.ProjectName = options.VSProject; vsRestGenerator.Execute(); } else { VSSoapGenerator vsSoapGenerator = new VSSoapGenerator(visible, new GeneratorContext()); vsSoapGenerator.Properties.NoImplementationDelegates = options.GenerateNoImplementationDelegates; vsSoapGenerator.Properties.ThrowNotImplementedException = !options.GenerateNoUnimplementedException; vsSoapGenerator.Properties.GenerateImplementationBase = options.GenerateImplementationBase; vsSoapGenerator.Properties.OutputDir = options.OutputDir; vsSoapGenerator.Properties.ProjectName = options.VSProject; vsSoapGenerator.Execute(); } } }
public override void Validate(SoaModel model) { foreach (Binding binding in model.Instances.OfType<Binding>()) { Validate_BindingElementProperties(binding.Transport); Validate_BindingElementProperties(binding.Encoding); SecurityProtocolBindingElement security = null; BootstrapProtocolBindingElement bootstrap = null; foreach (ProtocolBindingElement element in binding.Protocols) { if (element is SecurityProtocolBindingElement) { if (security == null) { security = (SecurityProtocolBindingElement)element; } else { Error_MultipleProtocol(element, "security"); } } if (element is BootstrapProtocolBindingElement) { if (bootstrap == null) { bootstrap = (BootstrapProtocolBindingElement)element; } else { Error_MultipleProtocol(element, "bootstrap"); } } Validate_BindingElementProperties(element); } if ((security != null) && (security is SecureConversationSecurityProtocolBindingElement)) { if (bootstrap == null) { Error_MissingProtocol(security, "bootstrap"); } else { ((SecureConversationSecurityProtocolBindingElement)security).Bootstrap = bootstrap; } } if ((bootstrap != null) && ((security == null) || !(security is SecureConversationSecurityProtocolBindingElement))) { Error_MissingProtocol(bootstrap, "secure conversation"); } // Set up claims if necessary if (security != null && security is SamlSecurityProtocolBindingElement) { Validate_Claims(binding, ((SamlSecurityProtocolBindingElement)security).Claims, model); } if (bootstrap != null && bootstrap is SamlBootstrapProtocolBindingElement) { Validate_Claims(binding, ((SamlBootstrapProtocolBindingElement)bootstrap).Claims, model); } } }
private void Validate_Claims(Binding binding, ModelList<ClaimsetType> claims, SoaModel model) { foreach (Endpoint endpoint in model.Instances.OfType<Endpoint>().Where(ep => ep.Binding == binding)) { Authorization authorization = endpoint.Authorization; if (authorization != null) { foreach (OperationAuthorization operation in authorization.OperationAuthorizations) { foreach (Reference reference in operation.References.Where(rf => rf.Object is ClaimsetType)) { ClaimsetType claimset = (ClaimsetType)reference.Object; if (!claims.Contains(claimset)) { claims.Add(claimset); } } foreach (Reference reference in operation.References.Where(rf => rf.Object is ClaimField)) { ClaimsetType claimset = ((ClaimField)reference.Object).Claimset; if (!claims.Contains(claimset)) { claims.Add(claimset); } } } } } }