use of org.jasig.portlet.cms.mvc.exception.ContentPersistenceException in project SimpleContentPortlet by Jasig.
the class PortletPreferencesContentDaoImplTest method testValidatorError.
@Test
public void testValidatorError() throws IOException {
try {
doThrow(new ValidatorException("", null)).when(preferences).store();
contentDao.saveContent(request, content, null);
Assert.fail("Should have thrown an exception");
} catch (ValidatorException e) {
Assert.fail("Validator exception should have been converted to a ContentPersistenceException");
} catch (ContentPersistenceException e) {
}
}
use of org.jasig.portlet.cms.mvc.exception.ContentPersistenceException in project SimpleContentPortlet by Jasig.
the class PortletPreferencesContentDaoImplTest method testReadOnlyError.
@Test
public void testReadOnlyError() {
try {
doThrow(new ReadOnlyException("")).when(preferences).setValue(PortletPreferencesContentDaoImpl.CONTENT_KEY, content);
contentDao.saveContent(request, content, null);
Assert.fail("Should have thrown an exception");
} catch (ReadOnlyException e) {
Assert.fail("Read-only exception should have been converted to a ContentPersistenceException");
} catch (ContentPersistenceException e) {
}
}
use of org.jasig.portlet.cms.mvc.exception.ContentPersistenceException in project SimpleContentPortlet by Jasig.
the class PortletPreferencesContentDaoImpl method saveContent.
/*
* (non-Javadoc)
* @see org.jasig.portlet.cms.service.dao.IContentDao#saveContent(javax.portlet.ActionRequest, java.lang.String, java.lang.String)
*/
public void saveContent(ActionRequest request, String content, String localeKey) {
try {
PortletPreferences preferences = request.getPreferences();
if (StringUtils.isNotBlank(localeKey)) {
preferences.setValue(getLocaleSpecificKey(localeKey), content);
} else {
preferences.setValue(CONTENT_KEY, content);
}
preferences.store();
} catch (ReadOnlyException e) {
throw new ContentPersistenceException("Failed to save read-only preference", e);
} catch (ValidatorException e) {
throw new ContentPersistenceException("Portlet preferences validation error while attempting to persist portlet content", e);
} catch (IOException e) {
throw new ContentPersistenceException("IO error while attempting to persist portlet content", e);
}
}
use of org.jasig.portlet.cms.mvc.exception.ContentPersistenceException in project SimpleContentPortlet by Jasig.
the class PortletPreferencesContentDaoImplTest method testIOError.
@Test
public void testIOError() throws ValidatorException {
try {
doThrow(new IOException("")).when(preferences).store();
contentDao.saveContent(request, content, null);
Assert.fail("Should have thrown an exception");
} catch (IOException e) {
Assert.fail("Validator exception should have been converted to a ContentPersistenceException");
} catch (ContentPersistenceException e) {
}
}
Aggregations