Package org.opensocial.explorer.specserver.api

Examples of org.opensocial.explorer.specserver.api.GadgetResource


    GadgetSpec mockSpec = createMock(GadgetSpec.class);
    Map<String, GadgetResource> cssResources = Maps.newLinkedHashMap();

    String resourceContent = "The quick brown fox jumps over the lazy dog";
    GadgetResource mockResource = createMock(GadgetResource.class);
    expect(mockResource.getName()).andReturn("foo.css");
    expect(mockResource.getContent()).andReturn(resourceContent);
    expect(mockResource.getContentType()).andReturn("text/css");

    GadgetResource mockResource2 = createMock(GadgetResource.class);
    expect(mockResource2.getName()).andStubReturn("bar.css");

    cssResources.put("bar.css", mockResource2);
    cssResources.put("foo.css", mockResource);
    expect(mockSpec.getCssResources()).andReturn(cssResources);
View Full Code Here


    Map<String, GadgetResource> jsResources, htmlResources, cssResources;
    jsResources = Maps.newLinkedHashMap();
    htmlResources = Maps.newLinkedHashMap();
    cssResources = Maps.newLinkedHashMap();

    GadgetResource jsResource = createMock(GadgetResource.class);
    expect(jsResource.getName()).andReturn("foo.js");
    jsResources.put("foo.js", jsResource);

    GadgetResource htmlResource = createMock(GadgetResource.class);
    expect(htmlResource.getName()).andReturn("bar.html");
    htmlResources.put("bar.html", htmlResource);

    GadgetResource cssResource = createMock(GadgetResource.class);
    expect(cssResource.getName()).andReturn("baz.css");
    cssResources.put("baz.css", cssResource);

    GadgetResource xmlResource = createMock(GadgetResource.class);
    expect(xmlResource.getName()).andReturn("gadget.xml").atLeastOnce();

    expect(mockSpec.getJsResources()).andReturn(jsResources);
    expect(mockSpec.getHtmlResources()).andReturn(htmlResources);
    expect(mockSpec.getCssResources()).andReturn(cssResources);
    expect(mockSpec.getGadgetResource()).andReturn(xmlResource).atLeastOnce();
View Full Code Here

    JSONArray html = json.getJSONArray(HTML_RESOURCES);
    htmlResources = TempGadgetResource.parse(html);

    JSONObject gadget = json.getJSONObject(GADGET_RESOURCE);
    GadgetResource gadgetResource = TempGadgetResource.parse(gadget);
   
    if(json.has(EE_RESOURCE)) {
      JSONObject ee = json.getJSONObject(EE_RESOURCE);
      GadgetResource eeResource = TempGadgetResource.parse(ee);
      return new TempGadgetSpec(title, gadgetResource, cssResources, jsResources, htmlResources, eeResource);
    } else {
      return new TempGadgetSpec(title, gadgetResource, cssResources, jsResources, htmlResources);
    }
  }
View Full Code Here

    assertEquals(false, spec.isDefault());
   
    assertNotNull(spec.getGadgetResource());
    assertEquals("GadgetContent", spec.getGadgetResource().getContent());
   
    GadgetResource eeResource = spec.getEEResource();
    assertNotNull(eeResource);
   
    Map<String, GadgetResource> cssResources = spec.getCssResources();
    Map<String, GadgetResource> htmlResources = spec.getHtmlResources();
    Map<String, GadgetResource> jsResources = spec.getJsResources();
View Full Code Here

  public static Map<String, GadgetResource> parse(JSONArray json) throws JSONException {
    Map<String, GadgetResource> resourceMap = Maps.newHashMap();
    Iterator itr = json.iterator();
    Object obj;
    GadgetResource resource;
    while (itr.hasNext()) {
      obj = itr.next();
      if (obj instanceof JSONObject) {
        resource = parse((JSONObject) obj);
        resourceMap.put(resource.getContent(), resource);
      }
    }
    return resourceMap;
  }
View Full Code Here

    }

    // Check to see if resources are being requested through this servlet
    if (paths.length > 1) {
      String resourceName = paths[1];
      GadgetResource resource = findResource(spec, resourceName);
      if (resource != null) {
        returnResource(resource, resp);
      } else {
        // 404 - Not Found
        resp.sendError(HttpServletResponse.SC_NOT_FOUND, resourceName + " was not found");
View Full Code Here

      return null;
    }

    Iterator<Entry<String, GadgetResource>> itr = resources.entrySet().iterator();
    Entry<String, GadgetResource> entry;
    GadgetResource resource = null;
    while (itr.hasNext()) {
      entry = itr.next();
      resource = entry.getValue();
      if (resource.getName().equals(resourceName)) {
        break;
      }
    }
    return resource;
  }
View Full Code Here

TOP

Related Classes of org.opensocial.explorer.specserver.api.GadgetResource

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.