Package org.restlet.routing

Examples of org.restlet.routing.Router


            this.context = getContext();
        }
       
        @Override
        public Restlet createInboundRoot() {
            Router baseRouter = new Router(context);
            baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
            for (org.flowforwarding.warp.jcontroller.restapi.RestletRoutable rr : restlets) {
                baseRouter.attach(rr.basePath(), rr.getRestlet(context));
            }

            Filter slashFilter = new Filter() {           
                @Override
                protected int beforeHandle(Request request, Response response) {
View Full Code Here


          attributes.put("observerTask", observerTask);
       if (controllerRef != null)
          attributes.put("controllerRef", controllerRef);
             
       context.setAttributes(attributes);
       Router router = new Router(context);
       router.attach("/restapi", RootRestApiResource.class);
       return router;
   }
View Full Code Here

  /**
   * Creates a root Restlet that will receive all incoming calls.
   */
  @Override
  public synchronized Restlet createInboundRoot() {
    Router router = new Router(getContext());
    router.attachDefault(DefaultResource.class);
    ModelerServicesInit.attachResources(router);
    DiagramServicesInit.attachResources(router);
    JsonpFilter jsonpFilter = new JsonpFilter(getContext());
    jsonpFilter.setNext(router);
    return jsonpFilter;
View Full Code Here

    configuration = new Configuration();   
    configuration.setTemplateLoader(new ContextTemplateLoader(context, "clap://class/templates"));
    configuration.setDateFormat(config.getDateFormat());

    // map the routes
    Router router = new Router(context);
   
    // map the local repository folders
    for (String folder : config.getLocalRepositories()) {
      attachMaven2(context, router, folder);
      attachBrowsing(context, router, folder);
    }

    // map the remote repository folders
    for (RemoteRepository repository : config.getRemoteRepositories()) {
      attachMaven2(context, router, repository.id);
      attachBrowsing(context, router, repository.id);
    }

    // Search artifacts
    router.attach("/search", SearchResource.class);

    // Recent artifacts
    router.attach("/recent/{repository}", RecentResource.class);
    router.attach("/recent", RecentResource.class);

    // Atom artifacts feed
    router.attach("/atom/{repository}", AtomResource.class);
    router.attach("/atom", AtomResource.class);
   
    // Root
    router.attach("/", RootResource.class);
    router.attach("", RootResource.class);

    // static resources
    Directory dir = new Directory(context, "clap://class");
    dir.setListingAllowed(true);
    dir.setDeeplyAccessible(true);
    router.attach("/", dir);

    if (config.getProxyPort() > 0) {
      getLogger().info(MessageFormat.format(Constants.MESSAGE_STARTUP, "PROXY", config.getProxyPort()));
    }
    getLogger().info(MessageFormat.format("Moxie root is {0}", config.getMoxieRoot()));
View Full Code Here

  private RestServer(Context context) {
    super(context);
  }

  public synchronized Restlet createInboundRoot() {
    Router router = new Router(getContext());

    // *** MCCs ***
    router.attach("/mcc", MccRest.class); //LIST All


    // *** Accounts ***
    router.attach("/mcc/{topAccountId}/accounts", AccountRest.class); //LIST All

   
    // *** Kratu ***
    // ?includeZeroImpressions=false by default
    router.attach("/mcc/{topAccountId}/kratu", KratuRest.class); // List All
    router.attach("/mcc/{topAccountId}/kratu/{accountId}", KratuRest.class); // LIST Account level

    // Genereate Kratus MCC level
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/generatekratus", GenerateKratusRest.class);

   
    // *** Reporting ***
    // Generate
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/generatereports", GenerateReportsRest.class);

    // Accounts
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/reportaccount", ReportAccountRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportaccount/{accountId}", ReportAccountRest.class); //LIST Account level
   
    // Campaigns
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/reportcampaign", ReportCampaignRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportcampaign/{accountId}", ReportCampaignRest.class); //LIST Account level
    router.attach("/mcc/{topAccountId}/reportcampaign/campaign/{campaignId}", ReportCampaignRest.class); //LIST Campaign level

    // AdGroups
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/reportadgroup", ReportAdGroupRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportadgroup/{accountId}", ReportAdGroupRest.class); //LIST Account level
    router.attach("/mcc/{topAccountId}/reportadgroup/campaign/{campaignId}", ReportAdGroupRest.class); //LIST Campaign level
    router.attach("/mcc/{topAccountId}/reportadgroup/adgroup/{adGroupId}", ReportAdGroupRest.class); //LIST AdGroup level

    // Ads
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/reportad", ReportAdRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportad/{accountId}", ReportAdRest.class); //LIST Account level
    router.attach("/mcc/{topAccountId}/reportad/campaign/{campaignId}", ReportAdRest.class); //LIST Campaign level
    router.attach("/mcc/{topAccountId}/reportad/adgroup/{adGroupId}", ReportAdRest.class); //LIST AdGroup level
    router.attach("/mcc/{topAccountId}/reportad/ad/{adId}", ReportAdRest.class); //LIST Ad level

    // Keywords
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/reportkeyword", ReportKeywordRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportkeyword/{accountId}", ReportKeywordRest.class); //LIST Account level
    router.attach("/mcc/{topAccountId}/reportkeyword/campaign/{campaignId}", ReportKeywordRest.class); //LIST Campaign level
    router.attach("/mcc/{topAccountId}/reportkeyword/adgroup/{adGroupId}", ReportKeywordRest.class); //LIST AdGroup level
    router.attach("/mcc/{topAccountId}/reportkeyword/keyword/{criterionId}", ReportKeywordRest.class); //LIST Keyword level

    // ReportCampaignNegativeKeyword
    // This one does not support dateStart and dateEnd
    router.attach("/mcc/{topAccountId}/reportcampaignnegativekeyword", ReportCampaignNegativeKeywordRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportcampaignnegativekeyword/{accountId}", ReportCampaignNegativeKeywordRest.class); //LIST Account level
    router.attach("/mcc/{topAccountId}/reportcampaignnegativekeyword/campaign/{campaignId}", ReportCampaignNegativeKeywordRest.class); //LIST Campaign level
    router.attach("/mcc/{topAccountId}/reportcampaignnegativekeyword/keyword/{criterionId}", ReportCampaignNegativeKeywordRest.class); //LIST Keyword level

    // ReportAdExtension
    // ?dateStart=yyyyMMdd&dateEnd=yyyyMMdd
    router.attach("/mcc/{topAccountId}/reportadextension", ReportAdExtensionRest.class); //LIST All
    router.attach("/mcc/{topAccountId}/reportadextension/{accountId}", ReportAdExtensionRest.class); //LIST Account level
    router.attach("/mcc/{topAccountId}/reportadextension/campaign/{campaignId}", ReportAdExtensionRest.class); //LIST Campaign level
    router.attach("/mcc/{topAccountId}/reportadextension/adextension/{adExtensionId}", ReportAdExtensionRest.class); //LIST Keyword level


    router.attach("/html2pdf", HtmlToPdfRest.class);


    // *** Static files ***
    // USING FILE
    String target = "index.html";
    Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_CLIENT_FOUND);
    router.attach("/", redirector);
    File currentPath = new File(RestServer.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    String htmlPath = "file:///" + currentPath.getParent() + "/html/";
    router.attach("/", redirector);
    router.attach("", new Directory(getContext(), htmlPath));

    return router;
  }
View Full Code Here

TOP

Related Classes of org.restlet.routing.Router

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.