Package org.apache.wookie.beans.util

Examples of org.apache.wookie.beans.util.IPersistenceManager.findById()


  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();
      // FIXME localize error messages
      try {
        W3CWidgetFactory factory  = getFactory(request.getSession().getServletContext());
        installUpdate(factory, widget, false);
View Full Code Here


   * @return
   */
  private static IWidgetService getWidgetService(String resourceId) throws ResourceNotFoundException{
    if (resourceId == null) throw new ResourceNotFoundException();
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidgetService ws = persistenceManager.findById(IWidgetService.class, resourceId);
    if (ws == null) {
      IWidgetService[] wsa = persistenceManager.findByValue(IWidgetService.class, "serviceName", resourceId);
      if (wsa != null && wsa.length == 1) ws = wsa[0];
    }
    if (ws == null) throw new ResourceNotFoundException();
View Full Code Here

   * @param id the id of the widget
   * @return true if the widget is destroyed successfully
   */
  public static boolean destroy(Object id){
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, id);
    return destroy(widget);
  }

  /**
   * Destroy a widget and all dependent objects and references
View Full Code Here

      index(resourceId, request, response);
      return;
    }
    // attempt to get specific widget by id
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
    // support queries by type
    if (widget == null) {
      IWidgetService[] services = persistenceManager.findByValue(IWidgetService.class, "serviceName", resourceId);
        if (services != null && services.length == 1) {
          IWidget[] widgets = persistenceManager.findWidgetsByType(resourceId);
View Full Code Here

        if (widgetId == null){
            accessRequests = persistenceManager.findAll(IAccessRequest.class);
        }
    if (widgetId != null && widgetId.trim().length()>0){
      // Filter by widgetId
      IWidget widget = persistenceManager.findById(IWidget.class, widgetId);
            if (widget != null) accessRequests = persistenceManager.findByValue(IAccessRequest.class, "widget", widget);
    }
   
    switch (format(request)) {
      case XML: returnXml(AccessRequestHelper.createXMLAccessRequestDocument(accessRequests),response);break;
View Full Code Here

  @Override
  protected void show(String resourceId, HttpServletRequest request,
      HttpServletResponse response) throws ResourceNotFoundException,
      UnauthorizedAccessException, IOException {
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IAccessRequest ar = persistenceManager.findById(IAccessRequest.class, resourceId);
    if (ar == null) throw new ResourceNotFoundException();
   
    switch (format(request)) {
      case XML: returnXml(AccessRequestHelper.createXMLAccessRequestDocument(new IAccessRequest[]{ar}),response);break;
      case HTML: returnHtml(AccessRequestHelper.createAccessRequestHTMLTable(new IAccessRequest[]{ar}),response);break;
View Full Code Here

  @Override
  protected void update(String resourceId, HttpServletRequest request)
      throws ResourceNotFoundException, 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);
View Full Code Here

   
    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);
View Full Code Here

  @Override
  protected boolean remove(String resourceId, HttpServletRequest request)
      throws ResourceNotFoundException, UnauthorizedAccessException,
      InvalidParametersException {
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        IAccessRequest ar = persistenceManager.findById(IAccessRequest.class, resourceId);
    if (ar == null) throw new ResourceNotFoundException();
    return persistenceManager.delete(ar);
  }

  private void grantAccess(IPersistenceManager persistenceManager, IAccessRequest ar){
View Full Code Here

    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findWidgetByGuid(resourceId);
    // attempt to get specific widget by id
    if (widget == null) {
      persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      widget = persistenceManager.findById(IWidget.class, resourceId);
    }
    // return widget result
    if (widget == null) throw new ResourceNotFoundException();
   
    try {
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.