Package org.apache.shindig.gadgets.uri.JsUriManager

Examples of org.apache.shindig.gadgets.uri.JsUriManager.JsUri


  public GadgetsHandlerApi.JsResponse getJs(GadgetsHandlerApi.JsRequest request)
      throws ProcessingException {
    verifyBaseParams(request, false);
    Set<String> fields = beanFilter.processBeanFields(request.getFields());

    JsUri jsUri = createJsUri(request);
    Uri servedUri = jsUriManager.makeExternJsUri(jsUri);

    String content = null;
    Long expireMs = null;
    if (isFieldIncluded(fields, "jsContent")) {
View Full Code Here


    (request.getContext() != null ?
        // TODO: Figure out why maven complain about casting and clean the dummy cast
        (Object) beanDelegator.convertEnum(request.getContext())
        : RenderingContext.GADGET);

    return new JsUri(request.getRefresh(), request.getDebug(), request.getIgnoreCache(),
        request.getContainer(), request.getGadget(), request.getFeatures(),
        request.getLoadedFeatures(), request.getOnload(), false, false, context, request.getUrl(),
        request.getRepository());
  }
View Full Code Here

      Gadget gadget, Node headTag, Node firstHeadChild, String extraContent)
      throws GadgetException {

    GadgetContext context = gadget.getContext();
    // Gadget is not specified in request in order to support better caching
    JsUri jsUri = new JsUri(null, context.getDebug(), false, context.getContainer(), null,
        libs, loaded, null, false, false, RenderingContext.getDefault(), null,
        getFeatureRepositoryId(gadget));
    jsUri.setCajoleContent(gadget.requiresCaja());

    String content = "";
    if (!inline) {
      String jsUrl = new UriBuilder(jsUriManager.makeExternJsUri(jsUri))
          // Avoid jsload by adding jsload=0
View Full Code Here

    Capture<JsUri> uriCapture = new Capture<JsUri>();
    expect(jsUriManager.makeExternJsUri(capture(uriCapture))).andReturn(resUri);
    replay();

    GadgetsHandlerApi.JsResponse response = gadgetHandler.getJs(request);
    JsUri expectedUri = new JsUri(null, false, false, CONTAINER, null, features, null, null, false,
            false, RenderingContext.GADGET, null, null);
    assertEquals(expectedUri, uriCapture.getValue());
    assertEquals(resUri, response.getJsUrl());
    assertNull(response.getJsContent());
    assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
View Full Code Here

    expect(request.getOnload()).andStubReturn(onload);
    expect(request.getContext()).andStubReturn(GadgetsHandlerApi.RenderingContext.CONTAINER);
    replay();

    GadgetsHandlerApi.JsResponse response = gadgetHandler.getJs(request);
    JsUri expectedUri = new JsUri(null, false, false, CONTAINER, FakeProcessor.SPEC_URL.toString(),
            features, null, onload, false, false, RenderingContext.CONTAINER, null, repository);
    assertEquals(expectedUri, uriCapture.getValue());
    assertNull(response.getJsUrl());
    assertEquals(jsContent, response.getJsContent());
    assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
View Full Code Here

    RpcHandler operation = registry.getRpcHandler(request);
    Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
    JSONObject results = new JSONObject(converter.convertToString(responseObj));
    assertEquals(jsUri.toString(), results.getString("jsUrl"));
    JsUri expectedUri = new JsUri(null, false, false, CONTAINER, GADGET1_URL, features, null, null,
            false, false, RenderingContext.GADGET, null, null);
    assertEquals(expectedUri, captureUri.getValue());
    assertFalse(results.has("error"));
    assertFalse(results.has("jsContent"));
    verify();
View Full Code Here

    RpcHandler operation = registry.getRpcHandler(request);
    Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
    JSONObject results = new JSONObject(converter.convertToString(responseObj));
    assertEquals(jsUri.toString(), results.getString("jsUrl"));
    JsUri expectedUri = new JsUri(123, true, true, CONTAINER, GADGET1_URL, features,
            loadedFeatures, onload, false, false, RenderingContext.CONTAINER, null, repository);
    assertEquals(expectedUri, captureUri.getValue());
    assertFalse(results.has("error"));
    assertEquals(jsContent, results.getString("jsContent"));
    verify();
View Full Code Here

    JsResponse result = builder.build();
    return result;
  }

  public Iterable<JsContent> getJsContent(JsUri jsUri, FeatureBundle bundle) {
    jsUri = new JsUri(jsUri) {
      @Override
      public boolean isDebug() {
        // Force debug JS in the raw JS content retrieved.
        return true;
      }
View Full Code Here

    }
  }

  public boolean process(JsRequest request, JsResponseBuilder builder) throws JsException {
    // Get JavaScript content from features aliases request.
    JsUri jsUri = request.getJsUri();
    GadgetContext ctx = new JsGadgetContext(jsUri);

    FeatureRegistry registry;
    try {
      registry = registryProvider.get(jsUri.getRepository());
    } catch (GadgetException e) {
      throw new JsException(e.getHttpStatusCode(), e.getMessage());
    }

    // TODO: possibly warn on unknown/unrecognized libs.
    List<FeatureBundle> requestedBundles = registry.getFeatureResources(
        ctx, jsUri.getLibs(), null).getBundles();
    List<FeatureBundle> loadedBundles = registry.getFeatureResources(
        ctx, jsUri.getLoadedLibs(), null).getBundles();

    Set<String> loadedFeatures = Sets.newHashSet();
    for (FeatureBundle bundle : loadedBundles) {
      loadedFeatures.add(bundle.getName());
      builder.appendExterns(bundle.getApis(ApiDirective.Type.JS, true));
      builder.appendExterns(bundle.getApis(ApiDirective.Type.JS, false));
    }

    // Collate all JS desired for the current request.
    boolean isProxyCacheable = true;

    for (FeatureBundle bundle : requestedBundles) {
      // Exclude all transitively-dependent loaded features.
      if (loadedFeatures.contains(bundle.getName())) {
        continue;
      }
      builder.appendAllJs(compiler.getJsContent(jsUri, bundle));
      for (FeatureResource featureResource : bundle.getResources()) {
        isProxyCacheable = isProxyCacheable && featureResource.isProxyCacheable();
      }
    }

    builder.setProxyCacheable(isProxyCacheable);
    UriStatus uriStatus = jsUri.getStatus();
    setResponseCacheTtl(builder, uriStatus != null ? uriStatus : UriStatus.VALID_UNVERSIONED);
    return true;
  }
View Full Code Here

    JsResponse result = builder.build();
    return result;
  }

  public Iterable<JsContent> getJsContent(JsUri jsUri, FeatureBundle bundle) {
    jsUri = new JsUri(jsUri) {
      @Override
      public boolean isDebug() {
        // Force debug JS in the raw JS content retrieved.
        return true;
      }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.uri.JsUriManager.JsUri

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.