Package org.jasig.portal

Examples of org.jasig.portal.PortalException


            xslt.transform();
            String html = results.toString();
            pw.print(html);
        } catch (Exception e)
        {
            throw new PortalException("Problem generating content.", e);
        }
    }
View Full Code Here


        String errorMessage = e.getMessage();
        try { RDBMServices.rollback(con); } catch ( SQLException sqle ) {
           log.error( sqle.getMessage(), sqle );
           errorMessage += ":" + sqle.getMessage();
        }
         throw new PortalException(errorMessage, e);
       }
    }
View Full Code Here

        return node;

     } catch (Exception e) {
      log.error(e,e);
        throw new PortalException(e);
       }

    }
View Full Code Here

        String errorMessage = e.getMessage();
        try { RDBMServices.rollback(con); } catch ( SQLException sqle ) {
           log.error( sqle.toString() );
           errorMessage += ":" + sqle.getMessage();
        }
         throw new PortalException(errorMessage, e);
       }
}
View Full Code Here

        return count > 0;

     } catch (Exception e) {
      log.error(e,e);
        throw new PortalException(e);
       }
  }
View Full Code Here

        String errorMessage = e.getMessage();
        try { RDBMServices.rollback(con); } catch ( SQLException sqle ) {
           log.error( sqle.getMessage(), sqle );
           errorMessage += ":" + sqle.getMessage();
        }
         throw new PortalException(errorMessage, e);
       }
    }
View Full Code Here

     * @exception PortalException if an error occurs
     */
public synchronized void setAggregatedLayout (IPerson person, UserProfile profile, IAggregatedLayout layoutImpl ) throws PortalException {

    if ( !(layoutImpl instanceof AggregatedLayout) )
       throw new PortalException("The user layout object should have \"AggregatedLayout\" type");

    AggregatedLayout layout = (AggregatedLayout) layoutImpl;
    int userId = person.getID();
    int profileId=profile.getProfileId();
    int layoutId = Integer.parseInt(layoutImpl.getId());
   
    Connection con = null;
   
  try {
 
    con  = RDBMServices.getConnection();
      RDBMServices.setAutoCommit(con, false);

      PreparedStatement psSelect = null;
      final String sQuery = "SELECT LAYOUT_ID FROM UP_USER_PROFILE WHERE USER_ID=? AND PROFILE_ID=?";
      try {
          psSelect = con.prepareStatement(sQuery);
          psSelect.setInt(1, userId);
          psSelect.setInt(2, profileId);
        ResultSet rs = null;
        try {
              rs = psSelect.executeQuery();
             if (rs.next()) {
               rs.getInt(1);
             if ( rs.wasNull() ) {
                    final String sUpdateProfileQuery = "UPDATE UP_USER_PROFILE SET LAYOUT_ID=? WHERE USER_ID=? AND PROFILE_ID=?";
                    PreparedStatement psUpdateUserProfile = null;
                    try {
                        psUpdateUserProfile = con.prepareStatement(sUpdateProfileQuery);
                        psUpdateUserProfile.setInt(1,layoutId);
                        psUpdateUserProfile.setInt(2,userId);
                        psUpdateUserProfile.setInt(3, profileId);
                        if (log.isDebugEnabled())
                            log.debug("AggregatedUserLayoutStore::setAggregatedLayout(): " + sUpdateProfileQuery);
                        psUpdateUserProfile.executeUpdate();
                    } finally {
                        if (psUpdateUserProfile != null){
                            try { psUpdateUserProfile.close(); } catch (Exception e){}
                        }
                    }
             }
             }
          } finally {
            if (rs != null){
                try {rs.close();} catch (Exception e) {}
            }
          }
      } finally {
          if (psSelect != null){
              try { psSelect.close(); } catch (Exception e){}
          }
      }
         
     
      final String sSelectInitQuery = "SELECT INIT_NODE_ID FROM UP_USER_LAYOUT_AGGR WHERE USER_ID=? AND LAYOUT_ID=?";
      if (log.isDebugEnabled())
          log.debug("AggregatedUserLayoutStore::setAggregatedLayout(): " + sSelectInitQuery);
      String firstNodeId = layout.getLayoutFolder(layout.getRootId()).getFirstChildNodeId();
      PreparedStatement psSelectInit = null;
      try {
          psSelectInit = con.prepareStatement(sSelectInitQuery);
          psSelectInit.setInt(1,userId);
          psSelectInit.setInt(2,layoutId);
          ResultSet rsInit = null;
          try {
              rsInit = psSelectInit.executeQuery();
              if ( !rsInit.next() ) {
                 final String insertLayoutQuery = "INSERT INTO UP_USER_LAYOUT_AGGR (LAYOUT_ID,USER_ID,LAYOUT_TITLE,INIT_NODE_ID) VALUES (?,?,?,?)";
                 PreparedStatement psInsertLayout = null;
                 try {
                     psInsertLayout = con.prepareStatement(insertLayoutQuery);
               psInsertLayout.setInt(1,layoutId);
               psInsertLayout.setInt(2,userId);
               psInsertLayout.setString(3, new String (person.getFullName()+" layout"));
               psInsertLayout.setInt(4,Integer.parseInt(firstNodeId));
                     if (log.isDebugEnabled())
                         log.debug("AggregatedUserLayoutStore::setAggregatedLayout(): "+insertLayoutQuery+ "  with values ("+layoutId+", "+userId+", "+new String (person.getFullName()+" layout")+", "+firstNodeId+")");
               psInsertLayout.executeUpdate();
                 } finally {
                     if (psInsertLayout != null){
                         try { psInsertLayout.close(); } catch (Exception e){}
                     }
                 }
             } else {
                 final String sUpdateQuery = "UPDATE UP_USER_LAYOUT_AGGR SET INIT_NODE_ID=? WHERE LAYOUT_ID=? AND USER_ID=?";
                 PreparedStatement psUpdateLayout = null;
                 try {
                     psUpdateLayout = con.prepareStatement(sUpdateQuery);
                     psUpdateLayout.setInt(1,Integer.parseInt(firstNodeId));
                     psUpdateLayout.setInt(2,layoutId);
                     psUpdateLayout.setInt(3, userId);
                     if (log.isDebugEnabled())
                         log.debug("AggregatedUserLayoutStore::setAggregatedLayout(): " + sUpdateQuery);
                     psUpdateLayout.executeUpdate();
                 } finally {
                     if (psUpdateLayout != null){
                         try { psUpdateLayout.close(); } catch (Exception e){}
                     }
                 }
             }
          } finally {
              if (rsInit != null){
                  try { rsInit.close(); } catch (Exception e){}
              }
          }
      } finally {
          if (psSelectInit != null){
              try { psSelectInit.close(); } catch (Exception e){}
          }
      }
     
      // Clear the previous data related to the user layout
      PreparedStatement psDeleteLayout = null;
      try {
          psDeleteLayout = con.prepareStatement("DELETE FROM UP_LAYOUT_STRUCT_AGGR WHERE USER_ID=? AND LAYOUT_ID=?");
          // Deleting the node from the user layout
          psDeleteLayout.setInt(1,userId);
          psDeleteLayout.setInt(2,layoutId);
          psDeleteLayout.executeUpdate();
      } finally {
          if (psDeleteLayout != null){
              try { psDeleteLayout.close(); } catch (Exception e){}
          }
      }

     
      // Deleting restrictions for regular nodes
      PreparedStatement psDeleteLayoutRestriction = null;
      try {
          psDeleteLayoutRestriction = con.prepareStatement("DELETE FROM UP_LAYOUT_RESTRICTIONS WHERE USER_ID=? AND LAYOUT_ID=?");
          // Deleting restrictions for the node
          psDeleteLayoutRestriction.setInt(1,userId);
          psDeleteLayoutRestriction.setInt(2,layoutId);
          psDeleteLayoutRestriction.executeUpdate();
      } finally {
          if (psDeleteLayoutRestriction != null){
              try { psDeleteLayoutRestriction.close(); } catch (Exception e){}
          }
      }

      // Add prepared statements
      PreparedStatement  psAddLayoutNode = con.prepareStatement(LAYOUT_ADD_SQL);
      PreparedStatement  psAddLayoutRestriction = con.prepareStatement(LAYOUT_RESTRICTION_ADD_SQL);
    

       // The loop for all the nodes from the layout
       for ( Enumeration nodeIds = layout.getNodeIds(); nodeIds.hasMoreElements() ;) {
        String strNodeId = nodeIds.nextElement().toString();

        if ( !strNodeId.equals(IALFolderDescription.ROOT_FOLDER_ID) && !strNodeId.equals(IALFolderDescription.LOST_FOLDER_ID) ) {

         ALNode node = layout.getNode(strNodeId);

         int fragmentId = CommonUtils.parseInt(node.getFragmentId());
         int fragmentNodeId = CommonUtils.parseInt(node.getFragmentNodeId());

         if ( fragmentNodeId > 0 || fragmentId <= 0 ) {
        
          /* boolean channelParamsExist = false;

               if ( node.getNodeType() == IUserLayoutNodeDescription.CHANNEL ) {
                int publishId = CommonUtils.parseInt(((IALChannelDescription)node.getNodeDescription()).getChannelPublishId());
                  ResultSet rsChan = stmt.executeQuery("SELECT CHAN_ID FROM UP_CHANNEL WHERE CHAN_ID=" + publishId);
                  try {
                   if ( rsChan.next() )
                     channelParamsExist = true;
                  } finally {
                     rsChan.close();
                    }
               }*/

                 addUserLayoutNode(userId,layoutId,node,psAddLayoutNode,psAddLayoutRestriction,null,null,null);
         }  
        } // End if
       } // End for

       // Commit all the changes
      RDBMServices.commit(con);

      if ( psAddLayoutNode != null ) psAddLayoutNode.close();
      if ( psAddLayoutRestriction != null ) psAddLayoutRestriction.close();


    } catch (Exception e) {
        log.error(e,e);
        try {
          RDBMServices.rollback(con);
        } catch ( Exception ee ) {
            /*ignore*/
        }
        throw new PortalException(e);
    } finally {
    RDBMServices.releaseConnection(con);
    }
}
View Full Code Here

    if ( stmt != null ) stmt.close();
    if ( con != null ) con.close();

    return fragments;
  } catch ( Exception e ) {
      throw new PortalException(e);
  }
}
View Full Code Here

    int userId = person.getID();
    String fragmentId = fragment.getId();
    Connection con=null;

     if ( !(fragment instanceof ALFragment) )
       throw new PortalException("The user layout fragment must have "+ALFragment.class.getName()+" type!");

    ALFragment layout = (ALFragment) fragment;

   try {
     con = RDBMServices.getConnection();
       RDBMServices.setAutoCommit(con, false);       // May speed things up, can't hurt

       Statement stmt = con.createStatement();

         boolean isOwner = false;
         boolean isNewFragment = false;
         // Check if the user was an owner
         ResultSet rs = stmt.executeQuery("SELECT OWNER_ID FROM UP_OWNER_FRAGMENT WHERE FRAGMENT_ID="+fragmentId);
         if ( rs.next() ) {
          if ( rs.getInt(1) == userId )
            isOwner = true;
         } else
            isNewFragment = true;
         if ( rs != null ) rs.close();

         if ( !isOwner && !isNewFragment )
          throw new PortalException("The user "+userId+" is not an owner of the fragment with ID="+fragmentId);

      ALFolder rootNode = layout.getLayoutFolder(layout.getRootId());
      String fragmentRootId = rootNode.getFirstChildNodeId();

      // Check if the fragment is new
      if ( isNewFragment ) {

        String sqlInsert = "INSERT INTO UP_OWNER_FRAGMENT (FRAGMENT_ID,FRAGMENT_ROOT_ID,OWNER_ID,FRAGMENT_NAME,FRAGMENT_DESCRIPTION,PUSHED_FRAGMENT) "+
        "VALUES (?,?,?,?,?,?)";
        PreparedStatement ps = con.prepareStatement(sqlInsert);
        ps.setInt(1,CommonUtils.parseInt(fragmentId));
        if ( fragmentRootId != null )
         ps.setInt(2,CommonUtils.parseInt(fragmentRootId));
        else
         ps.setNull(2,Types.INTEGER);
        ps.setInt(3,userId);
        ps.setString(4,layout.getName());
        ps.setString(5,layout.getDescription());
        ps.setString(6,(layout.isPushedFragment())?"Y":"N");
        ps.executeUpdate();
        ps.close();
      } else {

         String sqlUpdate = "UPDATE UP_OWNER_FRAGMENT SET FRAGMENT_NAME=?,FRAGMENT_DESCRIPTION=?,PUSHED_FRAGMENT=?,FRAGMENT_ROOT_ID=? WHERE OWNER_ID=? AND FRAGMENT_ID=?";
         PreparedStatement ps = con.prepareStatement(sqlUpdate);
         ps.setString(1,layout.getName());
         ps.setString(2,layout.getDescription());
         ps.setString(3,(layout.isPushedFragment())?"Y":"N");
         if ( fragmentRootId != null )
          ps.setInt(4,CommonUtils.parseInt(fragmentRootId));
         else
          ps.setNull(4,Types.INTEGER);
         ps.setInt(5,userId);
         ps.setInt(6,CommonUtils.parseInt(fragmentId));
         ps.executeUpdate();
         ps.close();
        }

      // Clear the previous data related to the user layout
      stmt.executeUpdate("DELETE FROM UP_FRAGMENTS WHERE FRAGMENT_ID="+fragmentId);

      // Deleting restrictions for fragment nodes
      stmt.executeUpdate("DELETE FROM UP_FRAGMENT_RESTRICTIONS WHERE FRAGMENT_ID="+fragmentId);

      // Add prepared statements
      PreparedStatement  psAddFragmentNode = con.prepareStatement(FRAGMENT_ADD_SQL);
      PreparedStatement  psAddFragmentRestriction = con.prepareStatement(FRAGMENT_RESTRICTION_ADD_SQL);

       // The loop for all the nodes from the layout
      for ( Enumeration nodeIds = layout.getNodeIds(); nodeIds.hasMoreElements() ;) {
        String strNodeId = nodeIds.nextElement().toString();

       if ( !strNodeId.equals(IALFolderDescription.ROOT_FOLDER_ID) && !strNodeId.equals(IALFolderDescription.LOST_FOLDER_ID) ) {

         ALNode node = layout.getNode(strNodeId);

         // Setting the fragment ID
         ((IALNodeDescription)node.getNodeDescription()).setFragmentId(fragmentId);

         int fragmentNodeId = CommonUtils.parseInt(node.getFragmentNodeId());

         if CommonUtils.parseInt(node.getFragmentId()) > 0 && fragmentNodeId <= 0 )
           addUserLayoutNode(userId,-1,node,psAddFragmentNode,psAddFragmentRestriction,null,null,stmt);

       } // End if
      } // End for


      if ( stmt != null ) stmt.close();

      // Commit all the changes
      RDBMServices.commit(con);

      if ( psAddFragmentNode != null ) psAddFragmentNode.close();
      if ( psAddFragmentRestriction != null ) psAddFragmentRestriction.close();

    } catch (Exception e) {
      log.error(e,e);
        try {
          RDBMServices.rollback(con);
        } catch ( Exception e1 ) {
          //ignore
        }
        throw new PortalException(e);
    }finally{
      RDBMServices.releaseConnection(con);
    }
}
View Full Code Here

         isOwner = true;
     }
     if ( rs != null ) rs.close();
    
     if ( !isOwner )
       throw new PortalException("The user "+userId+" is not an owner of the fragment with ID="+fragmentId);
    
     stmt.executeUpdate("DELETE FROM UP_FRAGMENT_RESTRICTIONS WHERE FRAGMENT_ID="+fragmentId);
     stmt.executeUpdate("DELETE FROM UP_GROUP_FRAGMENT WHERE FRAGMENT_ID="+fragmentId);
     stmt.executeUpdate("DELETE FROM UP_FRAGMENTS WHERE FRAGMENT_ID="+fragmentId);

     if ( stmt != null ) stmt.close();
    
     String sqlUpdate = "DELETE FROM UP_OWNER_FRAGMENT WHERE OWNER_ID=? AND FRAGMENT_ID=?";
     PreparedStatement ps = con.prepareStatement(sqlUpdate);
     ps.setInt(1,userId);
     ps.setInt(2,CommonUtils.parseInt(fragmentId));
     ps.executeUpdate();
     ps.close();
    
     // Commit all the changes
     RDBMServices.commit(con);
    
   } catch (Exception e) {
     log.error(e,e);
     try {
      RDBMServices.rollback(con);
        } catch (SQLException e1) {
      // ignore
     }
     throw new PortalException(e);
   }finally{
     // Close the connection
     RDBMServices.releaseConnection(con);
   }
   
View Full Code Here

TOP

Related Classes of org.jasig.portal.PortalException

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.