Package org.apache.wookie.beans.util

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


  private void removeWidget(HttpServletRequest request, Configuration properties, IWidgetAdminManager manager) {
    final String WIDGETFOLDER = getServletContext().getRealPath(properties.getString("widget.widgetfolder"));//$NON-NLS-1$
    Messages localizedMessages = LocaleHandler.localizeMessages(request);
    String widgetId = request.getParameter("widgetId"); //$NON-NLS-1$
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, widgetId);
    String guid = widget.getGuid();
    if(WidgetFactory.destroy(widget)){
      if(WidgetFileUtils.removeWidgetResources(WIDGETFOLDER, guid)){     
        request.setAttribute("message_value", localizedMessages.getString("WidgetAdminServlet.12"));       //$NON-NLS-1$ //$NON-NLS-2$
      }
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)
      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

  @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

      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

        //
        // test findById  for IWidget
        //
        Object widgetId = allWidgets[0].getId();
        IWidget widgetById = persistenceManager.findById(IWidget.class, widgetId);
        assertNotNull(widgetById);
        assertEquals(allWidgets[0], widgetById);
       
        //
        // test findByValue method for IWidget
View Full Code Here

        //
        // test findById  for IWidget
        //
        Object widgetId = allWidgets[0].getId();
        IWidget widgetById = persistenceManager.findById(IWidget.class, widgetId);
        assertNotNull(widgetById);
        assertEquals(allWidgets[0], widgetById);
       
        //
        // test findByValue method for IWidget
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

        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

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.