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

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


      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


  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

    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

    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

  }

  private JsUri mockJsUri(String container, RenderingContext context, boolean debug,
      boolean jsload, boolean nocache, String onload, int refresh, UriStatus status,
      String... libs) {
    JsUri result = mock(JsUri.class);
    expect(result.getContainer()).andReturn(container).anyTimes();
    expect(result.getContext()).andReturn(context).anyTimes();
    expect(result.getOnload()).andReturn(onload).anyTimes();
    expect(result.getRefresh()).andReturn(refresh).anyTimes();
    expect(result.isDebug()).andReturn(debug).anyTimes();
    expect(result.isNoCache()).andReturn(nocache).anyTimes();
    expect(result.isJsload()).andReturn(jsload).anyTimes();
    expect(result.getStatus()).andReturn(status).anyTimes();
    if (libs != null) {
      expect(result.getLibs()).andReturn(Lists.newArrayList(libs)).anyTimes();
    }
    return result;
  }
View Full Code Here

  }

  @Test
  public void testWithIfModifiedSinceHeaderPresentAndVersionReturnsNotModified() throws Exception {
    setUp(0);
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, false, false, false,
        null, REFRESH_INTERVAL_SEC, UriStatus.VALID_VERSIONED);
    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    expect(request.getHeader("If-Modified-Since")).andReturn("12345");
    replay();
View Full Code Here

    replay(result);
    return result;
  }

  private JsUri mockJsUri(boolean debug) {
    JsUri result = createMock(JsUri.class);
    expect(result.isDebug()).andReturn(debug).anyTimes();
    expect(result.getCompileMode()).andReturn(JsCompileMode.CONCAT_COMPILE_EXPORT_ALL).anyTimes();
    expect(result.getStatus()).andReturn(UriStatus.VALID_UNVERSIONED).anyTimes();
    expect(result.getContainer()).andReturn("container").anyTimes();
    expect(result.getContext()).andReturn(RenderingContext.CONFIGURED_GADGET).anyTimes();
    expect(result.getRefresh()).andReturn(1000).anyTimes();
    expect(result.isNoCache()).andReturn(false).anyTimes();
    expect(result.getGadget()).andReturn("http://foo.com/g.xml").anyTimes();
    expect(result.getLibs()).andReturn(ImmutableList.<String>of()).anyTimes();
    expect(result.getLoadedLibs()).andReturn(ImmutableList.<String>of()).anyTimes();
    expect(result.getOnload()).andReturn("foo").anyTimes();
    expect(result.isJsload()).andReturn(true).anyTimes();
    expect(result.isNohint()).andReturn(true).anyTimes();
    expect(result.getOrigUri()).andReturn(null).anyTimes();
    expect(result.getRepository()).andReturn(null).anyTimes();
    expect(result.getExtensionParams()).andReturn(null).anyTimes();
    replay(result);
    return result;
  }
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.