Examples of IPersistenceManager


Examples of org.apache.wookie.beans.util.IPersistenceManager

  }
 
  public synchronized static void lockWidgetInstance(IWidgetInstance instance){
    new SharedContext(instance).updateSharedData("isLocked", "true", false); //$NON-NLS-1$ //$NON-NLS-2$
    instance.setLocked(true);
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    persistenceManager.save(instance);
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

  }

  public synchronized static void unlockWidgetInstance(IWidgetInstance instance){
    new SharedContext(instance).updateSharedData("isLocked", "false", false); //$NON-NLS-1$ //$NON-NLS-2$
    instance.setLocked(false);
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    persistenceManager.save(instance);
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

      if (
          (locale == null && instance.getLang()!=null) ||
          (locale != null && instance.getLang()==null) ||          
          (locale != null && !instance.getLang().equals(locale))
      ){
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        instance.setLang(locale);
        persistenceManager.save(instance);
      }
    }
    return instance;
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

   * @param request
   * @return
   */
  public static IWidgetInstance findWidgetInstance(HttpServletRequest request){
    IWidgetInstance instance;
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();

    // Try using the id_key parameter
    String id_key = request.getParameter("id_key"); //$NON-NLS-1$
    if (id_key != null & id_key != ""){
      instance = persistenceManager.findWidgetInstanceByIdKey(id_key);
      return instance;
    }
   
    // Try using the resource part of the path as an id key e.g. widgetinstances/xyz
    id_key = getResourceId(request);
    if (id_key != null & id_key != ""){
      instance = persistenceManager.findWidgetInstanceByIdKey(id_key);
      return instance;
    }

    //
    // If all else fails, try using instance parameters
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

   * @return the widget instance, or null if there is no matching instance
   * @throws UnsupportedEncodingException
   */
  public static IWidgetInstance findWidgetInstance(String apiKey, String userId, String sharedDataKey, String widgetId, String serviceType) throws UnsupportedEncodingException{
    IWidgetInstance instance;
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    if (widgetId != null){
      widgetId = URLDecoder.decode(widgetId, "UTF-8"); //$NON-NLS-1$
      _logger.debug("Looking for widget instance with widgetid of " + widgetId);
      instance = persistenceManager.findWidgetInstanceByGuid(apiKey, userId, sharedDataKey, widgetId);
    } else {
      _logger.debug("Looking for widget instance of service type " + serviceType);
      instance = persistenceManager.findWidgetInstance(apiKey, userId, sharedDataKey, serviceType);
    }
    return instance;
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

   */
  public static boolean revokeKey(String value){
    if (value == null) return false;
    if (value.trim().equals("")) return false;
    value = value.trim();
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IApiKey[] key = persistenceManager.findByValue(IApiKey.class, "value", value);
    if (key == null || key.length !=1) return false;
    return revokeKey(persistenceManager, key[0]);
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

   * @throws EmailException if there is a problem sending the email notification about this key
   * @throws SystemUnavailableException if there is a problem generating the key
   */
  public static void createKey(HttpServletRequest request, String email, Messages localizedMessages) throws SystemUnavailableException, EmailException {
     
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IApiKey key = persistenceManager.newInstance(IApiKey.class);
    key.setEmail(email);

    // generate a nonce
    RandomGUID r = new RandomGUID();
    String nonce = "nonce-" + r.toString();         //$NON-NLS-1$

    // now use SHA hash on the nonce       
    String hashKey = HashGenerator.getInstance().encrypt(nonce+email)

    // get rid of any chars that might upset a url...
    hashKey = hashKey.replaceAll("=", ".eq."); //$NON-NLS-1$ //$NON-NLS-2$
    hashKey = hashKey.replaceAll("\\?", ".qu."); //$NON-NLS-1$ //$NON-NLS-2$
    hashKey = hashKey.replaceAll("&", ".am."); //$NON-NLS-1$ //$NON-NLS-2$
    hashKey = hashKey.replaceAll("\\+", ".pl."); //$NON-NLS-1$ //$NON-NLS-2$

    key.setValue(hashKey);
    persistenceManager.save(key);
   
    String message = localizedMessages.getString("WidgetKeyManager.0")+hashKey+" \n"//$NON-NLS-1$//$NON-NLS-2$
    message+="\n" + localizedMessages.getString("WidgetKeyManager.1"); //$NON-NLS-1$ //$NON-NLS-2$
   
    Configuration properties = (Configuration) request.getSession().getServletContext().getAttribute("properties"); //$NON-NLS-1$
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

   * @see org.apache.wookie.controller.Controller#index(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  @Override
  protected void index(HttpServletRequest request, HttpServletResponse response)
      throws UnauthorizedAccessException, IOException {
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IApiKey[] apiKeys = persistenceManager.findAll(IApiKey.class);
    returnXml(ApiKeyHelper.createXML(apiKeys),response);
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

      throws ResourceDuplicationException, InvalidParametersException,
      UnauthorizedAccessException {
    String value = request.getParameter("apikey");
    String email = request.getParameter("email");
    if (value == null || email == null || value.trim().length() ==0 || email.trim().length() == 0) throw new InvalidParametersException();
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    Map<String, Object> values = new HashMap<String, Object>();
    values.put("value", value);
    values.put("email", email);
    if (persistenceManager.findByValues(IApiKey.class, values).length > 0){
      throw new ResourceDuplicationException();
    }
   
    IApiKey apiKey = persistenceManager.newInstance(IApiKey.class);
    apiKey.setValue(value);
    apiKey.setEmail(email);
    persistenceManager.save(apiKey);
    _logger.info("New API key registered for "+email);
    return true;
  }
View Full Code Here

Examples of org.apache.wookie.beans.util.IPersistenceManager

   */
  @Override
  protected boolean remove(String resourceId, HttpServletRequest request)
      throws ResourceNotFoundException, UnauthorizedAccessException,
      InvalidParametersException {
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IApiKey apiKey = persistenceManager.findById(IApiKey.class, resourceId);
    if (apiKey == null) throw new ResourceNotFoundException();
    persistenceManager.delete(apiKey);
    _logger.info("API key deleted for "+apiKey.getEmail());
    return true;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.