Search in sources :

Example 11 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project uPortal by Jasig.

the class RDBMDistributedLayoutStore method getPortletEntity.

private IPortletEntity getPortletEntity(String fName, String layoutNodeId, int userId) {
    // Try getting the entity
    final IPortletEntity portletEntity = this.portletEntityDao.getPortletEntity(layoutNodeId, userId);
    if (portletEntity != null) {
        return portletEntity;
    }
    // Load the portlet definition
    final IPortletDefinition portletDefinition;
    try {
        portletDefinition = this.portletDefinitionRegistry.getPortletDefinitionByFname(fName);
    } catch (Exception e) {
        throw new DataRetrievalFailureException("Failed to retrieve ChannelDefinition for fName='" + fName + "'", e);
    }
    // The channel definition for the fName MUST exist for this class to function
    if (portletDefinition == null) {
        throw new EmptyResultDataAccessException("No ChannelDefinition exists for fName='" + fName + "'", 1);
    }
    // create the portlet entity
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    return this.portletEntityDao.createPortletEntity(portletDefinitionId, layoutNodeId, userId);
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) PortalException(org.apereo.portal.PortalException) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) SQLException(java.sql.SQLException) AuthorizationException(org.apereo.portal.AuthorizationException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 12 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project opennms by OpenNMS.

the class SpringSecurityUserDaoImpl method parseUsers.

/**
 * Parses the users.
 *
 * <p>Convenience method for parsing the users.xml file.</p>
 * <p>This method is synchronized so only one thread at a time
 * can parse the users.xml file and create the <code>principal</code>
 * instance variable.</p>
 *
 * @throws DataRetrievalFailureException the data retrieval failure exception
 */
private void parseUsers() throws DataRetrievalFailureException {
    final HashMap<String, OnmsUser> users = new HashMap<String, OnmsUser>();
    final Map<String, List<GrantedAuthority>> roles = new HashMap<String, List<GrantedAuthority>>();
    try {
        for (final OnmsUser user : m_userManager.getOnmsUserList()) {
            final String username = user.getUsername();
            users.put(username, user);
            if (!roles.containsKey(username)) {
                roles.put(username, new LinkedList<GrantedAuthority>());
            }
            for (final String role : user.getRoles()) {
                if (Authentication.isValidRole(role)) {
                    roles.get(username).add(getAuthority(role));
                    if (Authentication.ROLE_ADMIN.equals(role)) {
                        roles.get(username).add(getAuthority(Authentication.ROLE_USER));
                    }
                }
            }
        }
    } catch (final Throwable t) {
        throw new DataRetrievalFailureException("Unable to get user list.", t);
    }
    LOG.debug("Loaded the users.xml file with {} users", users.size());
    m_usersLastModified = m_userManager.getLastModified();
    m_users = users;
    m_roles = roles;
}
Also used : HashMap(java.util.HashMap) OnmsUser(org.opennms.netmgt.model.OnmsUser) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) List(java.util.List) LinkedList(java.util.LinkedList) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException)

Example 13 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project uPortal by Jasig.

the class JpaPortletEntityDao method createPortletEntity.

@Override
@PortalTransactional
public IPortletEntity createPortletEntity(IPortletDefinitionId portletDefinitionId, String layoutNodeId, int userId) {
    Validate.notNull(portletDefinitionId, "portletDefinitionId can not be null");
    Validate.notEmpty(layoutNodeId, "layoutNodeId can not be null");
    final IPortletDefinition portletDefinition = this.portletDefinitionDao.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        throw new DataRetrievalFailureException("No IPortletDefinition exists for IPortletDefinitionId='" + portletDefinitionId + "'");
    }
    IPortletEntity portletEntity = new PortletEntityImpl(portletDefinition, layoutNodeId, userId);
    this.getEntityManager().persist(portletEntity);
    return portletEntity;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 14 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project opennms by OpenNMS.

the class QuickBaseTicketerPlugin method saveOrUpdate.

public void saveOrUpdate(Ticket ticket) {
    try {
        Properties props = getProperties();
        QuickBaseClient qdb = createClient(getUserName(props), getPassword(props), getUrl(props));
        String dbId = qdb.findDbByName(getApplicationName(props));
        HashMap<String, String> record = new HashMap<String, String>();
        record.put(getSummaryField(props), ticket.getSummary());
        record.put(getDetailsField(props), ticket.getDetails());
        record.put(getStateField(props), getQuickBaseStateValue(ticket.getState(), props));
        if (ticket.getId() == null) {
            addAdditionCreationFields(record, props);
            String recordId = qdb.addRecord(dbId, record);
            ticket.setId(recordId);
        } else {
            Ticket oldTicket = get(ticket.getId());
            if (ticket.getModificationTimestamp().equals(oldTicket.getModificationTimestamp())) {
                qdb.editRecord(dbId, record, ticket.getId());
            } else {
                throw new OptimisticLockingFailureException("Ticket has been updated while this ticket was in memory! Reload and try again!");
            }
        }
    } catch (Throwable e) {
        throw new DataRetrievalFailureException("Failed to commit QuickBase transaction: " + e.getMessage(), e);
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) HashMap(java.util.HashMap) QuickBaseClient(com.intuit.quickbase.util.QuickBaseClient) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) Properties(java.util.Properties)

Aggregations

DataRetrievalFailureException (org.springframework.dao.DataRetrievalFailureException)14 IOException (java.io.IOException)3 Ticket (org.opennms.api.integration.ticketing.Ticket)3 EventOrdering (org.opennms.netmgt.xml.eventconf.EventOrdering)3 Events (org.opennms.netmgt.xml.eventconf.Events)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)2 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)2 DataRecord (org.aspcfs.apps.transfer.DataRecord)2 DataAccessException (org.springframework.dao.DataAccessException)2 QuickBaseClient (com.intuit.quickbase.util.QuickBaseClient)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 ResultSetMetaData (java.sql.ResultSetMetaData)1