Search in sources :

Example 6 with LocaleMapDto

use of org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto in project pentaho-platform by pentaho.

the class ZipExportProcessor method getAvailableLocales.

/**
 * lookup the list of available locale values
 *
 * @param fileId
 * @return
 */
private List<LocaleMapDto> getAvailableLocales(Serializable fileId) {
    List<LocaleMapDto> availableLocales = new ArrayList<LocaleMapDto>();
    List<Locale> locales = getUnifiedRepository().getAvailableLocalesForFileById(fileId);
    if (locales != null && !locales.isEmpty()) {
        for (Locale locale : locales) {
            availableLocales.add(new LocaleMapDto(locale.toString(), null));
        }
    }
    return availableLocales;
}
Also used : Locale(java.util.Locale) LocaleMapDto(org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto) ArrayList(java.util.ArrayList)

Example 7 with LocaleMapDto

use of org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto in project pentaho-platform by pentaho.

the class FileResourceTest method testDoGetFileLocalesError.

@Test
public void testDoGetFileLocalesError() throws Exception {
    Messages mockMessages = mock(Messages.class);
    doReturn(mockMessages).when(fileResource).getMessagesInstance();
    // Test 1
    Exception mockFileNotFoundException = mock(FileNotFoundException.class);
    doThrow(mockFileNotFoundException).when(fileResource.fileService).doGetFileLocales(PATH_ID);
    List<LocaleMapDto> testLocales = fileResource.doGetFileLocales(PATH_ID);
    assertEquals(0, testLocales.size());
    // Test 2
    Throwable mockThrowable = mock(RuntimeException.class);
    doThrow(mockThrowable).when(fileResource.fileService).doGetFileLocales(PATH_ID);
    testLocales = fileResource.doGetFileLocales(PATH_ID);
    assertEquals(0, testLocales.size());
    verify(fileResource, times(2)).getMessagesInstance();
    verify(mockMessages, times(1)).getErrorString("FileResource.FILE_NOT_FOUND", PATH_ID);
    verify(mockMessages, times(1)).getString("SystemResource.GENERAL_ERROR");
}
Also used : LocaleMapDto(org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto) Messages(org.pentaho.platform.web.http.messages.Messages) GeneralSecurityException(java.security.GeneralSecurityException) InvalidParameterException(java.security.InvalidParameterException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) UnifiedRepositoryAccessDeniedException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryAccessDeniedException) FileNotFoundException(java.io.FileNotFoundException) WebApplicationException(javax.ws.rs.WebApplicationException) IllegalSelectorException(java.nio.channels.IllegalSelectorException) IOException(java.io.IOException) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) Test(org.junit.Test)

Aggregations

LocaleMapDto (org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto)6 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 IllegalSelectorException (java.nio.channels.IllegalSelectorException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 InvalidParameterException (java.security.InvalidParameterException)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)3 UnifiedRepositoryAccessDeniedException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryAccessDeniedException)3 RepositoryFileDto (org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto)3 Serializable (java.io.Serializable)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 UnifiedRepositoryException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException)2 StringKeyStringValueDto (org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto)2 PlatformImportException (org.pentaho.platform.plugin.services.importer.PlatformImportException)2 ExportException (org.pentaho.platform.plugin.services.importexport.ExportException)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Locale (java.util.Locale)1