Package ch.entwine.weblounge.common.impl.util.doc

Examples of ch.entwine.weblounge.common.impl.util.doc.Endpoint


  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "sqldirectoryprovider");
    docs.setTitle("Weblounge SQL Directory Provider");

    // GET /
    Endpoint getStatus = new Endpoint("/", Method.GET, "status");
    getStatus.setDescription("Returns the directory provider status");
    getStatus.addFormat(Format.xml());
    getStatus.addStatus(ok("status has been sent back to the client"));
    getStatus.addStatus(notFound("the site does not exist"));
    getStatus.addStatus(serviceUnavailable("the site is temporarily offline"));
    getStatus.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getStatus);

    // PUT /status
    Endpoint enableSiteLogins = new Endpoint("/status", Method.PUT, "enable");
    enableSiteLogins.setDescription("Enables login to the site");
    enableSiteLogins.addFormat(Format.xml());
    enableSiteLogins.addStatus(ok("site logins have been enabled"));
    enableSiteLogins.addStatus(notModified("site logins were already enabled"));
    enableSiteLogins.addStatus(notFound("the site does not exist"));
    enableSiteLogins.addStatus(serviceUnavailable("the site is temporarily offline"));
    enableSiteLogins.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, enableSiteLogins);

    // DELETE /status
    Endpoint disableSiteLogins = new Endpoint("/status", Method.DELETE, "disable");
    disableSiteLogins.setDescription("Disables login to the site");
    disableSiteLogins.addFormat(Format.xml());
    disableSiteLogins.addStatus(ok("site logins have been disabled"));
    disableSiteLogins.addStatus(notModified("site logins were already disabled"));
    disableSiteLogins.addStatus(notFound("the site does not exist"));
    disableSiteLogins.addStatus(serviceUnavailable("the site is temporarily offline"));
    disableSiteLogins.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, disableSiteLogins);

    // POST /account
    Endpoint createAccount = new Endpoint("/account", Method.POST, "createaccount");
    createAccount.setDescription("Creates a new account in this site");
    createAccount.addFormat(Format.xml());
    createAccount.addStatus(created("the account has been created and the account's location is part of the response"));
    createAccount.addStatus(conflict("an account with that login already exists"));
    createAccount.addStatus(badRequest("the login is malformed or empty"));
    createAccount.addStatus(notFound("the site does not exist"));
    createAccount.addStatus(serviceUnavailable("the site is temporarily offline"));
    createAccount.setTestForm(new TestForm());
    createAccount.addRequiredParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    createAccount.addRequiredParameter(new Parameter("password", Parameter.Type.Password, "Password"));
    createAccount.addOptionalParameter(new Parameter("email", Parameter.Type.String, "E-mail address"));
    docs.addEndpoint(Endpoint.Type.WRITE, createAccount);

    // GET /account/{login}
    Endpoint getAccount = new Endpoint("/account/{login}", Method.GET, "getaccount");
    getAccount.setDescription("Returns the account");
    getAccount.addFormat(Format.xml());
    getAccount.addStatus(ok("the account information has been sent back to the client"));
    getAccount.addStatus(forbidden("insufficient rights to access the account"));
    getAccount.addStatus(notFound("the account does not exist"));
    getAccount.addStatus(notFound("the site does not exist"));
    getAccount.addStatus(serviceUnavailable("the site is temporarily offline"));
    getAccount.setTestForm(new TestForm());
    getAccount.addPathParameter(new Parameter("login", Parameter.Type.String, "Login name"));
    docs.addEndpoint(Endpoint.Type.READ, getAccount);

    // PUT /account/{login}
    Endpoint updateAccount = new Endpoint("/account/{login}", Method.PUT, "updateaccount");
    updateAccount.setDescription("Updates the account");
    updateAccount.addFormat(Format.xml());
    updateAccount.addStatus(ok("the account has been updated"));
    updateAccount.addStatus(forbidden("insufficient rights to update the account"));
    updateAccount.addStatus(badRequest("if a non-existing language identifier is provided"));
    updateAccount.addStatus(notFound("the account does not exist"));
    updateAccount.addStatus(notFound("the site does not exist"));
    updateAccount.addStatus(serviceUnavailable("the site is temporarily offline"));
    updateAccount.setTestForm(new TestForm());
    updateAccount.addPathParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    updateAccount.addOptionalParameter(new Parameter("email", Parameter.Type.String, "E-mail address"));
    updateAccount.addOptionalParameter(new Parameter("firstname", Parameter.Type.String, "First name"));
    updateAccount.addOptionalParameter(new Parameter("lastname", Parameter.Type.String, "Last name"));
    updateAccount.addOptionalParameter(new Parameter("initials", Parameter.Type.String, "Initials"));
    updateAccount.addOptionalParameter(new Parameter("language", Parameter.Type.String, "Two letter ISO code for the preferred language"));
    docs.addEndpoint(Endpoint.Type.WRITE, updateAccount);

    // PUT /account/{login}/password
    Endpoint updateAccountPassword = new Endpoint("/account/{login}/password", Method.PUT, "updateaccountpassword");
    updateAccountPassword.setDescription("Updates the account password");
    updateAccountPassword.addFormat(Format.xml());
    updateAccountPassword.addStatus(ok("the password has been updated"));
    updateAccountPassword.addStatus(forbidden("insufficient rights to update the account"));
    updateAccountPassword.addStatus(notFound("the account does not exist"));
    updateAccountPassword.addStatus(notFound("the site does not exist"));
    updateAccountPassword.addStatus(serviceUnavailable("the site is temporarily offline"));
    updateAccountPassword.setTestForm(new TestForm());
    updateAccountPassword.addPathParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    updateAccountPassword.addOptionalParameter(new Parameter("password", Parameter.Type.Password, "Password"));
    docs.addEndpoint(Endpoint.Type.WRITE, updateAccountPassword);

    // PUT /account/{login}/challenge
    Endpoint updateAccountChallenge = new Endpoint("/account/{login}/challenge", Method.PUT, "updateaccountchallenge");
    updateAccountChallenge.setDescription("Updates the account challenge");
    updateAccountChallenge.addFormat(Format.xml());
    updateAccountChallenge.addStatus(ok("the challenge has been updated"));
    updateAccountChallenge.addStatus(forbidden("insufficient rights to update the account"));
    updateAccountChallenge.addStatus(notFound("the account does not exist"));
    updateAccountChallenge.addStatus(notFound("the site does not exist"));
    updateAccountChallenge.addStatus(serviceUnavailable("the site is temporarily offline"));
    updateAccountChallenge.setTestForm(new TestForm());
    updateAccountChallenge.addPathParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    updateAccountChallenge.addOptionalParameter(new Parameter("challenge", Parameter.Type.String, "Password"));
    updateAccountChallenge.addOptionalParameter(new Parameter("response", Parameter.Type.Password, "Password"));
    docs.addEndpoint(Endpoint.Type.WRITE, updateAccountChallenge);

    // DELETE /account/{login}
    Endpoint deleteAccount = new Endpoint("/account/{login}", Method.DELETE, "removeaccount");
    deleteAccount.setDescription("Removes the account from the site");
    deleteAccount.addFormat(Format.xml());
    deleteAccount.addStatus(ok("the account has been removed"));
    deleteAccount.addStatus(notFound("the account does not exist"));
    deleteAccount.addStatus(notFound("the site does not exist"));
    deleteAccount.addStatus(serviceUnavailable("the site is temporarily offline"));
    deleteAccount.setTestForm(new TestForm());
    deleteAccount.addPathParameter(new Parameter("login", Parameter.Type.String, "Login name"));
    docs.addEndpoint(Endpoint.Type.WRITE, deleteAccount);

    // PUT /account/{login}/status
    Endpoint enableAccount = new Endpoint("/account/{login}/status", Method.PUT, "enableaccount");
    enableAccount.setDescription("Enables the account");
    enableAccount.addFormat(Format.xml());
    enableAccount.addStatus(ok("the account has been enabled"));
    enableAccount.addStatus(notModified("the account was already enabled"));
    enableAccount.addStatus(forbidden("insufficient rights to enable the account"));
    enableAccount.addStatus(notFound("the account does not exist"));
    enableAccount.addStatus(notFound("the site does not exist"));
    enableAccount.addStatus(serviceUnavailable("the site is temporarily offline"));
    enableAccount.setTestForm(new TestForm());
    enableAccount.addPathParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    docs.addEndpoint(Endpoint.Type.WRITE, enableAccount);

    // DELETE /account/{login}/status
    Endpoint disableAccount = new Endpoint("/account/{login}/status", Method.DELETE, "disableaccount");
    disableAccount.setDescription("Disables the account");
    disableAccount.addFormat(Format.xml());
    disableAccount.addStatus(ok("the account has been disabled"));
    disableAccount.addStatus(notModified("the account is already disabled"));
    disableAccount.addStatus(forbidden("insufficient rights to disable the account"));
    disableAccount.addStatus(notFound("the account does not exist"));
    disableAccount.addStatus(notFound("the site does not exist"));
    disableAccount.addStatus(serviceUnavailable("the site is temporarily offline"));
    disableAccount.setTestForm(new TestForm());
    disableAccount.addPathParameter(new Parameter("login", Parameter.Type.String, "Login name"));
    docs.addEndpoint(Endpoint.Type.WRITE, disableAccount);

    // POST /account/{login}/roles/{context}
    Endpoint addRole = new Endpoint("/account/{login}/roles/{context}", Method.POST, "addrole");
    addRole.setDescription("Adds a role to the account");
    addRole.addFormat(Format.xml());
    addRole.addStatus(ok("the role has been added"));
    addRole.addStatus(notModified("the role is already owned by the account"));
    addRole.addStatus(badRequest("the role parameter is blank"));
    addRole.addStatus(forbidden("insufficient rights to add the role"));
    addRole.addStatus(notFound("the account does not exist"));
    addRole.addStatus(notFound("the site does not exist"));
    addRole.addStatus(serviceUnavailable("the site is temporarily offline"));
    addRole.setTestForm(new TestForm());
    addRole.addPathParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    addRole.addPathParameter(new Parameter("context", Parameter.Type.String, "Role context"));
    addRole.addRequiredParameter(new Parameter("role", Parameter.Type.String, "Role name"));
    docs.addEndpoint(Endpoint.Type.WRITE, addRole);

    // DELETE /account/{login}/roles/{context}
    Endpoint removeRole = new Endpoint("/account/{login}/roles/{context}", Method.DELETE, "removerole");
    removeRole.setDescription("Removes a role from the account");
    removeRole.addFormat(Format.xml());
    removeRole.addStatus(ok("the role has been removed"));
    removeRole.addStatus(notModified("the role had not been owned by the account"));
    removeRole.addStatus(badRequest("the role parameter is blank"));
    removeRole.addStatus(forbidden("insufficient rights to remove the role"));
    removeRole.addStatus(notFound("the account does not exist"));
    removeRole.addStatus(notFound("the site does not exist"));
    removeRole.addStatus(serviceUnavailable("the site is temporarily offline"));
    removeRole.setTestForm(new TestForm());
    removeRole.addPathParameter(new Parameter("login", Parameter.Type.String, "Unique login name"));
    removeRole.addPathParameter(new Parameter("context", Parameter.Type.String, "Role context"));
    removeRole.addRequiredParameter(new Parameter("role", Parameter.Type.String, "Role name"));
    docs.addEndpoint(Endpoint.Type.WRITE, removeRole);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here


  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "workbench");
    docs.setTitle("Weblounge Workbench");

    // GET /edit/{page}/{composer}/{pageletindex}
    Endpoint getPageletEditor = new Endpoint("/edit/{page}/{composer}/{pageletindex}", Method.GET, "getpageleteditor");
    getPageletEditor.setDescription("Returns the editor for the given pagelet");
    getPageletEditor.addFormat(new Format("xml", null, null));
    getPageletEditor.addStatus(ok("the pagelet was found and it's editing information is returned"));
    getPageletEditor.addStatus(notFound("the page, the composer or the pagelet were not found"));
    getPageletEditor.addStatus(serviceUnavailable("the site is temporarily offline"));
    getPageletEditor.addPathParameter(new Parameter("page", Parameter.Type.String, "The page uri"));
    getPageletEditor.addPathParameter(new Parameter("composer", Parameter.Type.String, "The composer identifier"));
    getPageletEditor.addPathParameter(new Parameter("pageletindex", Parameter.Type.String, "The pagelet's index within the composer (0 based)"));
    getPageletEditor.addOptionalParameter(new Parameter("language", Parameter.Type.String, "The language id"));
    getPageletEditor.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getPageletEditor);
   
    Endpoint getRenderer = new Endpoint("/renderer/{page}/{composer}/{pageletindex}", Method.GET, "getrenderer");
    getRenderer.setDescription("Returns the renderer for the given pagelet");
    getRenderer.addFormat(new Format("html", null, null));
    getRenderer.addStatus(ok("the pagelet was found and it's renderer is returned"));
    getRenderer.addStatus(notFound("the page, the composer, the pagelet or the renderer were not found"));
    getRenderer.addStatus(serviceUnavailable("the site is temporarily offline"));
    getRenderer.addPathParameter(new Parameter("page", Parameter.Type.String, "The page uri"));
    getRenderer.addPathParameter(new Parameter("composer", Parameter.Type.String, "The composer identifier"));
    getRenderer.addPathParameter(new Parameter("pageletindex", Parameter.Type.String, "The pagelet's index within the composer (0 based)"));
    getRenderer.addOptionalParameter(new Parameter("language", Parameter.Type.String, "The language id"));
    getRenderer.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getRenderer);

    // GET /suggest/subjects/{hint}
    Endpoint suggestSubjects = new Endpoint("/suggest/subjects/{seed}", Method.GET, "suggestsubjects");
    suggestSubjects.setDescription("Returns suggestions for subjects based on the given seed");
    suggestSubjects.addFormat(new Format("xml", null, null));
    suggestSubjects.addStatus(ok("suggestions based on the seed are returned"));
    suggestSubjects.addStatus(serviceUnavailable("the site is temporarily offline"));
    suggestSubjects.addPathParameter(new Parameter("seed", Parameter.Type.String, "The seed on which suggestions are based"));
    suggestSubjects.addOptionalParameter(new Parameter("limit", Parameter.Type.String, "The maximum number of suggestions"));
    suggestSubjects.addOptionalParameter(new Parameter("highlight", Parameter.Type.String, "The tag name used to highlight matches"));
    suggestSubjects.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, suggestSubjects);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "runtimeinfo");
    docs.setTitle("Weblounge Runtime Information");

    // GET /
    Endpoint sitesEndpoint = new Endpoint("/", Method.GET, "getinfo");
    sitesEndpoint.setDescription("Returns all runtime information");
    sitesEndpoint.addFormat(Format.xml());
    sitesEndpoint.addStatus(ok("the runtime information is returned as part of the response"));
    sitesEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, sitesEndpoint);

    // GET /{component}
    Endpoint siteEndpoint = new Endpoint("/{component}", Method.GET, "getcomponent");
    siteEndpoint.setDescription("Returns the specified part of the runtime information");
    siteEndpoint.addFormat(Format.xml());
    siteEndpoint.addStatus(ok("the component was found and the corresponding runtime information is returned as part of the response"));
    siteEndpoint.addStatus(notFound("the component was not found"));
    siteEndpoint.addPathParameter(new Parameter("component", Parameter.Type.String, "The runtime information component"));
    siteEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, siteEndpoint);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "sites");
    docs.setTitle("Weblounge Sites");

    // GET /
    Endpoint sitesEndpoint = new Endpoint("/", Method.GET, "getsites");
    sitesEndpoint.setDescription("Returns all sites");
    sitesEndpoint.addFormat(Format.xml());
    sitesEndpoint.addStatus(ok("the sites are returned as part of the response"));
    sitesEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, sitesEndpoint);

    // GET /{site}
    Endpoint siteEndpoint = new Endpoint("/{site}", Method.GET, "getsite");
    siteEndpoint.setDescription("Returns the site with the given id");
    siteEndpoint.addFormat(Format.xml());
    siteEndpoint.addStatus(ok("the site was found and is returned as part of the response"));
    siteEndpoint.addStatus(notFound("the site was not found"));
    siteEndpoint.addPathParameter(new Parameter("site", Parameter.Type.String, "The site identifier"));
    siteEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, siteEndpoint);

    // PUT /{site}
    Endpoint updateSiteEndpoint = new Endpoint("/{site}", Method.PUT, "updatesite");
    updateSiteEndpoint.setDescription("Updates the specified site");
    updateSiteEndpoint.addFormat(Format.xml());
    updateSiteEndpoint.addStatus(ok("the site was updated"));
    updateSiteEndpoint.addStatus(badRequest("the site identifier was not specified"));
    updateSiteEndpoint.addStatus(badRequest("the site status is malformed"));
    updateSiteEndpoint.addStatus(notFound("the site to update was not found"));
    updateSiteEndpoint.addPathParameter(new Parameter("site", Parameter.Type.String, "The site identifier"));
    updateSiteEndpoint.addOptionalParameter(new Parameter("status", Parameter.Type.Text, "The site status", "on"));
    updateSiteEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, updateSiteEndpoint);

    // GET /{site}/modules
    Endpoint modulesEndpoint = new Endpoint("/{site}/modules", Method.GET, "getmodules");
    modulesEndpoint.setDescription("Returns the modules of the site with the given id");
    modulesEndpoint.addFormat(Format.xml());
    modulesEndpoint.addStatus(ok("the site was found and its modules are returned as part of the response"));
    modulesEndpoint.addStatus(notFound("the site was not found"));
    modulesEndpoint.addPathParameter(new Parameter("site", Parameter.Type.String, "The site identifier"));
    modulesEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, modulesEndpoint);
   
    // GET /{site}/modules/{module}
    Endpoint moduleEndpoint = new Endpoint("/{site}/modules/{module}", Method.GET, "getmodule");
    moduleEndpoint.setDescription("Returns the module with the given id");
    moduleEndpoint.addFormat(Format.xml());
    moduleEndpoint.addStatus(ok("the module was found and is returned as part of the response"));
    moduleEndpoint.addStatus(notFound("either the site or the module was not found"));
    moduleEndpoint.addPathParameter(new Parameter("site", Parameter.Type.String, "The site identifier"));
    moduleEndpoint.addPathParameter(new Parameter("module", Parameter.Type.String, "The module identifier"));
    moduleEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, moduleEndpoint);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "cache");
    docs.setTitle("Weblounge Cache");

    // GET /
    Endpoint getStatistics = new Endpoint("/", Method.GET, "stats");
    getStatistics.setDescription("Returns cache statistics");
    getStatistics.addFormat(Format.xml());
    getStatistics.addStatus(ok("statistics have been compiled and sent back to the client"));
    getStatistics.addStatus(notFound("the site does not exist"));
    getStatistics.addStatus(serviceUnavailable("the site is temporarily offline"));
    getStatistics.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getStatistics);

    // PUT /
    Endpoint startCacheEndpoint = new Endpoint("/", Method.PUT, "start");
    startCacheEndpoint.setDescription("Enables caching for the current site");
    startCacheEndpoint.addFormat(Format.xml());
    startCacheEndpoint.addStatus(ok("the cache was enabled"));
    startCacheEndpoint.addStatus(notModified("the cache was already enabled"));
    startCacheEndpoint.addStatus(notFound("the site does not exist"));
    startCacheEndpoint.addStatus(serviceUnavailable("the site is temporarily offline"));
    startCacheEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, startCacheEndpoint);

    // DELETE /
    Endpoint stopCacheEndpoint = new Endpoint("/", Method.DELETE, "stop");
    stopCacheEndpoint.setDescription("Disables caching for the current site");
    stopCacheEndpoint.addFormat(Format.xml());
    stopCacheEndpoint.addStatus(ok("the cache was disabled"));
    stopCacheEndpoint.addStatus(notModified("the cache was already disabled"));
    stopCacheEndpoint.addStatus(notFound("the site does not exist"));
    stopCacheEndpoint.addStatus(serviceUnavailable("the site is temporarily offline"));
    stopCacheEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, stopCacheEndpoint);

    // DELETE /content
    Endpoint clearCacheEndpoint = new Endpoint("/content", Method.DELETE, "clear");
    clearCacheEndpoint.setDescription("Clear the cache for the current site");
    clearCacheEndpoint.addFormat(Format.xml());
    clearCacheEndpoint.addStatus(ok("the cache was cleared"));
    clearCacheEndpoint.addStatus(notFound("the site does not exist"));
    clearCacheEndpoint.addStatus(serviceUnavailable("the site is temporarily offline"));
    clearCacheEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, clearCacheEndpoint);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "fop");
    docs.setTitle("Weblounge Formatting Object Processor Endpoint");

    // POST /pdf
    Endpoint createPDFEndpoint = new Endpoint("/pdf", Method.POST, "createpdf");
    createPDFEndpoint.setDescription("Creates a PDF document");
    createPDFEndpoint.addFormat(new Format("pdf", "Portable Document Format", "http://en.wikipedia.org/wiki/Portable_Document_Format"));
    createPDFEndpoint.addStatus(ok("the document was created"));
    createPDFEndpoint.addStatus(badRequest("the xml document url is not a regular url"));
    createPDFEndpoint.addStatus(badRequest("the xsl document url is not a regular url"));
    createPDFEndpoint.addStatus(notFound("the xml document could not be accessed at the given address"));
    createPDFEndpoint.addStatus(notFound("the xsl document could not be accessed at the given address"));
    createPDFEndpoint.addRequiredParameter(new Parameter("xml", Parameter.Type.String, "URL to the xml document"));
    createPDFEndpoint.addRequiredParameter(new Parameter("xsl", Parameter.Type.String, "URL to the xsl document"));
    createPDFEndpoint.addOptionalParameter(new Parameter("parameters", Parameter.Type.String, "Parameters, formatted as 'a=b;c=d'"));
    createPDFEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, createPDFEndpoint);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

        "created-desc",
        "modified-asc",
        "modified-desc" };

    // GET /?path=x&...
    Endpoint getFileByPathEndpoint = new Endpoint("/", Method.GET, "getfile");
    getFileByPathEndpoint.setDescription("Returns a set of files or a single file if the path parameter is specified");
    getFileByPathEndpoint.addFormat(Format.xml());
    getFileByPathEndpoint.addStatus(ok("A resultset was compiled and returned as part of the response"));
    getFileByPathEndpoint.addStatus(notFound("When a path parameter was specified, and no resource was found"));
    getFileByPathEndpoint.addStatus(badRequest("An invalid path was received"));
    getFileByPathEndpoint.addStatus(serviceUnavailable("The site or its content repository is temporarily offline"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("path", Parameter.Type.String, "The resource path"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("subjects", Parameter.Type.String, "The page subjects, separated by a comma"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("searchterms", Parameter.Type.String, "search terms to search the pages content"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("filter", Parameter.Type.String, "Filter for the current result set"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("type", Parameter.Type.String, "The file type, e. g. 'image'"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("sort", Parameter.Type.Enum, "The sort parameter", "modified-desc", sortParams));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("limit", Parameter.Type.String, "Offset within the result set", "10"));
    getFileByPathEndpoint.addOptionalParameter(new Parameter("offset", Parameter.Type.String, "Number of result items to include", "0"));
    getFileByPathEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getFileByPathEndpoint);

    // GET /{resource}
    Endpoint getFileByURIEndpoint = new Endpoint("/{resource}", Method.GET, "getfile");
    getFileByURIEndpoint.setDescription("Returns the file with the given id");
    getFileByURIEndpoint.addFormat(Format.xml());
    getFileByURIEndpoint.addStatus(ok("the file was found and is returned as part of the response"));
    getFileByURIEndpoint.addStatus(notFound("the file was not found or could not be loaded"));
    getFileByURIEndpoint.addStatus(badRequest("an invalid file identifier was received"));
    getFileByURIEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    getFileByURIEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The resource identifier"));
    getFileByURIEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getFileByURIEndpoint);

    // GET /{page}/referrer
    Endpoint getReferrerByURIEndpoint = new Endpoint("/{resource}/referrer", Method.GET, "getreferrer");
    getReferrerByURIEndpoint.setDescription("Returns pages containing references to the page with the given id");
    getReferrerByURIEndpoint.addFormat(Format.xml());
    getReferrerByURIEndpoint.addStatus(ok("the referring pages were found and are returned as part of the response"));
    getReferrerByURIEndpoint.addStatus(badRequest("an invalid page identifier was received"));
    getReferrerByURIEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    getReferrerByURIEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The resource identifier"));
    getReferrerByURIEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getReferrerByURIEndpoint);

    // GET /{resource}/content/{language}
    Endpoint getFileContentEndpoint = new Endpoint("/{resource}/content/{language}", Method.GET, "getfilecontent");
    getFileContentEndpoint.setDescription("Returns the localized file contents with the given id");
    getFileContentEndpoint.addFormat(Format.xml());
    getFileContentEndpoint.addStatus(ok("the file content was found and is returned as part of the response"));
    getFileContentEndpoint.addStatus(notFound("the file was not found or could not be loaded"));
    getFileContentEndpoint.addStatus(notFound("the file content don't exist in the specified language"));
    getFileContentEndpoint.addStatus(badRequest("an invalid file identifier was received"));
    getFileContentEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    getFileContentEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The file identifier"));
    getFileContentEndpoint.addPathParameter(new Parameter("language", Parameter.Type.String, "The language identifier"));
    getFileContentEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getFileContentEndpoint);

    // GET /pending
    Endpoint getPending = new Endpoint("/pending", Method.GET, "getpending");
    getPending.setDescription("Returns all unmodified resources");
    getPending.addFormat(Format.xml());
    getPending.addStatus(ok("A resultset was compiled and returned as part of the response"));
    getPending.addStatus(serviceUnavailable("The site or its content repository is temporarily offline"));
    getPending.addOptionalParameter(new Parameter("filter", Parameter.Type.String, "Filter for the current result set"));
    getPending.addOptionalParameter(new Parameter("type", Parameter.Type.String, "The file type, e. g. 'image'"));
    getPending.addOptionalParameter(new Parameter("sort", Parameter.Type.Enum, "The sort parameter", "modified-desc", sortParams));
    getPending.addOptionalParameter(new Parameter("limit", Parameter.Type.String, "Offset within the result set", "10"));
    getPending.addOptionalParameter(new Parameter("offset", Parameter.Type.String, "Number of result items to include", "0"));
    getPending.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getPending);

    // POST /
    Endpoint createFileEndpoint = new Endpoint("/", Method.POST, "createfile");
    createFileEndpoint.setDescription("Creates a new file, either at the given path or at a random location and returns the REST url of the created resource.");
    createFileEndpoint.addFormat(Format.xml());
    createFileEndpoint.addStatus(ok("the file was created and the response body contains it's resource url"));
    createFileEndpoint.addStatus(badRequest("the path was invalid"));
    createFileEndpoint.addStatus(conflict("a file already exists at the specified path"));
    createFileEndpoint.addStatus(methodNotAllowed("the site or its content repository is read-only"));
    createFileEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    createFileEndpoint.addOptionalParameter(new Parameter("path", Parameter.Type.String, "The target path"));
    createFileEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, createFileEndpoint);

    // PUT /{resource}
    Endpoint updateFileEndpoint = new Endpoint("/{resource}", Method.PUT, "updatefile");
    updateFileEndpoint.setDescription("Updates the specified file. If the client supplies an If-Match header, the update is processed only if the header value matches the file's ETag");
    updateFileEndpoint.addFormat(Format.xml());
    updateFileEndpoint.addStatus(ok("the file was updated"));
    updateFileEndpoint.addStatus(badRequest("the file content was not specified"));
    updateFileEndpoint.addStatus(badRequest("the file content is malformed"));
    updateFileEndpoint.addStatus(preconditionFailed("the file's etag does not match the value specified in the If-Match header"));
    updateFileEndpoint.addStatus(methodNotAllowed("the site or its content repository is read-only"));
    updateFileEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    updateFileEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The file identifier"));
    updateFileEndpoint.addOptionalParameter(new Parameter("content", Parameter.Type.Text, "The resource data"));
    updateFileEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, updateFileEndpoint);

    // DELETE /{resource}
    Endpoint deleteFileEndpoint = new Endpoint("/{resource}", Method.DELETE, "deletefile");
    deleteFileEndpoint.setDescription("Deletes the specified file.");
    deleteFileEndpoint.addFormat(Format.xml());
    deleteFileEndpoint.addStatus(ok("the file was deleted"));
    deleteFileEndpoint.addStatus(badRequest("the file was not specified"));
    deleteFileEndpoint.addStatus(notFound("the file was not found"));
    deleteFileEndpoint.addStatus(preconditionFailed("the file is still being referenced"));
    deleteFileEndpoint.addStatus(methodNotAllowed("the site or its content repository is read-only"));
    deleteFileEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    deleteFileEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The file identifier"));
    deleteFileEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, deleteFileEndpoint);

    // PUT /{resource}/content/{language}
    Endpoint addFileContentEndpoint = new Endpoint("/{resource}/content/{language}", Method.POST, "addfilecontent");
    addFileContentEndpoint.setDescription("Updates the specified file contents. If the client supplies an If-Match header, the update is processed only if the header value matches the file's ETag");
    addFileContentEndpoint.addFormat(Format.xml());
    addFileContentEndpoint.addStatus(ok("the file content was updated"));
    addFileContentEndpoint.addStatus(badRequest("the file content was not specified"));
    addFileContentEndpoint.addStatus(badRequest("the language does not exist"));
    addFileContentEndpoint.addStatus(badRequest("the file content is malformed"));
    addFileContentEndpoint.addStatus(preconditionFailed("the file's etag does not match the value specified in the If-Match header"));
    addFileContentEndpoint.addStatus(methodNotAllowed("the site or it's content repository is read-only"));
    addFileContentEndpoint.addStatus(serviceUnavailable("the site or it's content repository is temporarily offline"));
    addFileContentEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The file identifier"));
    addFileContentEndpoint.addPathParameter(new Parameter("language", Parameter.Type.String, "The language"));
    addFileContentEndpoint.addBodyParameter(true, null, "the filecontent");
    addFileContentEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, addFileContentEndpoint);

    // DELETE /{resource}/content/{language}
    Endpoint deleteFileContentEndpoint = new Endpoint("/{resource}/content/{language}", Method.DELETE, "deletefilecontent");
    deleteFileContentEndpoint.setDescription("Deletes the specified file content.");
    deleteFileContentEndpoint.addFormat(Format.xml());
    deleteFileContentEndpoint.addStatus(ok("the file content was deleted"));
    deleteFileContentEndpoint.addStatus(badRequest("the file content was not specified"));
    deleteFileContentEndpoint.addStatus(notFound("the file was not found"));
    deleteFileContentEndpoint.addStatus(notFound("the file content was not found"));
    deleteFileContentEndpoint.addStatus(methodNotAllowed("the site or its content repository is read-only"));
    deleteFileContentEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    deleteFileContentEndpoint.addPathParameter(new Parameter("resource", Parameter.Type.String, "The file identifier"));
    deleteFileContentEndpoint.addPathParameter(new Parameter("language", Parameter.Type.String, "The language identifier"));
    deleteFileContentEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, deleteFileContentEndpoint);

    // POST /uploads
    Endpoint uploadFileEndpoint = new Endpoint("/uploads", Method.POST, "uploadfile");
    uploadFileEndpoint.setDescription("Creates a new file as well as content, either at the given path or at a random location and returns the REST url of the created resource.");
    uploadFileEndpoint.addFormat(Format.xml());
    uploadFileEndpoint.addStatus(ok("the file was created and the response body contains it's resource url"));
    uploadFileEndpoint.addStatus(badRequest("the path was not specified"));
    uploadFileEndpoint.addStatus(badRequest("the file content is malformed"));
    uploadFileEndpoint.addStatus(badRequest("the language does not exist"));
    uploadFileEndpoint.addStatus(conflict("a file already exists at the specified path"));
    uploadFileEndpoint.addStatus(methodNotAllowed("the site or its content repository is read-only"));
    uploadFileEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    uploadFileEndpoint.addOptionalParameter(new Parameter("path", Parameter.Type.String, "The target path"));
    uploadFileEndpoint.addOptionalParameter(new Parameter("mimeType", Parameter.Type.String, "The mime type"));
    uploadFileEndpoint.addOptionalParameter(new Parameter("language", Parameter.Type.String, "The language"));
    uploadFileEndpoint.addBodyParameter(true, null, "the file");
    uploadFileEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, uploadFileEndpoint);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

    String endpointUrl = "/system/weblounge/search";
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "search");
    docs.setTitle("Weblounge Search");

    // GET /{searchterms:*}
    Endpoint searchEndpoint = new Endpoint("/{searchterms}", Method.GET, "search");
    searchEndpoint.setDescription("Returns the search result");
    searchEndpoint.addFormat(Format.xml());
    searchEndpoint.addStatus(ok("the search query was executed and the result is returned as part of the response"));
    searchEndpoint.addStatus(badRequest("no search terms have been specified"));
    searchEndpoint.addStatus(error("executing the query resulted in an error"));
    searchEndpoint.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    searchEndpoint.addPathParameter(new Parameter("searchterms", Parameter.Type.String, "The search terms"));
    searchEndpoint.addOptionalParameter(new Parameter("offset", Parameter.Type.String, "Offset within the result set", "-1"));
    searchEndpoint.addOptionalParameter(new Parameter("limit", Parameter.Type.String, "Number of result items to include", "-1"));
    searchEndpoint.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, searchEndpoint);

    this.docs = EndpointDocumentationGenerator.generate(docs);
    return this.docs;
  }
View Full Code Here

  public static String createDocumentation(String endpointUrl) {
    EndpointDocumentation docs = new EndpointDocumentation(endpointUrl, "index");
    docs.setTitle("Weblounge Index");

    // GET /
    Endpoint getStatistics = new Endpoint("/statistics", Method.GET, "getstatistics");
    getStatistics.setDescription("Returns index statistics");
    getStatistics.addFormat(Format.xml());
    getStatistics.addStatus(ok("the index statistics are returned as part of the response"));
    getStatistics.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    getStatistics.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getStatistics);

    // DELETE /{page}/unlock
    Endpoint reindex = new Endpoint("/", Method.DELETE, "reindex");
    reindex.setDescription("Triggers an index operation and returns immediately");
    reindex.addFormat(Format.xml());
    reindex.addStatus(ok("the index operation was started"));
    reindex.addStatus(preconditionFailed("the content repository is read only"));
    reindex.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    reindex.addStatus(conflict("the index is already being rebuilt"));
    reindex.addStatus(forbidden("the current user does not have the rights to rebuild the index"));
    reindex.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, reindex);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

    docs.setTitle("Weblounge Previews");

    String[] versions = { "0", "1" };

    // GET /{resource}/locales/{language}/styles/{styleid}
    Endpoint getScaleLocalizedImage = new Endpoint("/{resource}/locales/{language}/styles/{style}", Method.GET, "localizedstyledimage");
    getScaleLocalizedImage.setDescription("Returns a scaled version of the resource with the given identifier and language");
    getScaleLocalizedImage.addFormat(new Format("xml", null, null));
    getScaleLocalizedImage.addStatus(ok("the resource was scaled using the specified image style and is returned as part of the response"));
    getScaleLocalizedImage.addStatus(notFound("the resource was not found or could not be loaded"));
    getScaleLocalizedImage.addStatus(notFound("the resource does not exist in the specified language"));
    getScaleLocalizedImage.addStatus(badRequest("an invalid image or image style identifier was received"));
    getScaleLocalizedImage.addStatus(badRequest("an invalid language identifier was specified"));
    getScaleLocalizedImage.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    getScaleLocalizedImage.addPathParameter(new Parameter("resource", Parameter.Type.String, "The resource identifier"));
    getScaleLocalizedImage.addPathParameter(new Parameter("language", Parameter.Type.String, "The language identifier"));
    getScaleLocalizedImage.addPathParameter(new Parameter("style", Parameter.Type.String, "The image style identifier"));
    getScaleLocalizedImage.addOptionalParameter(new Parameter("version", Parameter.Type.String, "The version", "0", versions));
    getScaleLocalizedImage.addOptionalParameter(new Parameter("force", Parameter.Type.Boolean, "Force the creation if not available"));
    getScaleLocalizedImage.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getScaleLocalizedImage);

    // DELETE /
    Endpoint removeAll = new Endpoint("/", Method.DELETE, "deleteAll");
    removeAll.setDescription("Deletes all previews of this site");
    removeAll.addStatus(ok("the preview images were removed"));
    removeAll.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    removeAll.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, removeAll);

    // DELETE /{resource}}
    Endpoint removeByResource = new Endpoint("/{resource}", Method.DELETE, "delete");
    removeByResource.setDescription("Deletes all previews of the resource with the given identifier");
    removeByResource.addStatus(ok("the preview images were removed"));
    removeByResource.addStatus(notFound("the resource was not found or could not be loaded"));
    removeByResource.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    removeByResource.addPathParameter(new Parameter("resource", Parameter.Type.String, "The resource identifier"));
    removeByResource.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, removeByResource);

    // DELETE /styles/{styleid}
    Endpoint removeByStyle = new Endpoint("/styles/{style}", Method.DELETE, "deletebystyle");
    removeByStyle.setDescription("Deletes the previews for the given style");
    removeByStyle.addStatus(ok("the preview images were removed"));
    removeByStyle.addStatus(notFound("the resource was not found or could not be loaded"));
    removeByStyle.addStatus(notFound("the resource does not exist in the specified language"));
    removeByStyle.addStatus(badRequest("an invalid image or image style identifier was received"));
    removeByStyle.addStatus(serviceUnavailable("the site or its content repository is temporarily offline"));
    removeByStyle.addPathParameter(new Parameter("style", Parameter.Type.String, "The image style identifier"));
    removeByStyle.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, removeByStyle);

    // GET /styles
    Endpoint getImageStyles = new Endpoint("/styles", Method.GET, "getstyles");
    getImageStyles.setDescription("Returns the image style");
    getImageStyles.addFormat(Format.xml());
    getImageStyles.addStatus(ok("the image styles are returned as part of the response"));
    getImageStyles.addStatus(serviceUnavailable("the site is temporarily offline"));
    getImageStyles.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getImageStyles);

    // GET /styles/{styleid}
    Endpoint getImageStyle = new Endpoint("/styles/{style}", Method.GET, "getstyle");
    getImageStyle.setDescription("Returns the image style");
    getImageStyle.addFormat(Format.xml());
    getImageStyle.addStatus(ok("the image style was found and is returned as part of the response"));
    getImageStyle.addStatus(notFound("the image style was not found"));
    getImageStyle.addStatus(badRequest("an invalid image style identifier was received"));
    getImageStyle.addStatus(serviceUnavailable("the site is temporarily offline"));
    getImageStyle.addPathParameter(new Parameter("style", Parameter.Type.String, "The image style identifier"));
    getImageStyle.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.READ, getImageStyle);

    // POST /
    Endpoint createPreviews = new Endpoint("/", Method.POST, "createpreviews");
    createPreviews.setDescription("Creates the missing preview images");
    createPreviews.addFormat(Format.xml());
    createPreviews.addStatus(ok("the creation of preview images has been started"));
    createPreviews.addStatus(serviceUnavailable("the site is temporarily offline"));
    createPreviews.setTestForm(new TestForm());
    docs.addEndpoint(Endpoint.Type.WRITE, createPreviews);

    return EndpointDocumentationGenerator.generate(docs);
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.impl.util.doc.Endpoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.