Package org.apache.jetspeed.components.portletregistry

Examples of org.apache.jetspeed.components.portletregistry.RegistryException


            if (pa != null)
            {
                if (portletFactory.getPortletApplicationClassLoader(pa) != null)
                {
                    throw new RegistryException("Portlet Application " + paName + " still running");
                }

                unregisterPortletApplication(pa, true);
            }
        }
View Full Code Here


    if ((contextName.length() >= prefixLength)
      && contextName.substring(0, prefixLength).equalsIgnoreCase(LOCAL_PA_PREFIX))
    {
      if (!local)
      {
        throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
          + "\" is reserved for Local Portlet Applications only.");
      }
    }
    else if (local)
    {
      throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
        + "\" is required for Local Portlet Applications.");
    }
  }
View Full Code Here

    catch (Exception e)
    {
      String msg = "Failed to load portlet application for "
        + paWar.getPortletApplicationName();
      log.error(msg);
      throw new RegistryException(msg);
    }

    // register the portlet application
    try
    {
      registry.registerPortletApplication(pa);
      registered = true;
      log.info("Registered the portlet application " + paName);

      // add to search engine result
      if (searchEngine != null)
      {
        searchEngine.add(pa);
        searchEngine.add(pa.getPortletDefinitions());
        log.info("Registered the portlet application in the search engine... " + paName);
      }
           
            if ( autoCreateRoles && roleManager != null && pa.getWebApplicationDefinition().getSecurityRoles() != null )
            {
                try
                {
                    Iterator rolesIter = pa.getWebApplicationDefinition().getSecurityRoles().iterator();
                    SecurityRole sr;
                    while ( rolesIter.hasNext() )
                    {
                        sr = (SecurityRole)rolesIter.next();
                        if ( !roleManager.roleExists(sr.getRoleName()) )
                        {
                            roleManager.addRole(sr.getRoleName());
                            log.info("AutoCreated role: "+sr.getRoleName()+" from portlet application "+paName+" its web definition");
                        }
                    }
                }
                catch (SecurityException sex)
                {
                    log.warn("Failed to autoCreate roles for portlet application " + paName+": "+sex.getMessage(), sex);
                }
            }

      return pa;
    }
    catch (Exception e)
    {
      String msg = "Failed to register portlet application, " + paName;
      log.error(msg, e);

      if (registered)
      {
        try
        {
          unregisterPortletApplication(pa, local);
        }
        catch (Exception re)
        {
          log.error("Failed to rollback registration of portlet application" + paName, re);
        }
      }

      throw new RegistryException(msg, e);
    }
  }
View Full Code Here

      }
      catch (IOException e)
      {
        String msg = "Failed to create PA WAR for " + contextName;
        log.error(msg, e);
        throw new RegistryException(msg, e);
      }

      MutablePortletApplication pa = (MutablePortletApplication) registry
        .getPortletApplication(contextName);
View Full Code Here

          }
          catch (PortletEntityNotDeletedException e)
          {
            String msg = "Failed to delete Portlet Entity " + entity.getId();
            log.error(msg, e);
            throw new RegistryException(msg, e);
          }
        }

        entityAccess.removeFromCache(entity);
        windowAccess.removeWindows(entity);
View Full Code Here

    protected void retryStartPortletApplication(String contextName, String contextPath, FileSystemHelper warStruct, ClassLoader paClassLoader, int paType) throws RegistryException
    {
        // Retry to start application according to configuration. Note
        // that this method is not declared transactional to allow clean
        // retries within a single transaction.
        RegistryException tryStartException = null;
        for (int i = 0; (i < maxRetriedStarts+1); i++)
        {
            try
            {
                // try to start portlet application
View Full Code Here

           
            if (pa != null)
            {
                if (portletFactory.isPortletApplicationRegistered(pa))
                {
                    throw new RegistryException("Portlet Application " + paName + " still running");
                }

                unregisterPortletApplication(pa, true);
                try
                {
View Full Code Here

        if ((contextName.length() >= prefixLength)
            && contextName.substring(0, prefixLength).equalsIgnoreCase(LOCAL_PA_PREFIX))
        {
            if (!local)
            {
                throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
                    + "\" is reserved for Local Portlet Applications only.");
            }
        }
        else if (local)
        {
            throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
                + "\" is required for Local Portlet Applications.");
        }
    }
View Full Code Here

                + paWar.getPortletApplicationName();
            if (!silent || log.isDebugEnabled())
            {
                log.error(msg, e);
            }
            throw new RegistryException(msg, e);
        }

        // register the portlet application
        try
        {
            registry.registerPortletApplication(pa);
            registered = true;
            log.info("Registered the portlet application " + paName);

            // add to search engine result
            this.updateSearchEngine(false, pa);
           
            // and add to the current node info
            if (nodeManager != null)
            {           
                nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
            }
            // grant default permissions to portlet application
            grantDefaultPermissions(paName);
           
            if ( autoCreateRoles && roleManager != null && pa.getSecurityRoles() != null )
            {
                try
                {
                    for (SecurityRole sr : pa.getSecurityRoles())
                        if ( !roleManager.roleExists(sr.getName()) )
                        {
                            roleManager.addRole(sr.getName());
                            log.info("AutoCreated role: "+sr.getName()+" from portlet application "+paName+" its web definition");
                        }
                }
                catch (SecurityException sex)
                {
                    log.warn("Failed to autoCreate roles for portlet application " + paName+": "+sex.getMessage(), sex);
                }
            }

            return pa;
        }
        catch (Exception e)
        {
            String msg = "Failed to register portlet application, " + paName;
            if (!silent || log.isDebugEnabled())
            {
                log.error(msg, e);
            }

            if (registered)
            {
                try
                {
                    unregisterPortletApplication(pa, (paType == PortletApplication.LOCAL));
                }
                catch (Exception re)
                {
                    if (!silent || log.isDebugEnabled())
                    {
                        log.error("Failed to rollback registration of portlet application " + paName, re);
                    }
                }
            }

            throw new RegistryException(msg, e);
        }
    }
View Full Code Here

                    log.error(msg, e);
                }
                if ( paClassLoader == null )
                {
                    // nothing to be done about it anymore: this pa is beyond repair :(
                    throw new RegistryException(e);
                }
                register = false;
            }

            // try to get the PA from database by context name
            PortletApplication pa = registry.getPortletApplication(contextName);

            if (pa != null)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("Portlet Application " + contextName + " found in registry.");
                }
                if ( pa.getApplicationType() != paType )
                {
                    throw new RegistryException("Cannot start portlet application "+contextName+": as Application Types don't match: " + pa.getApplicationType() + " != " + paType);
                }
                if (!monitored && changeMonitor != null)
                {
                    changeMonitor.remove(contextName);
                }
                if (log.isDebugEnabled())
                {
                    log.debug("unregistering portlet application " + contextName + "...");
                }
                portletFactory.unregisterPortletApplication(pa);                       
            }
//            if (register && (pa == null || checksum != pa.getChecksum()))
            if (register)
            {
                if (pa == null)
                {
                    // new
                    try
                    {
                        if (log.isDebugEnabled())
                        {
                            log.debug("Register new portlet application " + contextName + ".");
                        }
                       
                        pa = registerPortletApplication(paWar, pa, paType, paClassLoader, silent);
                    }
                    catch (RegistryException e)
                    {
                        throw e;
                    }
                    catch (Exception e)
                    {
                        String msg = "Error register new portlet application " + contextName + ".";
                       
                        if (log.isDebugEnabled())
                        {
                            log.debug(msg);
                        }
                       
                        throw new RegistryException(msg);
                    }
                }
                else
                {
                    if (log.isDebugEnabled())
                    {
                        log.debug("Re-register existing portlet application " + contextName + ".");
                    }
                    int status = nodeManager.checkNode(new Long(pa.getRevision()), pa.getName());
                    boolean reregister = false;
                    boolean deploy = false;
                    switch (status)
                    {
                        case  NodeManager.NODE_NEW:
                        {
                            if (log.isDebugEnabled())
                            {
                                log.debug("Node for Portlet application " + contextName + " is NEW.");
                            }
                            //only reason is that the file got somehow corrupted
                            // so we really do not know what is going on here...
                            // the best chance at this point is to reregister (which might be the absolute wrong choice)
                            log.warn("The portlet application " + pa.getName() + " is registered in the database but not locally .... we will reregister");
                            reregister = true;
                            if (checksum != pa.getChecksum())
                            {
                                log.warn("The provided portlet application " + pa.getName() + " is a different version than in the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will redeploy (also to the database)");
                                deploy = true;
                            }
                            break;
                        }
                        case  NodeManager.NODE_SAVED:
                        {
                            if (log.isDebugEnabled())
                            {
                                log.debug("Node for Portlet application " + contextName + " is SAVED.");
                            }
                            if (checksum != pa.getChecksum())
                            {  
                                log.warn("The provided portlet application " + pa.getName() + " is a different version than in the local node info and the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will reregister AND redeploy (also to the database)");
                                //database and local node info are in synch, so we assume that this is a brand new
                                // war .... let's deploy
                                reregister = true;
                                deploy = true;
                            }
                            break;
                        }
                        case  NodeManager.NODE_OUTDATED:
                        {
                            // new version in database, maybe changed by a different cluster node
                            if (log.isDebugEnabled())
                            {
                                log.debug("Node for Portlet application " + contextName + " is OUTDATED (local PA.id < DB PA.id).");
                            }
                            //database version is older (determined by id) than the database
                            //let's deploy and reregister
                            if (checksum != pa.getChecksum())
                            {
                                log.error("The portlet application " + pa.getName() + " provided for the upgrade IS WRONG. The database checksum= " + pa.getChecksum() + ", but the local=" + checksum + "....THIS NEEDS TO BE CORRECTED");
                                // if the checksums do not match make sure the database is updated with the new PA from file system
                                // I've observed "unavailable PA" in clustered env for the cluster node that reported OUTDATED state
                                deploy = true;
                            }
                            reregister = true;
                            break;
                        }
                    }
                    if (deploy)
                    {
                        if (log.isDebugEnabled())
                        {
                            log.debug("Register (deploy=true) Portlet application " + contextName + " in database.");
                        }
                        pa = registerPortletApplication(paWar, pa, paType, paClassLoader, silent);
                    }
                    else
                        if (reregister)
                        {
                            if (log.isDebugEnabled())
                            {
                                log.debug("Re-Register (reregister=true) Portlet application " + contextName + ".");
                            }
                            // add to search engine result
                            this.updateSearchEngine(true, pa);
                            this.updateSearchEngine(false, pa);
                           
                            // and add to the current node info
                            try
                            {
                                nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
                            } catch (Exception e)
                            {
                                log.error("Adding node for portlet application " + pa.getName() + " caused exception" , e);
                            }
                        }
                       
               
                }
            }
            if (register)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("Register Portlet application " + contextName + " in portlet factory.");
                }
                portletFactory.registerPortletApplication(pa, paClassLoader);
            }
           
            if (!monitored && changeMonitor != null)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("Add change monitor for application " + contextName + " with checksum " + checksum + ".");
                }
                changeMonitor.monitor(contextName, contextPath, paClassLoader, paType, warStruct.getRootDirectory(), checksum);
            }
        }
        catch (Exception e)
        {
            String msg = "Error starting portlet application " + contextName;
           
            if (!silent || log.isDebugEnabled())
            {
                log.error(msg, e);
            }
            // monitor PA for changes
            // do not add monitor if a monitor already exists
            if (!monitored && changeMonitor != null)
            {
                // this code should be hit only during startup process
                if (log.isDebugEnabled())
                {
                    log.debug("Add change monitor for application " + contextName + " and set unsuccessful starts to 1.");
                }
                changeMonitor.monitor(contextName, contextPath, paClassLoader, paType, warStruct.getRootDirectory(), checksum);
                changeMonitor.get(contextName).setUnsuccessfulStarts(1);
            }
            throw new RegistryException(msg);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.components.portletregistry.RegistryException

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.