text:
author: AUTHORING
lang: en
title: 'draft-dejong-remotestorage-04 - remoteStorage'
---

\[[Docs]\] \[[txt]\|[pdf]\] \[[Tracker]\] \[[Email]\] \[[Diff1]\] \[[Diff2]\] \[[Nits]\]

Versions: [00][] [01][] [02][] [03][] [04]

    INTERNET DRAFT                                      Michiel B. de Jong
    Document: draft-dejong-remotestorage-04                   IndieHosters
                                                                 F. Kooman
    Intended Status: Proposed Standard                       (independent)
    Expires: 18 June 2015                                 15 December 2014

                                remoteStorage

    Abstract

        This draft describes a protocol by which client-side applications,
        running inside a web browser, can communicate with a data storage
        server that is hosted on a different domain name. This way, the
        provider of a web application need not also play the role of data
        storage provider. The protocol supports storing, retrieving, and
        removing individual documents, as well as listing the contents of an
        individual folder, and access control is based on bearer tokens.

    Status of this Memo

       This Internet-Draft is submitted in full conformance with the
       provisions of BCP 78 and BCP 79.

       Internet-Drafts are working documents of the Internet Engineering
       Task Force (IETF).  Note that other groups may also distribute
       working documents as Internet-Drafts.  The list of current Internet-
       Drafts is at http://datatracker.ietf.org/drafts/current/.

       Internet-Drafts are draft documents valid for a maximum of six months
       and may be updated, replaced, or obsoleted by other documents at any
       time.  It is inappropriate to use Internet-Drafts as reference
       material or to cite them other than as "work in progress."

       This Internet-Draft will expire on 15 December 2014.

    Copyright Notice

       Copyright (c) 2014 IETF Trust and the persons identified as the
       document authors. All rights reserved.

       This document is subject to BCP 78 and the IETF Trust's Legal
       Provisions Relating to IETF Documents
       (http://trustee.ietf.org/license-info) in effect on the date of
       publication of this document.  Please review these documents
       carefully, as they describe your rights and restrictions with respect
       to this document.  Code Components extracted from this document must
       include Simplified BSD License text as described in Section 4.e of
       the Trust Legal Provisions and are provided without warranty as
       described in the Simplified BSD License.

    de Jong                                                         [Page 1]

    Internet-Draft              remoteStorage                  December 2014

    Table of Contents

       1. Introduction...................................................2
       2. Terminology....................................................3
       3. Storage model..................................................3
       4. Requests.......................................................4
       5. Response codes.................................................7
       6. Versioning.....................................................7
       7. CORS headers...................................................8
       8. Session description............................................8
       9. Bearer tokens and access control...............................9
      10. Application-first bearer token issuance.......................10
      11. Storage-first bearer token issuance...........................11
      12. Example wire transcripts......................................12
         12.1. WebFinger................................................12
         12.2. OAuth dialog form........................................13
         12.3. OAuth dialog form submission.............................14
         12.4. OPTIONS preflight........................................15
         12.5. Initial PUT..............................................15
         12.6. Subsequent PUT...........................................16
         12.7. GET......................................................16
         12.8. DELETE...................................................17
      13. Distributed versioning........................................17
      14. Security Considerations.......................................19
      15. IANA Considerations...........................................20
      16. Acknowledgments...............................................20
      17. References....................................................21
         17.1. Normative References.....................................21
         17.2. Informative References...................................21
      18. Authors' addresses............................................22

    1.  Introduction

        Many services for data storage are available over the internet. This
        specification describes a vendor-independent interface for such
        services. It is based on https, CORS and bearer tokens. The
        metaphor for addressing data on the storage is that of folders
        containing documents and subfolders. The actions the interface
        exposes are:

           *  GET a folder: retrieve the names and current versions of the
              documents and subfolders currently contained by the folder

    de Jong                                                         [Page 2]

    Internet-Draft              remoteStorage                  December 2014

           *  GET a document: retrieve its content type, current version,
              and contents

           *  PUT a document: store a new version, its content type, and
              contents, conditional on the current version

           *  DELETE a document: remove it from the storage, conditional on
              the current version

           *  HEAD a folder or document: like GET, but omitting the response
              body

        The exact details of these four actions are described in this
        specification.

    2. Terminology

        The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
        "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
        document are to be interpreted as described in RFC 2119 [WORDS].

        "SHOULD" and "SHOULD NOT" are appropriate when valid exceptions to a
        general requirement are known to exist or appear to exist, and it is
        infeasible or impractical to enumerate all of them.  However, they
        should not be interpreted as permitting implementors to fail to
        implement the general requirement when such failure would result in
        interoperability failure.

    3. Storage model

        The server stores data in nodes that form a tree structure.
        Internal nodes are called 'folders' and leaf nodes are called
        'documents'. For a folder, the server stores references to nodes
        contained in the folder, and it should be able to produce a list of
        them, with for each contained item:

           * item name
           * item type (folder or document)
           * current version
           * content type
           * content length

        For a document, the server stores, and should be able to produce:

    de Jong                                                         [Page 3]

    Internet-Draft              remoteStorage                  December 2014

           * current version
           * content type
           * content length
           * content

    4. Requests

        Client-to-server requests SHOULD be made over https [HTTPS], and
        servers MUST comply with HTTP/1.1 [HTTP]. Specifically, they
        MUST support chunked transfer coding on PUT requests. Servers MAY
        also offer an optional switch from https to SPDY [SPDY].

        A request is considered successful if the HTTP response code is in
        the 2xx range (e.g. 200 OK, 201 Created), and unsuccessful if an
        error occurred or a condition was not met (response code e.g. 404
        Not Found, 304 Not Modified).

        The root folder of the storage tree is represented by the following
        URL:

            URI_ENCODE( <storage_root> '/' )

        Subsequently, if <parent_folder> is the URL of a folder, then the
        URL of an item contained in it is:

            URI_ENCODE( <parent_folder> <document_name> )

        for a document, or:

            URI_ENCODE( <parent_folder> <folder_name> '/' )

        for a folder. Item names MAY contain all characters except '/' and
        the null character, and MUST NOT have zero length.

        A document description is a map containing one string-valued 'ETag'
        field, one string-valued 'Content-Type' and one integer-valued
        'Content-Length' field. They represent the document's current
        version, its content type, and its content length respectively. Note
        that content length is measured in octets (bytes), not in
        characters.

        A folder description is a map containing a string-valued 'ETag'

    de Jong                                                         [Page 4]

    Internet-Draft              remoteStorage                  December 2014

        field, representing the folder's current version.

        A successful GET request to a folder MUST be responded to with a
        JSON-LD [JSON-LD] document (content type 'application/ld+json'),
        containing as its 'items' field a map in which contained documents
        appear as entries <item_name> to a document description, and
        contained non-empty folders appear as entries <item_name> '/' to a
        folder description. It MUST also contain an '@context' field with
        the value 'http://remotestorage.io/spec/folder-description'. For
        instance:

           {
             "@context": "http://remotestorage.io/spec/folder-description",
             "items": {
               "abc": {
                 "ETag": "DEADBEEFDEADBEEFDEADBEEF",
                 "Content-Type": "image/jpeg",
                 "Content-Length": 82352
               },
               "def/": {
                 "ETag": "1337ABCD1337ABCD1337ABCD"
               }
             }
           }

        All folders are treated as existing, and therefore GET requests to
        untouched folders SHOULD be responded to with a folder description
        with no items (the items field set to '{}'). However, an empty
        folder MUST NOT be listed as an item in its parent folder.

        Also, since folders exist automatically, PUT and DELETE requests
        only need to be made to documents, and never to folders. A document
        PUT will make all ancestor folders along its path become non-empty;
        deleting the last document from a subtree will make that whole
        subtree become empty. Folders will therefore show up in their parent
        folder descriptions if and only if their subtree contains at least
        one document.

        A successful GET request to a document SHOULD be responded to with
        the full document contents in the body, the document's content type
        in a 'Content-Type' header, its content length in octets (not in
        characters) in a 'Content-Length' header, and the document's current
        version as a strong ETag in an 'ETag' header.

    de Jong                                                         [Page 5]

    Internet-Draft              remoteStorage                  December 2014

        Note that the use of strong ETags prohibits changing the response
        body based on request headers; in particular, the server will not be
        able to serve the same document uncompressed to some clients and
        gzipped when requested by the client, since the two bodies would not
        be identical byte-for-byte.

        Servers MAY support Content-Range headers [RANGE] on GET requests,
        but whether or not they do SHOULD be announced through the <ranges>
        variable mentioned below in section 10.

        A successful PUT request to a document MUST result in:

           * the request body being stored as the document's new content,
           * parent and further ancestor folders being silently created as
             necessary, with the document (name and version) being added to
             its parent folder, and each folder added to its subsequent
             parent,
           * the value of its Content-Type header being stored as the
             document's new content type,
           * its version being updated, as well as that of its parent folder
             and further ancestor folders, using a strong validator [HTTP,
             section 7.2].

        The response MUST contain a strong ETag header, with the document's
        new version (for instance a hash of its contents) as its value.

        A successful DELETE request to a document MUST result in:

           * the deletion of that document from the storage, and from its
             parent folder,
           * silent deletion of the parent folder if it is left empty by
             this, and so on for further ancestor folders,
           * the version of its parent folder being updated, as well as that
             of further ancestor folders.

        A successful OPTIONS request SHOULD be responded to as described in
        the CORS section below.

        A successful HEAD request SHOULD be responded to like to the
        equivalent GET request, but omitting the response body.

    de Jong                                                         [Page 6]

    Internet-Draft              remoteStorage                  December 2014

    5. Response codes

        Response codes SHOULD be given as defined by [HTTP, section 6] and
        [BEARER, section 3.1]. The following is a non-normative checklist
        of status codes that are likely to occur in practice:

           * 500 if an internal server error occurs,
           * 429 if the client makes too frequent requests or is suspected
                 of malicious activity,
           * 414 if the request URI is too long,
           * 416 if Range requests are supported by the server and the Range
                 request can not be satisfied,
           * 401 for all requests that don't have a bearer token with
                 sufficient permissions,
           * 404 for all DELETE and GET requests to documents that do not
                 exist on the storage,
           * 304 for a conditional GET request whose pre-condition
                 fails (see "Versioning" below),
           * 409 for a PUT request where any folder name in the path
                 clashes with an existing document's name at the same
                 level, or where the document name coincides with an
                 existing folder's name at the same level.
           * 412 for a conditional PUT or DELETE request whose pre-condition
                 fails (see "Versioning" below),
           * 507 in case the account is over its storage quota,
           * 4xx for all malformed requests (e.g. foreign characters in the
                 path), as well as for all PUT and DELETE requests to
                 folders,
           * 2xx for all successful requests.

        Clients SHOULD also handle the case where a response takes too long
        to arrive, or where no response is received at all.

    6. Versioning

        All successful requests MUST return an 'ETag' header [HTTP] with, in
        the case of GET, the current version, in the case of PUT, the new
        version, and in case of DELETE, the version that was deleted. All
        successful GET requests MUST return an 'Expires: 0' header. PUT and
        DELETE requests MAY have an 'If-Match' request header [COND], and
        MUST fail with a 412 response code if that doesn't match the
        document's current version.

    de Jong                                                         [Page 7]

    Internet-Draft              remoteStorage                  December 2014

        GET requests MAY have a comma-separated list of revisions in an
        'If-None-Match' header [COND], and SHOULD be responded to with a 304
        response if that list includes the document or folder's current
        version. A PUT request MAY have an 'If-None-Match: *' header [COND],
        in which case it MUST fail with a 412 response code if the document
        already exists.

        In all 'ETag', 'If-Match' and 'If-None-Match' headers, revision
        strings should appear inside double quotes (").

        A provider MAY offer version rollback functionality to its users,
        but this specification does not define the user interface for that.

    7. CORS headers

        All responses MUST carry CORS headers [CORS]. The server MUST also
        reply to OPTIONS requests as per CORS. For GET requests, a wildcard
        origin MAY be returned, but for PUT and DELETE requests, the
        response MUST echo back the Origin header sent by the client.

    8. Session description

        The information that a client needs to receive in order to be able
        to connect to a server SHOULD reach the client as described in the
        'bearer token issuance' sections below. It consists of:

           * <storage_root>, consisting of 'https://' followed by a server
             host, and optionally a server port and a path prefix as per
             [IRI]. Examples:
             * 'https://example.com' (host only)
             * 'https://example.com:8080' (host and port)
             * 'https://example.com/path/to/storage' (host, port and
               path prefix; note there is no trailing slash)
           * <access_token> as per [OAUTH]. The token SHOULD be hard to
             guess and SHOULD NOT be reused from one client to another. It
             can however be reused in subsequent interactions with the same
             client, as long as that client is still trusted. Example:
             * 'ofb24f1ac3973e70j6vts19qr9v2eei'
           * <storage_api>, always 'draft-dejong-remotestorage-04' for this
             alternative version of the specification.

        The client can make its requests using https with CORS and bearer
        tokens, to the URL that is the concatenation of <storage_root> with

    de Jong                                                         [Page 8]

    Internet-Draft              remoteStorage                  December 2014

        '/' plus one or more <folder> '/' strings indicating a path in the
        folder tree, followed by zero or one <document> strings, indicating
        a document. For example, if <storage_root> is
        "https://storage.example.com/bob", then to retrieve the folder
        contents of the /public/documents/ folder, or to retrieve a
        'draft.txt' document from that folder, the client would make
        requests to, respectively:

        * https://storage.example.com/bob/public/documents/
        * https://storage.example.com/bob/public/documents/draft.txt

    9. Bearer tokens and access control

        A bearer token represents one or more access scopes. These access
        scopes are represented as strings of the form <module> <level>,
        where the <module> string SHOULD be lower-case alphanumerical, other
        than the reserved word 'public', and <level> can be ':r' or ':rw'.
        The access the bearer token gives is the sum of its access scopes,
        with each access scope representing the following permissions:

        '*:rw') any request,

        '*:r') any GET or HEAD request,

        <module> ':rw') any requests to paths that start with
                        '/' <module> '/' or '/public/' <module> '/',

        <module> ':r') any GET or HEAD requests to paths that start with
                       '/' <module> '/' or '/public/' <module> '/',

        As a special exceptions, GET requests to a document (but not a
        folder) whose path starts with '/public/' are always allowed. They,
        as well as OPTIONS requests, can be made without a bearer token.
        Unless [KERBEROS] is used (see section 10 below), all other requests
        SHOULD present a bearer token with sufficient access scope, using a
        header of the following form (no double quotes here):

           Authorization: Bearer <access_token>

        In addition, providing the access token via a HTTP query parameter
        for GET requests MAY be supported by the server, although its use
        is not recommended, due to its security deficiencies; see [BEARER,
        section 2.3].

    de Jong                                                         [Page 9]

    Internet-Draft              remoteStorage                  December 2014

    10. Application-first bearer token issuance

        To make a remoteStorage server available as 'the remoteStorage of
        <account> at <host>', exactly one link of the following format
        SHOULD be added to the WebFinger record [WEBFINGER] of <account> at
        <host>:

        {
          "href": <storage_root>,
          "rel": "remotestorage",
          "properties": {
            "http://remotestorage.io/spec/version": <storage_api>,
            "http://tools.ietf.org/html/rfc6749#section-4.2": <auth-dialog>,
            ... : ... ,
          }
        }

        Here <storage_root> and <storage_api> are as per "Session
        description" above, and <auth-dialog> SHOULD be either null or a
        URL where an OAuth 2.0 implicit-grant flow dialog [OAUTH] is
        presented.

        If <auth-dialog> is a URL, the user can supply their credentials
        for accessing the account (how, is out of scope), and allow or
        reject a request by the connecting application to obtain a bearer
        token for a certain list of access scopes. Note that an account
        will often belong to just one human user, but may also belong to a
        group of multiple users (the remoteStorage of <group> at <host>).

        If <auth-dialog> is null, the client will not have a way to obtain
        an access token, and SHOULD send all requests without Authorization
        header, and rely on Kerberos [KERBEROS] instead for requests that
        would normally be sent with a bearer token, but servers SHOULD NOT
        impose any such access barriers for resources that would normally
        not require an access token.

        The '...' ellipses indicate that more properties may be present.
        Non-breaking examples that have been proposed so far, include a
        "http://tools.ietf.org/html/rfc6750#section-2.3" property, set to
        the string value "true" if the server supports passing the bearer
        token in the URI query parameter as per section 2.3 of [BEARER],
        instead of in the request header.

    de Jong                                                        [Page 10]

    Internet-Draft              remoteStorage                  December 2014

        Another example is "http://tools.ietf.org/html/rfc7233" with a
        string value of "GET" if Content-Range headers are supported for
        GET requests as per [RANGE], "PUT" if they are supported for PUT
        requests, and "GET,PUT" if supported for both.

        Both these proposals are non-breaking extensions, since the client
        will have a way to work around it if these features are not present
        (e.g. retrieve the protected resource asynchronously in the first
        case, or request the entire resource in the second case).

        A "http://remotestorage.io/spec/web-authoring" property has been
        proposed with a string value of the fully qualified domain name to
        which web authoring content is published if the server supports web
        authoring as per [AUTHORING]. Note that this extension is a breaking
        extension in the sense that it divides users into "haves", whose
        remoteStorage accounts allow them to author web content, and
        "have-nots", whose remoteStorage account does not support this
        functionality.

        The server MAY expire bearer tokens, and MAY require the user to
        register applications as OAuth clients before first use; if no
        client registration is required, then the server MAY ignore the
        client_id parameter in favor of relying on the redirect_uri
        parameter for client identification.

    11. Storage-first bearer token issuance

        The provider MAY also present a dashboard to the user, where they
        have some way to add open web app manifests [MANIFEST]. Adding a
        manifest to the dashboard is considered equivalent to clicking
        'accept' in the dialog of the application-first flow. Removing one
        is considered equivalent to revoking its access token.

        As an equivalent to OAuth's 'scope' parameter, a 'datastores-access'
        field SHOULD be present in the root of such an application manifest
        document, with entries <module> -> '{"access": "readonly"}' for
        <level> 'r' or '{"access": "readwrite"}' for <level> 'rw', as
        prescribed in [DATASTORE].

        When the user gestures they want to use a certain application whose
        manifest is present on the dashboard, the dashboard SHOULD redirect
        to the application or open it in a new window. To mimic coming back

    de Jong                                                        [Page 11]

    Internet-Draft              remoteStorage                  December 2014

        from the OAuth dialog, it MAY add 'access_token' and 'scope'
        fields to the URL fragment.

        Regardless of whether 'access_token' and 'scope' are specified, it
        SHOULD add a 'remotestorage' field to the URL fragment, with a
        value of the form <account> '@' <host>. When the application detects
        this parameter, it SHOULD resolve the WebFinger record for <account>
        at <host> and extract the <storage_root> and <storage_api>
        information.

        If no access_token was given, then the application SHOULD also
        extract the <auth_endpoint> information from WebFinger, and continue
        as per application-first bearer token issuance.

        Note that whereas a remoteStorage server SHOULD offer support for
        the application-first flow with WebFinger and OAuth, it MAY choose
        not to support the storage-first flow, provided that users will
        easily remember their <account> '@' <host> WebFinger address at that
        provider. Applications SHOULD, however, support both flows, which
        means checking the URL for a 'remotestorage' parameter, but giving
        the user a way to specify the WebFinger address if there is none.

        If a server provides an application manifest dashboard, then it
        SHOULD merge the list of applications there with the list of
        issued access tokens as specified by OAuth into one list. Also,
        the interface for revoking an access token as specified by OAuth
        SHOULD coincide with removing an application from the dashboard.

        Servers MAY also provide a way to create access tokens directly from
        their user interface. Such functionality would be aimed mainly at
        developers, to manually copy and paste a token into a script or
        debug tool, thus bypassing the need for an OAuth dance. Clients
        SHOULD NOT rely on this in production.

    12. Example wire transcripts

        The following examples are not normative ("\" indicates a line was
        wrapped).

    12.1. WebFinger

        In application-first, an in-browser application might issue the
        following request, using XMLHttpRequest and CORS:

    de Jong                                                        [Page 12]

    Internet-Draft              remoteStorage                  December 2014

             GET /.well-known/webfinger?resource=acct:michiel@michielbdejon\
    g.com HTTP/1.1
             Host: michielbdejong.com

        and the server's response might look like this:

             HTTP/1.1 200 OK
             Access-Control-Allow-Origin: *
             Access-Control-Allow-Methods: GET
             Access-Control-Allow-Headers: If-Match, If-None-Match
             Access-Control-Expose-Headers: ETag, Content-Length
             Content-Type: application/jrd+json

             {
               "links":[{
                 "href": "https://michielbdejong.com:7678/inbox",
                 "rel": "post-me-anything"
               }, {
                 "href": "https://michielbdejong.com/me.jpg",
                 "rel": "avatar"
               }, {
                 "href": "https://3pp.io:4439/storage/michiel",
                 "rel": "remotestorage",
                 "properties": {
                   "http://remotestorage.io/spec/version": "draft-dejong-re\
    motestorage-04",
                   "http://tools.ietf.org/html/rfc6749#section-4.2": "https\
    ://3pp.io:4439/oauth/michiel",
                   "http://tools.ietf.org/html/rfc6750#section-2.3": false,
                   "http://tools.ietf.org/html/rfc7233": false,
                   "http://remotestorage.io/spec/web-authoring": false
                 }
               }]
             }

    12.2. OAuth dialog form

        Once the in-browser application has discovered the server's OAuth
        end-point, it will typically redirect the user to this URL, in
        order to obtain a bearer token. Say the application is hosted on
        https://drinks-unhosted.5apps.com/ and wants read-write access to
        the account's "myfavoritedrinks" scope:

    de Jong                                                        [Page 13]

    Internet-Draft              remoteStorage                  December 2014

            GET /oauth/michiel?redirect_uri=https%3A%2F%2Fdrinks-unhosted.5\
    apps.com%2F&scope=myfavoritedrinks%3Arw&client_id=https%3A%2F%2Fdrinks-\
    unhosted.5apps.com&response_type=token HTTP/1.1
            Host: 3pp.io

        The server's response might look like this (truncated for brevity):

            HTTP/1.1 200 OK

            <!DOCTYPE html>
            <html lang="en">
              <head>
                <title>Allow access?</title>
            ...

    12.3. OAuth dialog form submission

        When the user submits the form, the request would look something
        like this:

            POST /oauth HTTP/1.1
            Host: 3pp.io:4439
            Origin: https://3pp.io:4439
            Content-Type: application/x-www-form-urlencoded
            Referer: https://3pp.io:4439/oauth/michiel?redirect_uri=https%3\
    A%2F%2Fdrinks-unhosted.5apps.com%2F&scope=myfavoritedrinks%3Arw&client_\
    id=https%3A%2F%2Fdrinks-unhosted.5apps.com&response_type=token

            client_id=https%3A%2F%2Fdrinks-unhosted.5apps.com&redirect_uri=\
    https%3A%2F%2Fdrinks-unhosted.5apps.com%2F&response_type=token&scope=my\
    favoritedrinks%3Arw&state=&username=michiel&password=something&allow=Al\
    low

        To which the server could respond with a 302 redirect, back to the
        origin of the requesting application:

            HTTP/1.1 302 Found
            Location:https://drinks-unhosted.5apps.com/#access_token=j2YnGt\
    XjzzzHNjkd1CJxoQubA1o%3D&token_type=bearer&state=

    12.4. OPTIONS preflight

    de Jong                                                        [Page 14]

    Internet-Draft              remoteStorage                  December 2014

        When an in-browser application makes a cross-origin request which
        may affect the server-state, the browser will make a preflight
        request first, with the OPTIONS verb, for instance:

            OPTIONS /storage/michiel/myfavoritedrinks/ HTTP/1.1
            Host: 3pp.io:4439
            Access-Control-Request-Method: GET
            Origin: https://drinks-unhosted.5apps.com
            Access-Control-Request-Headers: Authorization
            Referer: https://drinks-unhosted.5apps.com/

        To which the server can for instance respond:

            HTTP/1.1 200 OK
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            Access-Control-Allow-Methods: GET, PUT, DELETE
            Access-Control-Allow-Headers: Authorization, Content-Length, Co\
    ntent-Type, Origin, X-Requested-With, If-Match, If-None-Match

    12.5. Initial PUT

        An initial PUT may contain an 'If-None-Match: *' header, like this:

            PUT /storage/michiel/myfavoritedrinks/test HTTP/1.1
            Host: 3pp.io:4439
            Content-Length: 91
            Origin: https://drinks-unhosted.5apps.com
            Authorization: Bearer j2YnGtXjzzzHNjkd1CJxoQubA1o=
            Content-Type: application/json; charset=UTF-8
            Referer: https://drinks-unhosted.5apps.com/?
            If-None-Match: *

            {"name":"test","@context":"http://remotestorage.io/spec/modules\
    /myfavoritedrinks/drink"}

        And the server may respond with either a 201 Created or a 200 OK
        status:

            HTTP/1.1 201 Created
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            ETag: "1382694045000"

    12.6. Subsequent PUT

    de Jong                                                        [Page 15]

    Internet-Draft              remoteStorage                  December 2014

        A subsequent PUT may contain an 'If-Match' header referring to the
        ETag previously returned, like this:

            PUT /storage/michiel/myfavoritedrinks/test HTTP/1.1
            Host: 3pp.io:4439
            Content-Length: 91
            Origin: https://drinks-unhosted.5apps.com
            Authorization: Bearer j2YnGtXjzzzHNjkd1CJxoQubA1o=
            Content-Type: application/json; charset=UTF-8
            Referer: https://drinks-unhosted.5apps.com/?
            If-Match: "1382694045000"

            {"name":"test", "updated":true, "@context":"http://remotestorag\
    e.io/spec/modules/myfavoritedrinks/drink"}

        And the server may respond with a 412 Conflict or a 200 OK status:

            HTTP/1.1 200 OK
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            ETag: "1382694048000"

    12.7. GET

        A GET request would also include the bearer token, and optionally
        an If-None-Match header:

            GET /storage/michiel/myfavoritedrinks/test HTTP/1.1
            Host: 3pp.io:4439
            Origin: https://drinks-unhosted.5apps.com
            Authorization: Bearer j2YnGtXjzzzHNjkd1CJxoQubA1o=
            Referer: https://drinks-unhosted.5apps.com/?
            If-None-Match: "1382694045000", "1382694048000"

        And the server may respond with a 304 Not Modified status:

            HTTP/1.1 304 Not Modified
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            ETag: "1382694048000"

        Or a 200 OK status, plus a response body:

            HTTP/1.1 200 OK

    de Jong                                                        [Page 16]

    Internet-Draft              remoteStorage                  December 2014

            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            Content-Type: application/json; charset=UTF-8
            Content-Length: 106
            ETag: "1382694048000"
            Expires: 0

            {"name":"test", "updated":true, "@context":"http://remotestora\
    ge.io/spec/modules/myfavoritedrinks/drink"}

        If the GET URL would have been "/storage/michiel/myfavoritedrinks/",
        a 200 OK response would have a folder description as the response
        body:

            HTTP/1.1 200 OK
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            Content-Type: application/ld+json
            Content-Length: 171
            ETag: "1382694048000"
            Expires: 0

            {"@context":"http://remotestorage.io/spec/folder-version","ite\
    ms":{"test":{"ETag":"1382694048000","Content-Type":"application/json; \
    charset=UTF-8","Content-Length":106}}}

        If the GET URL would have been a non-existing document like
        "/storage/michiel/myfavoritedrinks/x", the response would have a 404
        Not Found status, and no ETag header:

            HTTP/1.1 404 Not Found
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com

    12.8. DELETE

        A DELETE request may look like this:

            DELETE /storage/michiel/myfavoritedrinks/test HTTP/1.1
            Host: 3pp.io:4439
            Origin: https://drinks-unhosted.5apps.com
            Authorization: Bearer j2YnGtXjzzzHNjkd1CJxoQubA1o=
            Content-Type: application/json; charset=UTF-8
            Referer: https://drinks-unhosted.5apps.com/?
            If-Match: "1382694045000"

    de Jong                                                        [Page 17]

    Internet-Draft              remoteStorage                  December 2014

        And the server may respond with a 412 Conflict or a 200 OK status:

            HTTP/1.1 412 Conflict
            Access-Control-Allow-Origin: https://drinks-unhosted.5apps.com
            ETag: "1382694048000"

    13. Distributed versioning

        This section is non-normative, and is intended to explain some of
        the design choices concerning ETags and folder listings. At the
        same time it will hopefully help readers who intend to develop an
        application that uses remoteStorage as its per-user data storage.
        When multiple clients have read/write access to the same document,
        versioning conflicts may occur. For instance, client A may make
        a PUT request that changes the document from version 1 to version
        2, after which client B may make a PUT request attempting to change
        the same document from version 1 to version 3.

        In this case, client B can add an 'If-Match: "1"' header, which
        would trigger a 412 Conflict response code, since the current
        version ("2") does not match the version required as a condition by
        the header If-Match header ("1").

        Client B is now aware of the conflict, and may consult the user,
        saying the update to version 3 failed. The user may then choose,
        through the user interface of client B, whether version 2 or
        version 3 should be kept, or maybe the document should be reverted
        on the server to version 1, or a merged version 4 is needed. Client
        B may then make a request that puts the document to the version the
        user wishes; this time setting an 'If-Match: "2"' header instead.

        Both client A and client B would periodically poll the root
        folder of each scope they have access to, to see if the version
        of the root folder changed. If it did, then one of the versions
        listed in there will necessarily have changed, and the client can
        make a GET request to that child folder or document, to obtain
        its latest version.

        Because an update in a document will result in a version change of
        its containing folder, and that change will propagate all the way
        to the root folder, it is not necessary to poll each document for
        changes individually.

    de Jong                                                        [Page 18]

    Internet-Draft              remoteStorage                  December 2014

        As an example, the root folder may contain 10 directories,
        each of which contain 10 directories, which each contain 10
        documents, so their paths would be for instance '/0/0/1', '/0/0/2',
        etcetera. Then one GET request to the root folder '/' will be
        enough to know if any of these 1000 documents has changed.

        Say document '/7/9/2' has changed; then the GET request to '/' will
        come back with a different ETag, and entry '7/' will have a
        different value in its JSON content. The client could then request
        '/7/', '/7/9/', and '/7/9/2' to narrow down the one document that
        caused the root folder's ETag to change.

        Note that the remoteStorage server does not get involved in the
        conflict resolution. It keeps the canonical current version at all
        times, and allows clients to make conditional GET and PUT requests,
        but it is up to whichever client discovers a given version
        conflict, to resolve it.

    14. Security Considerations

        To prevent man-in-the-middle attacks, the use of https instead of
        http is important for both the interface itself and all end-points
        involved in WebFinger, OAuth, and (if present) the storage-first
        application launch dashboard.

        A malicious party could link to an application, but specifying a
        remoteStorage account address that it controls, thus tricking the
        user into using a trusted application to send sensitive data to the
        wrong remoteStorage server. To mitigate this, applications SHOULD
        clearly display to which remoteStorage server they are sending the
        user's data.

        Applications could request scopes that the user did not intend to
        give access to. The user SHOULD always be prompted to carefully
        review which scopes an application is requesting.

        An application may upload malicious html pages and then trick the
        user into visiting them, or upload malicious client-side scripts,
        that take advantage of being hosted on the user's domain name. The
        origin on which the remoteStorage server has its interface SHOULD
        therefore NOT be used for anything else, and the user SHOULD be
        warned not to visit any web pages on that origin. In particular, the
        OAuth dialog and launch dashboard or token revokation interface

    de Jong                                                        [Page 19]

    Internet-Draft              remoteStorage                  December 2014

        SHOULD be on a different origin than the remoteStorage interface.

        Where the use of bearer tokens is impractical, a user may choose to
        store documents on hard-to-guess URLs whose path after
        <storage_root> starts with '/public/', while sharing this URL only
        with the intended audience. That way, only parties who know the
        document's hard-to-guess URL, can access it. The server SHOULD
        therefore make an effort to detect and stop brute-force attacks that
        attempt to guess the location of such documents.

        The server SHOULD also detect and stop denial-of-service attacks
        that aim to overwhelm its interface with too much traffic.

    15. IANA Considerations

        This document registers the 'remotestorage' link relation, as well
        as the following WebFinger properties:
          * "http://remotestorage.io/spec/version"
          * "http://tools.ietf.org/html/rfc6749#section-4.2"
          * "http://tools.ietf.org/html/rfc6750#section-2.3"
          * "http://tools.ietf.org/html/rfc7233"
          * "http://remotestorage.io/spec/web-authoring"

    16. Acknowledgements

        The authors would like to thank everybody who contributed to the
        development of this protocol, including Kenny Bentley, Javier Diaz,
        Daniel Groeber, Bjarni Runar, Jan Wildeboer, Charles Schultz, Peter
        Svensson, Valer Mischenko, Michiel Leenaars, Jan-Christoph
        Borchardt, Garret Alfert, Sebastian Kippe, Max Wiehle, Melvin
        Carvalho, Martin Stadler, Geoffroy Couprie, Niklas Cathor, Marco
        Stahl, James Coglan, Ken Eucker, Daniel Brolund, elf Pavlik, Nick
        Jennings, Markus Sabadello, Steven te Brinke, Matthias Treydte,
        Rick van Rein, Mark Nottingham, Julian Reschke, and Markus
        Lanthaler, among many others.

    17. References

    17.1. Normative References

        [WORDS]
            Bradner, S., "Key words for use in RFCs to Indicate Requirement
            Levels", BCP 14, RFC 2119, March 1997.

    de Jong                                                        [Page 20]

    Internet-Draft              remoteStorage                  December 2014

        [IRI]
            Duerst, M., "Internationalized Resource Identifiers (IRIs)",
            RFC 3987, January 2005.

        [WEBFINGER]
            Jones, P., Salguerio, G., Jones, M, and Smarr, J.,
            "WebFinger", RFC7033, September 2013.

        [OAUTH]
            "Section 4.2: Implicit Grant", in: Hardt, D. (ed), "The OAuth
            2.0 Authorization Framework", RFC6749, October 2012.

    17.2. Informative References

        [HTTPS]
            Rescorla, E., "HTTP Over TLS", RFC2818, May 2000.

        [HTTP]
            Fielding et al., "Hypertext Transfer Protocol (HTTP/1.1):
            Semantics and Content", RFC7231, June 2014.

        [COND]
            Fielding et al., "Hypertext Transfer Protocol (HTTP/1.1):
            Conditional Requests", RFC7232, June 2014.

        [RANGE]
            Fielding et al., "Hypertext Transfer Protocol (HTTP/1.1):
            Conditional Requests", RFC7233, June 2014.

        [SPDY]
            Mark Belshe, Roberto Peon, "SPDY Protocol - Draft 3.1", http://
            www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3-1,
            September 2013.

        [JSON-LD]
            M. Sporny, G. Kellogg, M. Lanthaler, "JSON-LD 1.0", W3C
            Proposed Recommendation,
            http://www.w3.org/TR/2014/REC-json-ld-20140116/, January 2014.

        [CORS]
            van Kesteren, Anne (ed), "Cross-Origin Resource Sharing --
            W3C Candidate Recommendation 29 January 2013",

    de Jong                                                        [Page 21]

    Internet-Draft              remoteStorage                  December 2014

            http://www.w3.org/TR/cors/, January 2013.

        [MANIFEST]
            Mozilla Developer Network (ed), "App manifest -- Revision
            330541", https://developer.mozilla.org/en-
            US/Apps/Build/Manifest$revision/566677, April 2014.

        [DATASTORE]
            "WebAPI/DataStore", MozillaWiki, retrieved May 2014.
            https://wiki.mozilla.org/WebAPI/DataStore#Manifest

        [KERBEROS]
            C. Neuman et al., "The Kerberos Network Authentication Service
            (V5)", RFC4120, July 2005.

        [BEARER]
            M. Jones, D. Hardt, "The OAuth 2.0 Authorization Framework:
            Bearer Token Usage", RFC6750, October 2012.

        []
            "Using remoteStorage for web authoring", reSite wiki, retrieved
            September 2014. https://github.com/michielbdejong/resite/wiki
            /Using-remoteStorage-for-web-authoring

    18. Authors' addresses

        Michiel B. de Jong
        IndieHosters

        Email: michiel@michielbdejong.com

        F. Kooman
        (independent)

        Email: fkooman@tuxed.net

    de Jong                                                        [Page 22]

Html markup produced by rfcmarkup 1.111, available from <https://tools.ietf.org/tools/rfcmarkup/>

  [Docs]: ../html/
  [txt]: https://tools.ietf.org/id/draft-dejong-remotestorage-04.txt
  [pdf]: /pdf/draft-dejong-remotestorage-04.txt
  [Tracker]: https://datatracker.ietf.org/doc/draft-dejong-remotestorage
  [Email]: mailto:draft-dejong-remotestorage@tools.ietf.org?subject=draft-dejong-remotestorage%20
  [Diff1]: /rfcdiff?difftype=--hwdiff&url2=draft-dejong-remotestorage-04.txt
  [Diff2]: /rfcdiff?url2=draft-dejong-remotestorage-04.txt
  [Nits]: /idnits?url=https://tools.ietf.org/id/draft-dejong-remotestorage-04.txt
  [00]: ./draft-dejong-remotestorage-00
  [01]: ./draft-dejong-remotestorage-01
  [02]: ./draft-dejong-remotestorage-02
  [03]: ./draft-dejong-remotestorage-03
  [04]: ./draft-dejong-remotestorage-04


text:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Microsoft.Xna.Framework.Media
{
    public sealed class PictureCollection : IEnumerable<Picture>, IEnumerable, IDisposable
    {

        internal PictureCollection()
        {
        }

        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            throw new NotImplementedException();
        }

        public IEnumerator<Picture> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        public Picture this[int index]
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public int Count
        {
            get
            {
                throw new NotImplementedException();
            }
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
/*
 * Defines for 16 bit timers used with  Servo library
 *
 * If _useTimerX is defined then TimerX is a 16 bit timer on the current board
 * timer16_Sequence_t enumerates the sequence that the timers should be allocated
 * _Nbr_16timers indicates how many 16 bit timers are available.
 */

/**
 * AVR Only definitions
 * --------------------
 */

// Say which 16 bit timers can be used and in what order
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define _useTimer5
#define _useTimer1
#define _useTimer3
#define _useTimer4
typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t;

#elif defined(__AVR_ATmega32U4__)
#define _useTimer1
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;

#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define _useTimer3
#define _useTimer1
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t;

#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
#define _useTimer3
#define _useTimer1
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t;

#else  // everything else
#define _useTimer1
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
#endif


text:
/* ------------------------------------------------------------------------------
** _________   _________      ________    _____      _____  ___________ _________
** \_   ___ \ /   _____/     /  _____/   /  _  \    /     \ \_   _____//   _____/
** /    \  \/ \_____  \     /   \  ___  /  /_\  \  /  \ /  \ |    __)_ \_____  \
** \     \____/        \    \    \_\  \/    |    \/    Y    \|        \/        \
**  \______  /_______  /     \______  /\____|__  /\____|__  /_______  /_______  /
**        \/        \/             \/         \/         \/        \/        \/
**
** NetworkController.cpp
** Implementation of the NetworkController
**
** Author: Samuel-Ricardo Carriere
** ------------------------------------------------------------------------------*/

#include "stdafx.h"

#include "NetworkController.h"

NetworkController::NetworkController() : resolver(io_service), query("127.0.0.1", "1337"), socket(io_service), eventFactory()
{
	endpoint_iterator = resolver.resolve(query);
	readerThread = NULL;
	writerThread = NULL;
	status = ControllerStatus::TryToConnect;
	exitSocket = false;
}

NetworkController::~NetworkController()
{
	if(readerThread)
	{
		delete readerThread;
	}

	if(writerThread)
	{
		delete writerThread;
	}
}

void NetworkController::writeFunc()
{
	bool exit = false;
	try
	{
		std::string message = "";

		while(!exit)
		{
			if(!QueueController::getInstance().isMessageQueueEmpty())
			{
				message = QueueController::getInstance().getMessage();

				if(message == "Exit")
				{
					exit = true;
				}

				// To be sure that message don't overlap
				message += '\n';

				boost::system::error_code ignored_error;
				boost::asio::write(socket, boost::asio::buffer(message),
							   boost::asio::transfer_all(), ignored_error);
			}
			boost::this_thread::sleep(boost::posix_time::milliseconds(30));
		}
		readerThread->join();
		socket.close();
	}
	catch (std::exception& e)
	{
		printf("Exception in writter : %s\n", e.what());
	}
}

void NetworkController::init()
{
	while(status == ControllerStatus::TryToConnect)
	{
		if(!tryToConnect())
		{
			printf("Can't reach server... Will try again in 2s\n");
			boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
		}
		else
		{
			status = ControllerStatus::TryJoinGame;
		}
	}

	try
	{
		if(readerThread == NULL)
		{
			readerThread = new boost::thread( boost::bind (&NetworkController::readerFunc, this));
		}

		if(writerThread == NULL)
		{
			writerThread = new boost::thread( boost::bind (&NetworkController::writeFunc, this));
		}
	}
	catch (std::exception& e)
	{
		printf("Exception in init : %s\n", e.what());
	}

	tryJoinGame();
}

bool NetworkController::tryToConnect()
{
	try
	{
		boost::asio::connect(socket, endpoint_iterator);
	}
	catch (std::exception& e)
	{
		printf("Exception in init : %s\n", e.what());
		return false;
	}
	return true;
}

void NetworkController::tryJoinGame()
{
	QueueController::getInstance().addMessage("GameClientReady");
	status = ControllerStatus::WaitingYouAreTheGameClient;
}

void NetworkController::readerFunc()
{
	try
	{
		while(!exitSocket)
		{
			//we read the buffer to put the message in the buffer
			size_t len = socket.read_some(boost::asio::buffer(buf), error);

			if (error == boost::asio::error::eof)
				throw boost::system::system_error(error); // Connection closed cleanly by peer.
			else if (error)
				throw boost::system::system_error(error); // Some other error.

			buf.data()[len] = '\0';
			std::string messagePack = buf.data();

			std::string message = NetUtility::getNextToken(messagePack, "\n");
			while (!message.empty())
			{
				parseMessage(message);
				message = NetUtility::getNextToken(messagePack, "\n");
			}
		}
	}
	catch (std::exception& e)
	{
		printf("Exception in reader : %s\n", e.what());
	}
}

void NetworkController::parseMessage(std::string message)
{
	std::string header = NetUtility::getNextToken(message, ":");
	if(header == "Net")
	{
		parseMessageBody(message);
	}
	else if(header == "Game")
	{
		eventFactory.generate(message);
	}
}

void NetworkController::close()
{
	QueueController::getInstance().addMessage("Exit");

	if(readerThread)
		readerThread->join();

	if(writerThread)
		writerThread->join();
}

void NetworkController::parseMessageBody(std::string body)
{
	if(body == "OkForExit")
	{
		exitSocket = true;
	}
	else if(body == "YourAreTheGameClient")
	{
		status = ControllerStatus::Connected;
	}
	else if(body == "ErrorClientAlreadyConnected")
	{
		close();
	}
}


text:
// This example requires the Places library. Include the libraries=places
      // parameter when you first load the API. For example:
      //


text:
//
// Copyright (c) Microsoft and contributors.  All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
var should = require('should');
var util = require('util');
var msRestAzure = require('ms-rest-azure');

var SuiteBase = require('../../framework/suite-base');
var FileTokenCache = require('../../../lib/util/fileTokenCache');
var StorageManagementClient = require('../../../lib/services/cdnManagement/lib/cdnManagementClient');
var testPrefix = 'cdnCheckNameAvailability-tests';
var groupPrefix = 'cdnTestGroup';
var profilePrefix = 'cdnTestProfile';
var endpointPrefix = 'cdnTestEndpoint';
var createdGroups = [];
var createdProfiles = [];
var createdEndpoints = [];

var requiredEnvironment = [{
  name: 'AZURE_TEST_LOCATION',
  defaultValue: 'West US'
}];

var suite;
var client;
var profileName;
var groupName;
var endpointName;
var standardCreateParameters;
var validEndpointProperties;
var defaultLocation;

describe('Cdn Management CheckNameAvailability', function() {

  before(function(done) {
    suite = new SuiteBase(this, testPrefix, requiredEnvironment);
    suite.setupSuite(function() {
      groupName = suite.generateId(groupPrefix, createdGroups, suite.isMocked);
      client = new StorageManagementClient(suite.credentials, suite.subscriptionId);
      defaultLocation = process.env['AZURE_TEST_LOCATION'];
      profileName = suite.generateId(profilePrefix, createdProfiles, suite.isMocked);
      endpointName = suite.generateId(endpointPrefix, createdEndpoints, suite.isMocked);
      standardCreateParameters = {
        location: 'West US',
        tags: {
          tag1: 'val1',
          tag2: 'val2'
        },
        sku: {
          name: 'Standard_Verizon'
        }
      };
      validEndpointProperties = {
        location: 'West US',
        tags: {
          tag1: 'val1'
        },
        origins: [{
          name: 'somename',
          hostName: 'newname.azure.com'
        }]
      }
      if (suite.isPlayback) {
        client.longRunningOperationRetryTimeout = 0;
      }
      suite.createResourcegroup(groupName, defaultLocation, function(err, result) {
        should.not.exist(err);
        done();
      });
    });
  });

  after(function(done) {
    suite.teardownSuite(function() {
      suite.deleteResourcegroup(groupName, function(err, result) {
        should.not.exist(err);
        done();
      });
    });
  });

  beforeEach(function(done) {
    suite.setupTest(done);
  });

  afterEach(function(done) {
    suite.baseTeardownTest(done);
  });

  describe('cdn check name availability', function() {
    it('should return true when check a unique created endpoint name', function(done) {
      client.checkNameAvailability(endpointName, 'Microsoft.Cdn/Profiles/Endpoints', function(err, result, request, response) {
        should.not.exist(err);
        should.exist(result);
        result.nameAvailable.should.equal(true);
        done();
      });
    });

    it('should return false once endpoint is already used', function(done) {
      client.profiles.create(groupName, profileName, standardCreateParameters, function(err, result, request, response) {
        should.not.exist(err);
        client.endpoints.create(groupName, profileName, endpointName, validEndpointProperties, function(err, result, request, response) {
          should.not.exist(err);
          client.checkNameAvailability(endpointName, 'Microsoft.Cdn/Profiles/Endpoints', function(err, result, request, response) {
            should.not.exist(err);
            should.exist(result);
            result.nameAvailable.should.equal(false);
            done();
          });
        });
      });
    })
  });
});


text:
var SmartSweepers = (function() {
	"use strict";
	return {};
})();


text:
custom  a small theater between two guys~ , have fun!

可以自定义的两个人对话,或者互动答题.
配置规则详见config文件

## pages
[演示点我](https://twobear.github.io/littleTheater/)
[osChina演示点我](http://ccbear.oschina.io/littletheater)

## License

littleTheater基于 [MIT](http://opensource.org/licenses/MIT) 协议发布。请查阅LICENSE文件


text:
package lila.api

import play.api.libs.json._

import lila.common.PimpedJson._
import lila.db.api._
import lila.db.Implicits._
import lila.game.GameRepo
import lila.hub.actorApi.{ router => R }
import lila.rating.Perf
import lila.user.tube.userTube
import lila.user.{ UserRepo, User, Perfs, Profile }
import makeTimeout.short

private[api] final class UserApi(
    jsonView: lila.user.JsonView,
    relationApi: lila.relation.RelationApi,
    prefApi: lila.pref.PrefApi,
    makeUrl: Any => Fu[String],
    apiToken: String,
    userIdsSharingIp: String => Fu[List[String]]) {

  def list(
    team: Option[String],
    token: Option[String],
    nb: Option[Int],
    engine: Option[Boolean]): Fu[JsObject] = (team match {
    case Some(teamId) => lila.team.MemberRepo.userIdsByTeam(teamId) flatMap UserRepo.enabledByIds
    case None => $find(pimpQB($query(
      UserRepo.enabledSelect ++ (engine ?? UserRepo.engineSelect)
    )) sort UserRepo.sortPerfDesc(lila.rating.PerfType.Standard.key), makeNb(nb, token))
  }) flatMap { users =>
    users.map(u => makeUrl(R User u.username)).sequenceFu map { urls =>
      Json.obj(
        "list" -> JsArray(
          users zip urls map {
            case (u, url) => jsonView(u, extended = team.isDefined) ++ Json.obj("url" -> url).noNull
          }
        )
      )
    }
  }

  def one(username: String, token: Option[String])(implicit ctx: Context): Fu[Option[JsObject]] = UserRepo named username flatMap {
    case None => fuccess(none)
    case Some(u) => GameRepo mostUrgentGame u zip
      makeUrl(R User username) zip
      (check(token) ?? (knownEnginesSharingIp(u.id) map (_.some))) zip
      relationApi.nbFollowing(u.id) zip
      relationApi.nbFollowers(u.id) zip
      ctx.isAuth.?? { prefApi followable u.id } zip
      ctx.userId.?? { relationApi.relation(_, u.id) } zip
      ctx.userId.?? { relationApi.relation(u.id, _) } flatMap {
        case (((((((gameOption, userUrl), knownEngines), following), followers), followable), relation), revRelation) => gameOption ?? { g =>
          makeUrl(R.Watcher(g.gameId, g.color.name)) map (_.some)
        } map { gameUrlOption =>
          jsonView(u, extended = true) ++ {
            Json.obj(
              "url" -> userUrl,
              "playing" -> gameUrlOption,
              "knownEnginesSharingIp" -> knownEngines,
              "nbFollowing" -> following,
              "nbFollowers" -> followers
            ) ++ ctx.isAuth.??(Json.obj(
                "followable" -> followable,
                "following" -> relation.exists(true ==),
                "blocking" -> relation.exists(false ==),
                "followsYou" -> revRelation.exists(true ==)
              ))
          }.noNull
        }
      } map (_.some)
  }

  def knownEnginesSharingIp(userId: String): Fu[List[String]] =
    userIdsSharingIp(userId) flatMap UserRepo.filterByEngine

  private def makeNb(nb: Option[Int], token: Option[String]) = math.min(check(token) ? 1000 | 100, nb | 10)

  private def check(token: Option[String]) = token ?? (apiToken==)
}


text:
export default {
  logging: 'Connexion en cours...',
  logCall: 'Journal des appels',
  editLog: 'Éditer le journal',
  select: 'Sélectionner une correspondance de registre',
  OnHold: 'En attente',
  Ringing: 'Sonnerie en cours',
  CallConnected: 'Appel établi',
  unknownUser: 'Utilisateur inconnu',
  unknownNumber: 'Anonyme',
  unavailable: 'Non disponible',
  viewDetails: 'Afficher les détails',
  'phoneSource.systemUser': '(Utilisateur système)',
  'phoneSource.account': '(Compte)',
  'phoneSource.contact': '(Contact)',
  'phoneSource.lead': '(Piste)',
  'phoneType.phone': '(Téléphone)',
  'phoneType.home': '(Téléphone domicile)',
  'phoneType.business': '(Téléphone bureau)',
  'phoneType.mobile': '(Téléphone mobile)',
  'phoneType.unknown': '(Type de téléphone inconnu)',
};


text:
package com.gentics.mesh.core.rest.validation;

import java.util.Map;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.gentics.mesh.core.rest.common.GenericMessageResponse;
import com.gentics.mesh.core.rest.common.RestModel;

import io.vertx.core.json.JsonObject;

/**
 * Response of a schema / microschema validation.
 */
public class SchemaValidationResponse implements RestModel {

	@JsonProperty(required = true)
	@JsonPropertyDescription("Status of the validation.")
	ValidationStatus status;

	@JsonProperty(required = true)
	@JsonPropertyDescription("Detailed validation message.")
	GenericMessageResponse message;

	@JsonProperty(required = false)
	@JsonPropertyDescription("The generated default elasticsearch index configuration which includes the used analyzers and mappings.")
	JsonObject elasticsearch;

	@JsonProperty(required = false)
	@JsonPropertyDescription("The generated elasticsearch index configuration for each language.")
	Map<String, JsonObject> languageElasticsearch;

	/**
	 * Return the elasticsearch index configuration which was generated using the schema.
	 *
	 * @return
	 */
	public JsonObject getElasticsearch() {
		return elasticsearch;
	}

	/**
	 * Set the elasticsearch index configuration.
	 *
	 * @param elasticsearch
	 * @return
	 */
	public SchemaValidationResponse setElasticsearch(JsonObject elasticsearch) {
		this.elasticsearch = elasticsearch;
		return this;
	}

	public Map<String, JsonObject> getLanguageElasticsearch() {
		return languageElasticsearch;
	}

	public void setLanguageElasticsearch(Map<String, JsonObject> languageElasticsearch) {
		this.languageElasticsearch = languageElasticsearch;
	}

	/**
	 * Return the validation status.
	 *
	 * @return
	 */
	public ValidationStatus getStatus() {
		return status;
	}

	/**
	 * Set the status.
	 *
	 * @param status
	 * @return Fluent API
	 */
	public SchemaValidationResponse setStatus(ValidationStatus status) {
		this.status = status;
		return this;
	}

	/**
	 * Return the validation message.
	 *
	 * @return
	 */
	public GenericMessageResponse getMessage() {
		return message;
	}

	/**
	 * Set the message.
	 *
	 * @param message
	 * @return Fluent API
	 */
	public SchemaValidationResponse setMessage(GenericMessageResponse message) {
		this.message = message;
		return this;
	}
}


text:
package com.spiddekauga.http;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.UUID;

/**
 * Builds a new HTTP URL Connection
 */
public class HttpPostBuilder extends HttpParameterBuilder {
private static final String REGULAR_FORM_TYPE = "application/x-www-form-urlencoded";
private static final String FILE_UPLOAD_TYPE = "multipart/form-data";
private static final String CRLF = "\r\n";
private HttpURLConnection mConnection = null;
private OutputStream mOutput = null;
private PrintWriter mWriter = null;
private String mBoundary = UUID.randomUUID().toString();
private String mContentType = REGULAR_FORM_TYPE;
private boolean mFileUpload = false;

/**
 * Create a new connection as a POST request. To upload a file please call
 * {@link #doFileUpload()}
 * @param url string to parse as URL
 * @throws IOException
 * @throws MalformedURLException if no protocol is specified, or an unknown protocol
 *                               is found, or URL is null.
 */
public HttpPostBuilder(String url) throws MalformedURLException, IOException {
	HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
	setDefaultRequestProperties(connection);
	initConnection(connection);
}

/**
 * Initializes the connection and output
 * @param connection the connection to the server
 */
private void initConnection(HttpURLConnection connection) {
	mConnection = connection;
	mConnection.setDoOutput(true);
	try {
		mConnection.setRequestMethod("POST");
	} catch (ProtocolException e) {
		// Should never happen
		throw new RuntimeException(e);
	}
	setCharset(mCharset);
	resetContentTypeBondary();
}

/**
 * Reset content type and boundary
 */
private void resetContentTypeBondary() {
	if (mConnection != null) {
		String value = mContentType;
		if (mCharset != null && !mCharset.isEmpty()) {
			value += "; charset=" + mCharset;
		}
		if (mFileUpload && mBoundary != null && !mBoundary.isEmpty()) {
			value += "; boundary=" + mBoundary;
		}
		mConnection.setRequestProperty("Content-Type", value);
	}
}

/**
 * Create a new POST connection from a GET URL. This doesn't remove the GET
 * parameters. Rather it adds POST parameters to the URL request. To upload a file
 * please call {@link #doFileUpload()}
 * @param getBuilder builder for GET request
 * @throws IOException
 * @throws MalformedURLException
 */
public HttpPostBuilder(HttpGetBuilder getBuilder) throws MalformedURLException, IOException {
	HttpURLConnection connection = getBuilder.build();

	// Set charset from existing connection
	String charset = connection.getRequestProperty("Accept-Charset");
	if (charset != null) {
		mCharset = charset;
	}

	initConnection(connection);
}

/**
 * @return HttpUrlConnection if you want to set your own headers before adding
 * parameters.
 */
public HttpURLConnection getHttpURLConnection() {
	return mConnection;
}

/**
 * Set this POST builder to send the data as multipart that can handle files. This
 * method must be called before any calls to addParameter().
 * @throws IllegalStateException If any addParamater() method has been called.
 */
public void doFileUpload() {
	mFileUpload = true;
	setContentType(FILE_UPLOAD_TYPE);
}

/**
 * Set the content type of the message. Default is application/x-www-form-urlencoded
 * @param type content type
 */
private void setContentType(String type) {
	if (mOutput == null) {
		mContentType = type;
		resetContentTypeBondary();
	} else {
		throw new IllegalStateException("Output of parameters has already been started");
	}
}

/**
 * Set the boundary between messages. Defaults to random UUID
 * @param boundary message separator
 */
public void setBoundary(String boundary) {
	if (mOutput == null) {
		mBoundary = boundary;
		resetContentTypeBondary();
	} else {
		throw new IllegalStateException("Output of parameters has already been started");
	}
}

@Override
public void addParameter(String name, CharSequence text) throws IOException {
	if (!mFileUpload) {
		super.addParameter(name, text);
	} else {
		addParameter(name, text, "text/plain");
	}
}

/**
 * Add a text parameter with the specific content type
 * @param name field name
 * @param text value of the field
 * @param contentType type of content of value
 * @throws IOException
 */
protected void addParameter(String name, CharSequence text, String contentType) throws IOException {
	initOutput();
	beginParameter(name, contentType + "; charset=\"" + mCharset + "\"");
	mWriter.append(CRLF).append(text);
	endParameter();
}

/**
 * Initializes the output
 * @throws IOException
 */
private void initOutput() throws IOException {
	if (mOutput == null) {
		mOutput = mConnection.getOutputStream();
		mWriter = new PrintWriter(mOutput);
	}
}

/**
 * Begin writing a parameter
 * @param name field name
 * @param contentType content type
 */
private void beginParameter(String name, String contentType) {
	mWriter.append("--").append(mBoundary).append(CRLF);
	mWriter.append("Content-Disposition: form-data; name=\"").append(name).append("\"").append(CRLF);
	mWriter.append("Content-Type: ").append(contentType).append(CRLF);
}

/**
 * End a parameter
 */
private void endParameter() {
	mWriter.append(CRLF).flush();
}

@Override
public void addParameter(String name, byte[] array) throws IOException {
	if (!mFileUpload) {
		super.addParameter(name, array);
	} else {
		addParameter(name, array, "application/octet-stream");
	}
}

@Override
public void setCharset(String charset) {
	super.setCharset(charset);
	if (mOutput == null) {
//		mConnection.setRequestProperty("Accept-Charset", charset);
		resetContentTypeBondary();
	} else {
		throw new IllegalStateException("Output of parameters has already been started");
	}
}

/**
 * Add binary parameter with the specified content type
 * @param name field name
 * @param array binary array
 * @param contentType type of content value
 * @throws IOException
 */
protected void addParameter(String name, byte[] array, String contentType) throws IOException {
	initOutput();
	beginParameter(name, contentType);
	mWriter.append("Content-Transfer-Encoding: binary").append(CRLF).append(CRLF).flush();
	mOutput.write(array);
	mOutput.flush();
	endParameter();
}

/**
 * Add file parameter with as application/octet-stream. Adding a file requires the
 * content type to be set as multipart/form-data in {@link #setContentType(String)}.
 * @param name field name
 * @param file the file to upload
 * @throws IOException
 * @throws IllegalStateException if {@link #doFileUpload()} hasn't been called
 */
public void addFile(String name, File file) throws IOException {
	addFile(name, file, "application/octet-stream");
}

/**
 * Add binary parameter with the specified content type. Adding a file requires the
 * content type to be set as multipart/form-data in {@link #setContentType(String)}.
 * @param name field name
 * @param file binary array
 * @param contentType type of content value
 * @throws IOException
 * @throws IllegalStateException if {@link #doFileUpload()} hasn't been called
 */
public void addFile(String name, File file, String contentType) throws IOException {
	addFile(name, file, contentType, file.getName());
}

/**
 * Add binary parameter with the specified content type. Adding a file requires the
 * content type to be set as multipart/form-data in {@link #setContentType(String)}.
 * @param name field name
 * @param file binary array
 * @param contentType type of content value
 * @param filename custom filename
 * @throws IOException
 * @throws IllegalStateException if {@link #doFileUpload()} hasn't been called
 */
public void addFile(String name, File file, String contentType, String filename) throws IOException {
	if (mFileUpload) {
		initOutput();
		beginFileParameter(name, filename, contentType);
		DataInputStream dataInputStream = new DataInputStream(new FileInputStream(file));
		byte[] bytes = new byte[(int) file.length()];
		dataInputStream.readFully(bytes);
		dataInputStream.close();
		mOutput.write(bytes);
		mOutput.flush();
		endParameter();
	} else {
		throw new IllegalStateException("doFileUpload() hasn't been called");
	}
}

/**
 * Begin writing a file parameter
 * @param name field name
 * @param filename name of the file
 * @param contentType content type
 */
private void beginFileParameter(String name, String filename, String contentType) {
	mWriter.append("--").append(mBoundary).append(CRLF);
	mWriter.append("Content-Disposition: form-data; name=\"").append(name).append("\"; filename=\"").append(filename).append("\"").append(CRLF);
	mWriter.append("Content-Type: ").append(contentType).append(CRLF);
	mWriter.append("Content-Transfer-Encoding: binary").append(CRLF).append(CRLF).flush();
}

/**
 * Finalizes the connection. Call getInputStream() on the HttpURLConnection to
 * connect.
 * @return a HttpURLConnection ready to make a connection and receive a response
 * @throws IOException
 */
public HttpURLConnection build() throws IOException {
	if (!mFileUpload) {
		String body = mBuilder.toString();
		mConnection.setRequestProperty("Content-Length", String.valueOf(body.length()));
		initOutput();
		mWriter.append(body).flush();
	} else {
		mWriter.append("--").append(mBoundary).append("--").append(CRLF).flush();
	}

	return mConnection;
}
}


text:
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
//QUTIL: VANILLA

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.service.AbstractService;
import org.apache.hadoop.yarn.api.records.QueueACL;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights;
import org.apache.hadoop.yarn.util.Clock;
import org.apache.hadoop.yarn.util.SystemClock;
import org.apache.hadoop.yarn.util.resource.Resources;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;

import com.google.common.annotations.VisibleForTesting;

@Public
@Unstable
public class AllocationFileLoaderService extends AbstractService {

  public static final Log LOG = LogFactory.getLog(
      AllocationFileLoaderService.class.getName());

  /** Time to wait between checks of the allocation file */
  public static final long ALLOC_RELOAD_INTERVAL_MS = 10 * 1000;

  /**
   * Time to wait after the allocation has been modified before reloading it
   * (this is done to prevent loading a file that hasn't been fully written).
   */
  public static final long ALLOC_RELOAD_WAIT_MS = 5 * 1000;

  private final Clock clock;

  private long lastSuccessfulReload; // Last time we successfully reloaded queues
  private boolean lastReloadAttemptFailed = false;

  // Path to XML file containing allocations.
  private File allocFile;

  private Listener reloadListener;

  @VisibleForTesting
  long reloadIntervalMs = ALLOC_RELOAD_INTERVAL_MS;

  private Thread reloadThread;
  private volatile boolean running = true;

  public AllocationFileLoaderService() {
    this(new SystemClock());
  }

  public AllocationFileLoaderService(Clock clock) {
    super(AllocationFileLoaderService.class.getName());
    this.clock = clock;

  }

  @Override
  public void init(Configuration conf) {
    this.allocFile = getAllocationFile(conf);
    super.init(conf);
  }

  @Override
  public void start() {
    if (allocFile == null) {
      return;
    }
    reloadThread = new Thread() {
      public void run() {
        while (running) {
          long time = clock.getTime();
          long lastModified = allocFile.lastModified();
          if (lastModified > lastSuccessfulReload &&
              time > lastModified + ALLOC_RELOAD_WAIT_MS) {
            try {
              reloadAllocations();
            } catch (Exception ex) {
              if (!lastReloadAttemptFailed) {
                LOG.error("Failed to reload fair scheduler config file - " +
                    "will use existing allocations.", ex);
              }
              lastReloadAttemptFailed = true;
            }
          } else if (lastModified == 0l) {
            if (!lastReloadAttemptFailed) {
              LOG.warn("Failed to reload fair scheduler config file because" +
                  " last modified returned 0. File exists: " + allocFile.exists());
            }
            lastReloadAttemptFailed = true;
          }
          try {
            Thread.sleep(reloadIntervalMs);
          } catch (InterruptedException ex) {
            LOG.info("Interrupted while waiting to reload alloc configuration");
          }
        }
      }
    };
    reloadThread.setName("AllocationFileReloader");
    reloadThread.setDaemon(true);
    reloadThread.start();
    super.start();
  }

  @Override
  public void stop() {
    running = false;
    reloadThread.interrupt();
    super.stop();
  }

  /**
   * Path to XML file containing allocations. If the
   * path is relative, it is searched for in the
   * classpath, but loaded like a regular File.
   */
  public File getAllocationFile(Configuration conf) {
    String allocFilePath = conf.get(FairSchedulerConfiguration.ALLOCATION_FILE,
        FairSchedulerConfiguration.DEFAULT_ALLOCATION_FILE);
    File allocFile = new File(allocFilePath);
    if (!allocFile.isAbsolute()) {
      URL url = Thread.currentThread().getContextClassLoader()
          .getResource(allocFilePath);
      if (url == null) {
        LOG.warn(allocFilePath + " not found on the classpath.");
        allocFile = null;
      } else if (!url.getProtocol().equalsIgnoreCase("file")) {
        throw new RuntimeException("Allocation file " + url
            + " found on the classpath is not on the local filesystem.");
      } else {
        allocFile = new File(url.getPath());
      }
    }
    return allocFile;
  }

  public synchronized void setReloadListener(Listener reloadListener) {
    this.reloadListener = reloadListener;
  }

  /**
   * Updates the allocation list from the allocation config file. This file is
   * expected to be in the XML format specified in the design doc.
   *
   * @throws IOException if the config file cannot be read.
   * @throws AllocationConfigurationException if allocations are invalid.
   * @throws ParserConfigurationException if XML parser is misconfigured.
   * @throws SAXException if config file is malformed.
   */
  public synchronized void reloadAllocations() throws IOException,
      ParserConfigurationException, SAXException, AllocationConfigurationException {
    if (allocFile == null) {
      return;
    }
    LOG.info("Loading allocation file " + allocFile);
    // Create some temporary hashmaps to hold the new allocs, and we only save
    // them in our fields if we have parsed the entire allocs file successfully.
    Map<String, Resource> minQueueResources = new HashMap<String, Resource>();
    Map<String, Resource> maxQueueResources = new HashMap<String, Resource>();
    Map<String, Integer> queueMaxApps = new HashMap<String, Integer>();
    Map<String, Integer> userMaxApps = new HashMap<String, Integer>();
    Map<String, ResourceWeights> queueWeights = new HashMap<String, ResourceWeights>();
    Map<String, SchedulingPolicy> queuePolicies = new HashMap<String, SchedulingPolicy>();
    Map<String, Long> minSharePreemptionTimeouts = new HashMap<String, Long>();
    Map<String, Map<QueueACL, AccessControlList>> queueAcls =
        new HashMap<String, Map<QueueACL, AccessControlList>>();
    int userMaxAppsDefault = Integer.MAX_VALUE;
    int queueMaxAppsDefault = Integer.MAX_VALUE;
    long fairSharePreemptionTimeout = Long.MAX_VALUE;
    long defaultMinSharePreemptionTimeout = Long.MAX_VALUE;
    SchedulingPolicy defaultSchedPolicy = SchedulingPolicy.DEFAULT_POLICY;

    QueuePlacementPolicy newPlacementPolicy = null;

    // Remember all queue names so we can display them on web UI, etc.
    Set<String> queueNamesInAllocFile = new HashSet<String>();

    // Read and parse the allocations file.
    DocumentBuilderFactory docBuilderFactory =
      DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringComments(true);
    DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
    Document doc = builder.parse(allocFile);
    Element root = doc.getDocumentElement();
    if (!"allocations".equals(root.getTagName()))
      throw new AllocationConfigurationException("Bad fair scheduler config " +
          "file: top-level element not <allocations>");
    NodeList elements = root.getChildNodes();
    List<Element> queueElements = new ArrayList<Element>();
    Element placementPolicyElement = null;
    for (int i = 0; i < elements.getLength(); i++) {
      Node node = elements.item(i);
      if (node instanceof Element) {
        Element element = (Element)node;
        if ("queue".equals(element.getTagName()) ||
          "pool".equals(element.getTagName())) {
          queueElements.add(element);
        } else if ("user".equals(element.getTagName())) {
          String userName = element.getAttribute("name");
          NodeList fields = element.getChildNodes();
          for (int j = 0; j < fields.getLength(); j++) {
            Node fieldNode = fields.item(j);
            if (!(fieldNode instanceof Element))
              continue;
            Element field = (Element) fieldNode;
            if ("maxRunningApps".equals(field.getTagName())) {
              String text = ((Text)field.getFirstChild()).getData().trim();
              int val = Integer.parseInt(text);
              userMaxApps.put(userName, val);
            }
          }
        } else if ("userMaxAppsDefault".equals(element.getTagName())) {
          String text = ((Text)element.getFirstChild()).getData().trim();
          int val = Integer.parseInt(text);
          userMaxAppsDefault = val;
        } else if ("fairSharePreemptionTimeout".equals(element.getTagName())) {
          String text = ((Text)element.getFirstChild()).getData().trim();
          long val = Long.parseLong(text) * 1000L;
          fairSharePreemptionTimeout = val;
        } else if ("defaultMinSharePreemptionTimeout".equals(element.getTagName())) {
          String text = ((Text)element.getFirstChild()).getData().trim();
          long val = Long.parseLong(text) * 1000L;
          defaultMinSharePreemptionTimeout = val;
        } else if ("queueMaxAppsDefault".equals(element.getTagName())) {
          String text = ((Text)element.getFirstChild()).getData().trim();
          int val = Integer.parseInt(text);
          queueMaxAppsDefault = val;
        } else if ("defaultQueueSchedulingPolicy".equals(element.getTagName())
            || "defaultQueueSchedulingMode".equals(element.getTagName())) {
          String text = ((Text)element.getFirstChild()).getData().trim();
          defaultSchedPolicy = SchedulingPolicy.parse(text);
        } else if ("queuePlacementPolicy".equals(element.getTagName())) {
          placementPolicyElement = element;
        } else {
          LOG.warn("Bad element in allocations file: " + element.getTagName());
        }
      }
    }

    // Load queue elements.  A root queue can either be included or omitted.  If
    // it's included, all other queues must be inside it.
    for (Element element : queueElements) {
      String parent = "root";
      if (element.getAttribute("name").equalsIgnoreCase("root")) {
        if (queueElements.size() > 1) {
          throw new AllocationConfigurationException("If configuring root queue,"
              + " no other queues can be placed alongside it.");
        }
        parent = null;
      }
      loadQueue(parent, element, minQueueResources, maxQueueResources, queueMaxApps,
          userMaxApps, queueWeights, queuePolicies, minSharePreemptionTimeouts,
          queueAcls, queueNamesInAllocFile);
    }

    // Load placement policy and pass it configured queues
    Configuration conf = getConfig();
    if (placementPolicyElement != null) {
      newPlacementPolicy = QueuePlacementPolicy.fromXml(placementPolicyElement,
          queueNamesInAllocFile, conf);
    } else {
      newPlacementPolicy = QueuePlacementPolicy.fromConfiguration(conf,
          queueNamesInAllocFile);
    }

    AllocationConfiguration info = new AllocationConfiguration(minQueueResources, maxQueueResources,
        queueMaxApps, userMaxApps, queueWeights, userMaxAppsDefault,
        queueMaxAppsDefault, queuePolicies, defaultSchedPolicy, minSharePreemptionTimeouts,
        queueAcls, fairSharePreemptionTimeout, defaultMinSharePreemptionTimeout,
        newPlacementPolicy, queueNamesInAllocFile);

    lastSuccessfulReload = clock.getTime();
    lastReloadAttemptFailed = false;

    reloadListener.onReload(info);
  }

  /**
   * Loads a queue from a queue element in the configuration file
   */
  private void loadQueue(String parentName, Element element, Map<String, Resource> minQueueResources,
      Map<String, Resource> maxQueueResources, Map<String, Integer> queueMaxApps,
      Map<String, Integer> userMaxApps, Map<String, ResourceWeights> queueWeights,
      Map<String, SchedulingPolicy> queuePolicies,
      Map<String, Long> minSharePreemptionTimeouts,
      Map<String, Map<QueueACL, AccessControlList>> queueAcls, Set<String> queueNamesInAllocFile)
      throws AllocationConfigurationException {
    String queueName = element.getAttribute("name");
    if (parentName != null) {
      queueName = parentName + "." + queueName;
    }
    Map<QueueACL, AccessControlList> acls =
        new HashMap<QueueACL, AccessControlList>();
    NodeList fields = element.getChildNodes();
    boolean isLeaf = true;

    for (int j = 0; j < fields.getLength(); j++) {
      Node fieldNode = fields.item(j);
      if (!(fieldNode instanceof Element))
        continue;
      Element field = (Element) fieldNode;
      if ("minResources".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData().trim();
        Resource val = FairSchedulerConfiguration.parseResourceConfigValue(text);
        minQueueResources.put(queueName, val);
      } else if ("maxResources".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData().trim();
        Resource val = FairSchedulerConfiguration.parseResourceConfigValue(text);
        maxQueueResources.put(queueName, val);
      } else if ("maxRunningApps".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData().trim();
        int val = Integer.parseInt(text);
        queueMaxApps.put(queueName, val);
      } else if ("weight".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData().trim();
        double val = Double.parseDouble(text);
        queueWeights.put(queueName, new ResourceWeights((float)val));
      } else if ("minSharePreemptionTimeout".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData().trim();
        long val = Long.parseLong(text) * 1000L;
        minSharePreemptionTimeouts.put(queueName, val);
      } else if ("schedulingPolicy".equals(field.getTagName())
          || "schedulingMode".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData().trim();
        SchedulingPolicy policy = SchedulingPolicy.parse(text);
        queuePolicies.put(queueName, policy);
      } else if ("aclSubmitApps".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData();
        acls.put(QueueACL.SUBMIT_APPLICATIONS, new AccessControlList(text));
      } else if ("aclAdministerApps".equals(field.getTagName())) {
        String text = ((Text)field.getFirstChild()).getData();
        acls.put(QueueACL.ADMINISTER_QUEUE, new AccessControlList(text));
      } else if ("queue".endsWith(field.getTagName()) ||
          "pool".equals(field.getTagName())) {
        loadQueue(queueName, field, minQueueResources, maxQueueResources,
            queueMaxApps, userMaxApps, queueWeights, queuePolicies,
            minSharePreemptionTimeouts,
            queueAcls, queueNamesInAllocFile);
        isLeaf = false;
      }
    }
    if (isLeaf) {
      queueNamesInAllocFile.add(queueName);
    }
    queueAcls.put(queueName, acls);
    if (maxQueueResources.containsKey(queueName) && minQueueResources.containsKey(queueName)
        && !Resources.fitsIn(minQueueResources.get(queueName),
            maxQueueResources.get(queueName))) {
      LOG.warn(String.format("Queue %s has max resources %s less than min resources %s",
          queueName, maxQueueResources.get(queueName), minQueueResources.get(queueName)));
    }
  }

  public interface Listener {
    public void onReload(AllocationConfiguration info);
  }
}


text:
'use strict';

var path = require('path');
var assemblefile = require('./support/assemblefile');
var cwd = process.cwd();

module.exports = function(verb) {
  verb.use(require('verb-generate-readme'));

  verb.task('assemble', function(cb) {
    process.chdir(path.join(__dirname, 'support'));
    assemblefile.build(cb);
  });

  verb.task('docs', function(cb) {
    process.chdir(cwd);
    verb.build('readme', cb);
  });

  verb.task('default', ['docs', 'assemble']);
};


text:
from panda3d.core import GeomNode, NodePath, Plane, PlaneNode, TextNode
from direct.interval.IntervalGlobal import *
from direct.showbase.ShowBase import Plane
from direct.directnotify import DirectNotifyGlobal
from direct.showbase.RandomNumGen import RandomNumGen
from direct.interval.MetaInterval import Sequence, Parallel
from direct.interval.FunctionInterval import Func, Wait
from direct.gui.DirectGui import *
from toontown.toonbase.ToontownGlobals import *
from toontown.toonbase import TTLocalizer
from toontown.suit import Suit, SuitDNA
from toontown.toon import Toon, ToonHead, ToonDNA, NPCToons
from DistributedCogdoInterior import *
from CogdoUtil import CogdoGameMovie
import CogdoUtil

class CogdoElevatorMovie(CogdoGameMovie):
    notify = DirectNotifyGlobal.directNotify.newCategory('CogdoElevatorMovie')
    elevatorDuration = 5

    def __init__(self):
        CogdoGameMovie.__init__(self)
        self._toonDialogueSfx = None
        self.toonHead = None
        self.frame = None
        return

    def displayLine(self, text):
        self.notify.debug('displayLine')
        self._dialogueLabel.node().setText(text)
        self.toonHead.reparentTo(aspect2d)
        self._toonDialogueSfx.play()
        self.toonHead.setClipPlane(self.clipPlane)

    def makeSuit(self, suitType):
        self.notify.debug('makeSuit()')
        suit = Suit.Suit()
        dna = SuitDNA.SuitDNA()
        dna.newSuit(suitType)
        suit.setStyle(dna)
        suit.isDisguised = 1
        suit.generateSuit()
        suit.setScale(1.05, 1.05, 2.05)
        suit.setPos(0, 0, -4.4)
        suit.reparentTo(self.toonHead)
        for part in suit.getHeadParts():
            part.hide()

        suit.loop('neutral')

    def load(self):
        self.notify.debug('load()')
        CogdoGameMovie.load(self)
        backgroundGui = loader.loadModel('phase_5/models/cogdominium/tt_m_gui_csa_flyThru')
        self.bg = backgroundGui.find('**/background')
        self.chatBubble = backgroundGui.find('**/chatBubble')
        self.chatBubble.setScale(6.5, 6.5, 7.3)
        self.chatBubble.setPos(0.32, 0, -0.78)
        self.bg.setScale(5.2)
        self.bg.setPos(0.14, 0, -0.6667)
        self.bg.reparentTo(aspect2d)
        self.chatBubble.reparentTo(aspect2d)
        self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.2, 0, -0.6667))
        self.bg.wrtReparentTo(self.frame)
        self.gameTitleText = DirectLabel(parent=self.frame, text=TTLocalizer.CogdoExecutiveSuiteTitle, scale=TTLocalizer.MRPgameTitleText * 0.8, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None)
        self.chatBubble.wrtReparentTo(self.frame)
        self.frame.hide()
        backgroundGui.removeNode()
        self.toonDNA = ToonDNA.ToonDNA()
        self.toonDNA.newToonFromProperties(*NPCToons.getNPCDNA(7027))
        self.toonHead = Toon.Toon()
        self.toonHead.setDNA(self.toonDNA)
        self.makeSuit('sc')
        self.toonHead.getGeomNode().setDepthWrite(1)
        self.toonHead.getGeomNode().setDepthTest(1)
        self.toonHead.loop('neutral')
        self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18, 0.18)
        self.toonHead.reparentTo(hidden)
        self.toonHead.startBlink()
        self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip'))
        self.clipPlane.node().setPlane(Plane(0, 0, 1, 0))
        self.clipPlane.setPos(0, 0, 2.45)
        self._toonDialogueSfx = loader.loadSfx('phase_3.5/audio/dial/AV_dog_long.ogg')
        self._camHelperNode = NodePath('CamHelperNode')
        self._camHelperNode.reparentTo(render)
        dialogue = TTLocalizer.CogdoMazeGameElevatorRewardLaff

        def start():
            self.frame.show()
            base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 0)

        def end():
            self._dialogueLabel.reparentTo(hidden)
            self.toonHead.reparentTo(hidden)
            self.frame.hide()
            base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 1)
            self._stopUpdateTask()

        self._ival = Sequence(Func(start), Func(self.displayLine, dialogue), Wait(self.elevatorDuration), Func(end))
        self._startUpdateTask()
        return

    def _updateTask(self, task):
        dt = globalClock.getDt()
        return task.cont

    def unload(self):
        self.frame.destroy()
        del self.frame
        self.bg.removeNode()
        del self.bg
        self.chatBubble.removeNode()
        del self.chatBubble
        self.toonHead.stopBlink()
        self.toonHead.stop()
        self.toonHead.removeNode()
        self.toonHead.delete()
        del self.toonHead
        CogdoGameMovie.unload(self)