@Override public String version() { return api.version().value(); }
@Override public void importApiDoc(final ApiImportDTO dto, final String token) throws MockImportException, ValidationException { logger.debug("importApiDoc (RAML) called"); validate(dto); File tempDir = null; try { tempDir = Files.createTempDirectory(Long.toString(System.nanoTime())).toFile(); final Api api = readContent(loadRamlFileFromUpload(dto.getFile(), tempDir)); final MockImportConfigDTO apiImportConfig = dto.getConfig(); final String conflictCtxPath = "raml_" + GeneralUtils.createFileNameUniqueTimeStamp(); debug("Keep existing mocks: " + apiImportConfig.isKeepExisting()); debug("Keep strategy: " + apiImportConfig.getKeepStrategy()); debug("Base"); debug("URI " + api.baseUri().value()); debug("version " + api.version().value()); final String defaultMimeType = api.mediaType().stream().findFirst().orElse(() -> "text/plain").value(); loadInResources(api.resources(), apiImportConfig, userTokenServiceUtils.loadCurrentUser(token), conflictCtxPath, defaultMimeType); } catch (RecordNotFoundException ex) { throw new MockImportException("Unauthorized user access"); } catch (MockImportException ex) { throw ex; } catch (Throwable ex) { logger.error("Unexpected error whilst importing RAML API", ex); throw new MockImportException("Unexpected error whilst importing RAML API"); } finally { if (!FileUtils.deleteQuietly(tempDir)) { logger.error("Error deleting temp dir"); } } }