Package org.apache.wookie.exceptions

Examples of org.apache.wookie.exceptions.InvalidParametersException


      UnauthorizedAccessException {
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        IAccessRequest ar = persistenceManager.findById(IAccessRequest.class, resourceId);
    if (ar == null) throw new ResourceNotFoundException();
    String granted = request.getParameter("granted");
    if (granted == null) throw new InvalidParametersException();
    if (!granted.equals("true") && !granted.equals("false")) throw new InvalidParametersException();
    if (granted.equals("true")) grantAccess(persistenceManager, ar);
    if (granted.equals("false")) revokeAccess(persistenceManager, ar);
  }
View Full Code Here


   
    String origin;
    try {
      origin = checkOrigin(request.getParameter("origin"));
    } catch (Exception e) {
      throw new InvalidParametersException();
    }
   
    String subdomains = request.getParameter("subdomains");
   
    String widgetId = request.getParameter("widgetId");
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, widgetId);
    if (widget == null) throw new InvalidParametersException();
   
    IAccessRequest ar = persistenceManager.newInstance(IAccessRequest.class);
    ar.setOrigin(origin);
    if (subdomains.equals("true")) ar.setSubdomains(true);
    ar.setGranted(false);
View Full Code Here

  protected boolean create(String resourceId, HttpServletRequest request)
      throws ResourceDuplicationException, InvalidParametersException,
      UnauthorizedAccessException {
   
    String url = request.getParameter("url");
    if (url == null || url.trim().length() == 0) throw new InvalidParametersException();
    if (!IRIValidator.isValidIRI(url)) throw new InvalidParametersException();
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    // Check for duplicates
    IWhitelist[] matches = persistenceManager.findByValue(IWhitelist.class, "fUrl", url);
    if (matches.length != 0) throw new ResourceDuplicationException();
    IWhitelist entry = persistenceManager.newInstance(IWhitelist.class);
View Full Code Here

  UnauthorizedAccessException {
    if (!WidgetKeyManager.isValidRequest(request))
      throw new UnauthorizedAccessException();
    String requestId = request.getParameter("requestid"); //$NON-NLS-1$
    if (requestId == null || requestId.equals(""))
      throw new InvalidParametersException();
    if(requestId.equals("stopwidget")){ //$NON-NLS-1$
      doStopWidget(request);
    } else if(requestId.equals("resumewidget")){ //$NON-NLS-1$
      doResumeWidget(request);
    } else if(requestId.equals("clone")){ //$NON-NLS-1$
      cloneSharedData(request);
    } else {
      throw new InvalidParametersException();
    }

  }
View Full Code Here

    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request)
    if(instance!=null){
      lockWidgetInstance(instance);
      Notifier.notifyWidgets(request.getSession(), instance, Notifier.STATE_UPDATED);
    }else{
      throw new InvalidParametersException();
    }
  }
View Full Code Here

    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request);
    if(instance!=null){
      unlockWidgetInstance(instance);
      Notifier.notifyWidgets(request.getSession(), instance, Notifier.STATE_UPDATED);
    }else{
      throw new InvalidParametersException();
    }
  }
View Full Code Here

   * @throws InvalidParametersException
   */
  public static void cloneSharedData(HttpServletRequest request) throws InvalidParametersException{
    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request)
    if (instance == null){
      throw new InvalidParametersException();   
    }
    String sharedDataKey = request.getParameter("shareddatakey");   //$NON-NLS-1$; 
    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 : SharedDataHelper.findSharedData(instance))
    {
        ISharedData clone = persistenceManager.newInstance(ISharedData.class);
            clone.setDkey(sharedData.getDkey());
            clone.setDvalue(sharedData.getDvalue());
            clone.setSharedDataKey(cloneKey);
            persistenceManager.save(clone);
    }
    boolean ok = persistenceManager.save(widget);
    if (!ok) throw new InvalidParametersException();
  }
View Full Code Here

        //
        // Construct a FlatpackFactory for the instance identified in the request
        // If no instance can be found, throw an exception
        //
      IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request);
      if (instance == null) throw new InvalidParametersException();
      FlatpackFactory fac = new FlatpackFactory(instance);
     
      //
      // Set the folder to save the flatpack to an appropriate location on this server
      //
      fac.setFlatpackFolder(new File(request.getSession().getServletContext().getRealPath(FlatpackFactory.DEFAULT_FLATPACK_FOLDER.getPath())));
     
      //
      // Pack the widget instance and get the resulting File
      //
      File flatpack = fac.pack();
     
            //
            // Construct the URL pointing to the exported .wgt file
            //  Note that the resource begins with the servlet path, typically "/wookie"
      //
            String resource = request.getSession().getServletContext().getContextPath() + "/" + FlatpackFactory.DEFAULT_FLATPACK_FOLDER + "/" + flatpack.getName();
            URL url =  getWookieServerURL(request, resource);
     
            //
            // Return the String version of the URL pointing to the exported .wgt file
            //
      path = url.toString();
     
    } catch (Exception e) {
      throw new InvalidParametersException();
    }
    return path;
  }
View Full Code Here

  protected void update(String resourceId, HttpServletRequest request, HttpServletResponse response)
  throws ResourceNotFoundException, InvalidParametersException,
  UnauthorizedAccessException {
    String requestId = request.getParameter("requestid"); //$NON-NLS-1$
    if (requestId == null || requestId.equals(""))
      throw new InvalidParametersException();
    if(requestId.equals("stopwidget")){ //$NON-NLS-1$
      doStopWidget(request);
    } else if(requestId.equals("resumewidget")){ //$NON-NLS-1$
      doResumeWidget(request);
    } else if(requestId.equals("clone")){ //$NON-NLS-1$
      cloneSharedData(request);
    } else {
      throw new InvalidParametersException();
    }

  }
View Full Code Here

    IWidgetInstance instance = WidgetInstancesController.findWidgetInstance(request)
    if(instance!=null){
      lockWidgetInstance(instance);
      Notifier.notifyWidgets(request.getSession(), instance, Notifier.STATE_UPDATED);
    }else{
      throw new InvalidParametersException();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.wookie.exceptions.InvalidParametersException

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.