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);
}
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;
}
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;
}
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);
}
}
Aggregations