Package org.apache.wookie.beans

Examples of org.apache.wookie.beans.IWidget


        if ((apiKey != null) && (userId != null) && (sharedDataKey != null) && (widgetGuid != null))
        {
            try
            {
                // find widget by GUID
                IWidget widget = findWidgetByGuid(widgetGuid);
                if (widget != null)
                {
                    // get matching widget instance for widget
                    Map<String, Object> values = new HashMap<String, Object>();
                    values.put("apiKey", apiKey);
View Full Code Here


  private static IWidgetInstance INSTANCE_NO_USER_ID;
  private static Messages BUNDLE;
 
  @BeforeClass
  public static void setUp(){
    IWidget widget = new WidgetImpl();
    widget.setIdentifier("http://getwookie.org/test");
    IContent startFile = new StartFileImpl();
        startFile.setSrc("http://getwookie.org/test/index.html");
        startFile.setLang("en");
    widget.getContentList().add(startFile);
   
    INSTANCE = new WidgetInstanceImpl();
    INSTANCE.setWidget(widget);
    INSTANCE.setIdKey("xhKEoiff/4ltxSuuBmPjjxBx5hw.eq.");
    INSTANCE.setUserId("scott");
View Full Code Here

   
    return xml;
  }
 
  public static String toJson(IWidgetInstance instance, String url, String locale, boolean useDefaultSizes) {
    IWidget widget = instance.getWidget();
   
    String width = null;
    String height = null;
   
    if (useDefaultSizes){
      width = String.valueOf(IW3CXMLConfiguration.DEFAULT_WIDTH_LARGE);
      height = String.valueOf(IW3CXMLConfiguration.DEFAULT_HEIGHT_LARGE);
    }
    if (widget.getWidth() != null && widget.getWidth() > 0)
      width = widget.getWidth().toString();
    if (widget.getHeight() != null && widget.getHeight() > 0)
      height = widget.getHeight().toString();
    JSONObject json = new JSONObject();
    try {
      json.put("url", url);
      json.put("identifier", instance.getIdKey());
      json.put("title", widget.getLocalName(locale));
      if (height != null) json.put("height", height);
      if (width != null) json.put("width", width);
    } catch (JSONException e) {
      logger.error("Problem rendering instance using JSON",e);
    }
View Full Code Here

      for(Policy policy: policies){
        JSONObject policyJson = new JSONObject();
        policyJson.put("scope", policy.getScope());
        if (!policy.getScope().equals("*")){
          IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
          IWidget widget = persistenceManager.findWidgetByGuid(policy.getScope());
          if (widget != null){
            policyJson.put("widget-title", WidgetAdvertHelper.getEncodedWidgetTitle(widget, null));
          }
        }
        policyJson.put("origin", policy.getOrigin());
View Full Code Here

    if (localized == null) {

      //
      // Get the Widget this resource request is related to
      //
      IWidget widget = getWidgetFromRequest(request);

      //
      // Only if we have a valid instance and a resource which has no
      // localization parameter do we start the locale algorithm
      //
View Full Code Here

   * @param widgetId
   * @return a new WidgetInstance, or null if the instance cannot be created
   */
  public IWidgetInstance newInstance(String apiKey, String userId, String sharedDataKey, String serviceType, String widgetId, String lang){
    try {
      IWidget widget = null;
      IWidgetInstance widgetInstance;
      // Widget ID or Widget Type?
          IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      if (widgetId != null){
        widget = persistenceManager.findWidgetByGuid(widgetId);
View Full Code Here

    String cloneSharedDataKey = request.getParameter("cloneshareddatakey");
    if (sharedDataKey == null || sharedDataKey.trim().equals("") || cloneSharedDataKey == null || cloneSharedDataKey.trim().equals("")){//$NON-NLS-1$ //$NON-NLS-2$
      throw new InvalidParametersException();
    }
    String cloneKey = SharedDataHelper.getInternalSharedDataKey(instance, cloneSharedDataKey);
        IWidget widget = instance.getWidget();
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    for (ISharedData sharedData : new SharedContext(instance).getSharedData())
    {
        ISharedData clone = persistenceManager.newInstance(ISharedData.class);
            clone.setDkey(sharedData.getDkey());
View Full Code Here

      HttpServletResponse response) throws ResourceNotFoundException,
      UnauthorizedAccessException, IOException {
    // attempt to get specific widget by id; note that this is the internal
    // widget integer ID and not the widget URI
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
    if (widget == null) throw new ResourceNotFoundException();
    // redirect to the UDD
    if (widget.getUpdateLocation() ==  null) throw new ResourceNotFoundException();
    response.sendRedirect(widget.getUpdateLocation());
  }
View Full Code Here

  protected void update(String resourceId, HttpServletRequest request, HttpServletResponse response)
      throws ResourceNotFoundException, InvalidParametersException,
      UnauthorizedAccessException {
      // attempt to get specific widget by id
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
      if (widget == null) throw new ResourceNotFoundException();
     
      // Check to see if we're requiring updates over HTTPS - if not output a warning
      boolean onlyUseHttps = Boolean.parseBoolean(request.getParameter("use-https"));
      if (!onlyUseHttps) _logger.warn("checking for updates using non-secure method");
View Full Code Here

    if(widgetInstance==null) return map;
   
    // Get i18n-enabled metadata for the Widget's locale and encode it using unicode control characters.
   
    String locales[] = {widgetInstance.getLang()};
    IWidget widget = widgetInstance.getWidget();
     
    String author = "";
        String email = "";
        String href = "";
    if (widget.getAuthor() != null){
            if (widget.getAuthor().getAuthorName() != null) author = WidgetFormattingUtils.getEncoded(widget.getAuthor().getDir(), widget.getAuthor().getAuthorName());
          if (widget.getAuthor().getEmail() != null) email = widget.getAuthor().getEmail();
          if (widget.getAuthor().getHref() != null) href = widget.getAuthor().getHref();
    }

    String name = "";
    IName iname = (IName)LocalizationUtils.getLocalizedElement(widget.getNames().toArray(new IName[widget.getNames().size()]), locales, widget.getDefaultLocale());
    if (iname != null && iname.getName() != null) name = WidgetFormattingUtils.getEncoded(iname.getDir(), iname.getName());
    String shortName = "";
    if (iname != null && iname.getShort() != null) shortName = WidgetFormattingUtils.getEncoded(iname.getDir(), iname.getShort());
   
    String description = "";
    IDescription idescription = (IDescription)LocalizationUtils.getLocalizedElement(widget.getDescriptions().toArray(new IDescription[widget.getDescriptions().size()]), locales, widget.getDefaultLocale());
    if (idescription != null && idescription.getDescription() != null) description = WidgetFormattingUtils.getEncoded(idescription.getDir(), idescription.getDescription());
   
    String version = "";
    if (widget.getVersion() != null) version = WidgetFormattingUtils.getEncoded(widget.getDir(), widget.getVersion());
   
    String width = "0";
    if (widget.getWidth() != null) width = String.valueOf(widget.getWidth());
   
    String height = "0";
    if (widget.getHeight() != null) height = String.valueOf(widget.getHeight());
   
    // Add in metadata

    map.put("id", String.valueOf(widget.getIdentifier()))//$NON-NLS-1$
    map.put("author", author)//$NON-NLS-1$
    map.put("authorEmail", email);//$NON-NLS-1$
    map.put("authorHref", href);//$NON-NLS-1$
    map.put("name", name);//$NON-NLS-1$
    map.put("description", description);//$NON-NLS-1$ 
View Full Code Here

TOP

Related Classes of org.apache.wookie.beans.IWidget

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.