Ejemplo n.º 1
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var _HttpSecurity = new HTTPSecurity()
            {
                // Include: System.ServiceModel
                CredentialType            = HttpClientCredentialType.Basic,
                UserNamePasswordValidator = new PassValidator()
            };

            // Initialize REST service
            var _HttpWebServer = new HTTPServer<GraphDSREST_Service>(
                9975,
                new GraphDSREST_Service(myAGraphDSSharp),
                myAutoStart: true)
            {
                HTTPSecurity = _HttpSecurity,
            };

            // Register the REST service within the list of services
            // to stop before shutting down the GraphDSSharp instance
            myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
            {
                _HttpWebServer.StopAndWait();
            });

            return Exceptional.OK;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Start the WebDAV interface using the given ip address, port and HTTPSecurity parameters.
        /// </summary>
        /// <param name="myIPAddress">The IPAddress for binding the interface at</param>
        /// <param name="myPort">The port for binding the interface at</param>
        /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
        public static Exceptional<HTTPServer<GraphDSWebDAV_Service>> StartWebDAV(this AGraphDSSharp myAGraphDSSharp, IPAddress myIPAddress, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
        {
            try
            {
                // Initialize WebDAV service
                var _HttpWebServer = new HTTPServer<GraphDSWebDAV_Service>(
                    myIPAddress,
                    myPort,
                    new GraphDSWebDAV_Service(myAGraphDSSharp),
                    myAutoStart: true)
                {
                    HTTPSecurity = myHttpWebSecurity,
                };

                // Register the WebDAV service within the list of services
                // to stop before shutting down the GraphDSSharp instance
                myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
                {
                    _HttpWebServer.StopAndWait();
                });

                return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(_HttpWebServer);

            }
            catch (Exception e)
            {
                return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(new GeneralError(e.Message, new System.Diagnostics.StackTrace(e)));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start the WebDAV interface using the given URI and HTTPSecurity parameters.
        /// </summary>
        /// <param name="myURI">The URI for binding the interface at</param>
        /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
        public static HTTPServer<GraphDSWebDAV_Service> StartWebDAV(this AGraphDSSharp myAGraphDSSharp, Uri myURI, HTTPSecurity myHttpWebSecurity = null)
        {
            // Initialize WebDAV service
            var _HttpWebServer = new HTTPServer<GraphDSWebDAV_Service>(
                myURI,
                new GraphDSWebDAV_Service(myAGraphDSSharp),
                myAutoStart: true)
            {
                HTTPSecurity = myHttpWebSecurity,
            };

            // Register the WebDAV service within the list of services
            // to stop before shutting down the GraphDSSharp instance
            myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
            {
                _HttpWebServer.StopAndWait();
            });

            return _HttpWebServer;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Start the REST interface using the given ip address, port and HTTPSecurity parameters.
        /// </summary>
        /// <param name="myIPAddress">The IPAddress for binding the interface at</param>
        /// <param name="myPort">The port for binding the interface at</param>
        /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
        public static HTTPServer<GraphDSREST_Service> StartREST(this AGraphDSSharp myAGraphDSSharp, IPAddress myIPAddress, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
        {
            // Initialize REST service
            var _HttpWebServer = new HTTPServer<GraphDSREST_Service>(
                myIPAddress,
                myPort,
                new GraphDSREST_Service(myAGraphDSSharp),
                myAutoStart: true)
            {
                HTTPSecurity = myHttpWebSecurity,
            };

            // Register the REST service within the list of services
            // to stop before shutting down the GraphDSSharp instance
            myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
            {
                _HttpWebServer.StopAndWait();
            });

            return _HttpWebServer;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Start the WebDAV interface using the given port and HTTPSecurity parameters.
 /// </summary>
 /// <param name="myPort">The port for binding the interface at</param>
 /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
 public static Exceptional<HTTPServer<GraphDSWebDAV_Service>> StartWebDAV(this AGraphDSSharp myAGraphDSSharp, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
 {
     return myAGraphDSSharp.StartWebDAV(IPAddress.Any, myPort, myHttpWebSecurity);
 }
Ejemplo n.º 6
0
        public sonesExampleClass(String[] myArgs)
        {
            if (myArgs.Count() > 0)
            {
                foreach (String parameter in myArgs)
                {
                    if (parameter.ToUpper() == "--Q")
                        quiet = true;
                }
            }

            #region Init NotificationDispatcher
            var _NotificationSettings = new NotificationSettings()
            {
                StartDispatcher = false,
                StartBrigde = false
            };

            var _NotificationDispatcher = new NotificationDispatcher(UUID.NewUUID, _NotificationSettings);

            #endregion

            #region Create or open GraphDS

            var _GraphDSSharp = new GraphDSSharp()
            {
                DatabaseName = "sonesExample",
                Username = "******",
                Password = "******",
                NotificationSettings = _NotificationSettings,
                NotificationDispatcher = _NotificationDispatcher,
            };

            // Create a InMemory data storage
            _GraphDSSharp.CreateDatabase(true);

            #endregion

            #region Create GraphDB types

            _GraphDSSharp.CreateTypes(CheckResult, typeof(Document), typeof(Author), typeof(Tag));

            #endregion

            #region Create a document upload directory

            _GraphDSSharp.CreateDirectoryObject(new ObjectLocation("Uploads"));

            #endregion

            #region Insert some data

            _GraphDSSharp.Query("INSERT INTO Tag VALUES (Name = 'good')", CheckResult);
            _GraphDSSharp.Query("INSERT INTO Tag VALUES (Name = 'funny')", CheckResult);
            _GraphDSSharp.Query("INSERT INTO Tag VALUES (Name = 'science fiction')", CheckResult);

            _GraphDSSharp.Query("INSERT INTO Author VALUES (Name = 'Holger', EMail = '*****@*****.**')", CheckResult);
            _GraphDSSharp.Query("INSERT INTO Author VALUES (Name = 'Achim',  EMail = '*****@*****.**')", CheckResult);

            #endregion

            #region Start REST, WebDAV and WebAdmin services, send GraphDS notification

            var _HttpSecurity = new HTTPSecurity()
            {
                CredentialType = HttpClientCredentialType.Basic,
                UserNamePasswordValidator = new PassValidator()
            };

            // Start a REST service on localhost port 9975
            var _RESTService      = _GraphDSSharp.StartREST(IPAddress.Any, 9975, _HttpSecurity);

            // Start a WebDAV service on localhost port 9978
            var _WebDAVService    = _GraphDSSharp.StartWebDAV(IPAddress.Any, 9978, _HttpSecurity);

            // Send GraphDS notification
            _NotificationDispatcher.SendNotification(typeof(NGraphDSReady),
                    new NGraphDSReady.Arguments() { Message = "sonesExample up'n'ready!" },
                    NotificationPriority.Normal,
                    true);

            #endregion

            #region Some helping lines...
            if (!quiet)
            {
                Console.WriteLine();
                Console.WriteLine("This small example demonstrates how to start a sones GraphDB");
                Console.WriteLine("Instance and it's several services:");
                Console.WriteLine("   * If you want to suppress console output add --Q as a");
                Console.WriteLine("     parameter.");
                Console.WriteLine("   * REST Service is started at http://localhost:9975");
                Console.WriteLine("      * access it directly like in this example: ");
                Console.WriteLine("           http://localhost:9975/gql?DESCRIBE%20TYPES");
                Console.WriteLine("      * if you want JSON Output add ACCEPT: application/json ");
                Console.WriteLine("        to the client request header (or application/xml or");
                Console.WriteLine("        application/text)");
                Console.WriteLine("   * we recommend to use the AJAX WebShell. ");
                Console.WriteLine("        Browse to http://localhost:9975/WebShell and use");
                Console.WriteLine("        the username \"test\" and password \"test\"");
                Console.WriteLine("   * Additionally a WebDAV service is started on port 9978.");
                Console.WriteLine();
            }
            #endregion

            #region Start the GraphDS command line interface

            if (!quiet)
                _GraphDSSharp.OpenCLI();
            else
                while (true)
                {
                    Thread.Sleep(1000);
                }

            #endregion

            #region Shutdown

            _GraphDSSharp.Shutdown();

            #endregion
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Start the REST interface using the given port and HTTPSecurity parameters.
 /// </summary>
 /// <param name="myPort">The port for binding the interface at</param>
 /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
 public static HTTPServer<GraphDSREST_Service> StartREST(this AGraphDSSharp myAGraphDSSharp, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
 {
     return myAGraphDSSharp.StartREST(IPAddress.Any, myPort, myHttpWebSecurity);
 }