@Override public void addLocalizationFile( final String domainId, final String locale, final InputStream inputStream, final boolean overwrite) throws DomainStorageException { if (logger.isDebugEnabled()) { logger.debug("addLocalizationFile(" + domainId + ", " + locale + ", inputStream)"); } if (null != inputStream) { if (StringUtils.isEmpty(domainId) || StringUtils.isEmpty(locale)) { throw new IllegalArgumentException( messages.getErrorString( "PentahoMetadataDomainRepository.ERROR_0004_DOMAIN_ID_INVALID", domainId)); } lock.writeLock().lock(); try { // Check for duplicates final RepositoryFile localeFile = metadataMapping.getLocaleFile(domainId, locale); if (!overwrite && localeFile != null) { throw new DomainStorageException( messages.getErrorString( "PentahoMetadataDomainRepository.ERROR_0009_LOCALE_ALREADY_EXISTS", domainId, locale), null); } final SimpleRepositoryFileData data = new SimpleRepositoryFileData(inputStream, DEFAULT_ENCODING, LOCALE_MIME_TYPE); if (localeFile == null) { final RepositoryFile newLocaleFile = createUniqueFile(domainId, locale, data); metadataMapping.addLocale(domainId, locale, newLocaleFile); } else { repository.updateFile(localeFile, data, null); } // This invalidates any cached information flushDomains(); } finally { lock.writeLock().unlock(); } } }