Skip to content

Commit

Permalink
Release 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszbednarek committed Apr 20, 2018
1 parent 46b8efe commit dc22d9f
Show file tree
Hide file tree
Showing 113 changed files with 2,828 additions and 705 deletions.
6 changes: 3 additions & 3 deletions confluence-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>git4c</artifactId>
<groupId>com.networkedassets.git4c</groupId>
<version>1.5.0-RELEASE</version>
<version>1.6.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -418,8 +418,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import com.atlassian.sal.api.transaction.TransactionTemplate
import com.atlassian.user.UserManager
import com.networkedassets.git4c.application.*
import com.networkedassets.git4c.boundary.outbound.*
import com.networkedassets.git4c.core.business.ConfluenceQueryBaseExecutorHolder
import com.networkedassets.git4c.core.business.ConverterBaseExecutorHolder
import com.networkedassets.git4c.core.business.RepositoryPullBaseExecutorHolder
import com.networkedassets.git4c.core.business.RevisionCheckBaseExecutorHolder
import com.networkedassets.git4c.core.business.*
import com.networkedassets.git4c.core.datastore.repositories.*
import com.networkedassets.git4c.infrastructure.*
import com.networkedassets.git4c.infrastructure.cache.*
Expand Down Expand Up @@ -112,15 +109,17 @@ class ConfluencePlugin(
val gitClient = DefaultGitClient()
val importer = GitSourcePlugin(gitClient)
val postProcessor = JSoupPostProcessor(utils.idGenerator)
val mainPlugins = MainConverterPluginList(listOf(AsciidocConverterPlugin(), MarkdownConverterPlugin()), postProcessor)
val mainPlugins = MainConverterPluginList(listOf(AsciidocConverterPlugin.get(true), MarkdownConverterPlugin()), postProcessor)
val converterPlugins = listOf(mainPlugins, PrismJSConverterPlugin(), ImageConverterPlugin(), PUMLConverterPlugin())
val converter = ConverterPluginList(converterPlugins, PlainTextConverterPlugin())
val fileIgnorer = FileIgnorerList(AsciidocConverterPlugin.get(true))
val parser = Parsers()
val pageBuilder = HtmlErrorPageBuilder()
val pageMacroExtractor = AtlassianPageMacroExtractor()
return MacroPluginComponents(
importer,
converter,
fileIgnorer,
parser,
pageBuilder,
pageMacroExtractor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class ResultsCachePluginComponents(
class MacroPluginComponents(
val importer: SourcePlugin,
val converter: ConverterPlugin,
val fileIgnorer: FileIgnorer,
val parser: ParserPlugin,
val pageBuilder: ErrorPageBuilder,
val pageMacroExtractor: PageMacroExtractor
Expand Down Expand Up @@ -149,15 +150,15 @@ class ProcessesPluginComponents(
providers: ProvidersPluginComponents,
val extractContentProcess: ExtractContentProcess = ExtractContentProcess(macro.parser),
val revisionCheckAction: RevisionCheckAction = RevisionCheckAction(executors.revisionCheckExecutor, macro.importer, cache.revisionCache, providers.macroSettingsProvider, providers.repositoryProvider, providers.globsForMacroProvider, cache.documentsViewCache),
val indexDocumentAction: IndexDocumentsAction = IndexDocumentsAction(cache.documentItemCache),
val indexDocumentAction: IndexDocumentsAction = IndexDocumentsAction(cache.documentItemCache, macro.fileIgnorer),
val repositoryPullAction: PullRepositoryAction = PullRepositoryAction(executors.repositoryPullExecutor, providers.macroSettingsProvider, providers.repositoryProvider, providers.globsForMacroProvider, database.extractorDataDatabase, macro.importer, indexDocumentAction, cache.documentsViewCache, cache.revisionCache),
val converterAction: ConvertDocumentItemAction = ConvertDocumentItemAction(macro.importer, providers.macroSettingsProvider, providers.repositoryProvider, async.documentToBeConvertedLockCache, executors.converterExecutor, cache.documentItemCache, macro.pageBuilder, extractContentProcess, database.extractorDataDatabase, macro.converter),
val refreshProcess: RefreshMacroAction = RefreshMacroAction(cache.documentsViewCache, macro.importer, cache.revisionCache, providers.globsForMacroProvider, providers.macroSettingsProvider, providers.repositoryProvider, revisionCheckAction, repositoryPullAction),
val createMacroProcess: CreateMacroProcess = CreateMacroProcess(cache.macroViewCache, macro.importer, executors.repositoryPullExecutor),
val macroViewProcess: MacroViewProcess = MacroViewProcess(cache.macroViewCache, refreshProcess, providers.macroSettingsProvider, providers.repositoryProvider, cache.documentsViewCache),
val getBranchesProcess: GetBranchesProcess = GetBranchesProcess(macro.importer),
val getMethodsProcess: GetMethodsProcess = GetMethodsProcess(macro.importer, macro.converter, macro.parser, extractContentProcess),
val getFilesProcess: GetFilesProcess = GetFilesProcess(macro.importer),
val getFilesProcess: GetFilesProcess = GetFilesProcess(macro.importer, macro.fileIgnorer),
val getFileProcess: GetFileProcess = GetFileProcess(macro.importer, macro.converter, extractContentProcess),
val checkUserPermissionProcess: CheckUserPermissionProcess = CheckUserPermissionProcess(database.macroLocationDatabase, utils.permissionChecker, cache.pageAndSpacePermissionsForUserCache),
val getAllMacrosInSystemProcess: GetAllMacrosInSystem = GetAllMacrosInSystem(utils.pageManager, macro.pageMacroExtractor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ package com.networkedassets.git4c.boundary.outbound
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo

//data class MultiPageMacro(): Macro()
class MultiPageMacro(id: String) : Macro(id)

//data class Macro(val url: String?, val type: Macro.MacroType?, val file: String?, val exists: Boolean = true)

class MultiPageMacro(id: String, url: String) : Macro(id, url)

class SinglePageMacro(id: String, url: String, val file: String) : Macro(id, url)
class SinglePageMacro(id: String, val file: String) : Macro(id)

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes(
JsonSubTypes.Type(value = SinglePageMacro::class, name = "SINGLEFILEMACRO"),
JsonSubTypes.Type(value = MultiPageMacro::class, name = "MULTIFILEMACRO")

)
abstract class Macro(val id: String, val url: String)
abstract class Macro(val id: String)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.networkedassets.git4c.boundary.outbound.FileContent
import com.networkedassets.git4c.boundary.outbound.VerificationStatus
import com.networkedassets.git4c.boundary.outbound.exceptions.NotFoundException
import com.networkedassets.git4c.core.business.Commit
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.business.UserManager
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.bussiness.SourcePlugin
Expand Down Expand Up @@ -41,18 +42,20 @@ class GenerateFilePreviewUseCase(
return error(requestId, NotAuthorizedException("User doesn't have permission to this space"))
}

val macro = macroSettingsRepository.get(macroId)
val macroSettings = macroSettingsRepository.get(macroId)
?: return error(requestId, NotFoundException(request.transactionInfo, VerificationStatus.REMOVED))
val repositoryId = macro.repositoryUuid
val repositoryId = macroSettings.repositoryUuid
val repository = repositoryDatabase.get(repositoryId!!)!!
val branch = macro.branch
val branch = macroSettings.branch

val branchName = "temppreview/${UUID.randomUUID()}"

val macro = Macro(macroSettings.uuid, Macro.MacroType.SINGLEFILE)

try {
importer.createNewBranch(repository, branch, branchName)
importer.updateFile(repository, branchName, file, content, Commit("a", "a", "a"))
val fileContent = getFileProcess.getFile(repository, branchName, file)
val fileContent = getFileProcess.getFile(repository, branchName, file, macro)
importer.removeBranch(repository, branchName)
success(requestId, fileContent)
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.networkedassets.git4c.boundary.GetFileContentForExistingRepositoryRes
import com.networkedassets.git4c.boundary.outbound.FileContent
import com.networkedassets.git4c.boundary.outbound.VerificationStatus
import com.networkedassets.git4c.boundary.outbound.exceptions.NotFoundException
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.datastore.repositories.RepositoryDatabase
import com.networkedassets.git4c.core.process.GetFileProcess
Expand All @@ -27,7 +28,8 @@ class GetFileContentForExistingRepositoryUseCase(
if (repository == null) return error(requestId, NotFoundException(request.transactionInfo, VerificationStatus.REMOVED))

try {
val fileContent = process.getFile(repository, branch, request.detailsToGetFile.file)
val macro = Macro()
val fileContent = process.getFile(repository, branch, request.detailsToGetFile.file, macro)
success(requestId, fileContent)
} catch (e: Exception) {
error(requestId, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import com.networkedassets.git4c.boundary.GetFileContentForPredefinedRepositoryR
import com.networkedassets.git4c.boundary.outbound.FileContent
import com.networkedassets.git4c.boundary.outbound.VerificationStatus
import com.networkedassets.git4c.boundary.outbound.exceptions.NotFoundException
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.datastore.repositories.MacroSettingsDatabase
import com.networkedassets.git4c.core.datastore.repositories.PredefinedRepositoryDatabase
import com.networkedassets.git4c.core.datastore.repositories.RepositoryDatabase
import com.networkedassets.git4c.core.process.GetFileProcess
Expand All @@ -29,9 +31,9 @@ class GetFileContentForPredefinedRepositoryUseCase(
val repository = repositoryDatabase.get(repositoryUuid)
val branch = request.detailsToGetFile.branch
if (repository == null) return error(requestId, NotFoundException(request.transactionInfo, VerificationStatus.REMOVED))

val macro = Macro()
try {
val file = process.getFile(repository, branch, request.detailsToGetFile.file)
val file = process.getFile(repository, branch, request.detailsToGetFile.file, macro)
success(requestId, file)
} catch (e: Exception) {
error(requestId, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import com.networkedassets.git4c.boundary.GetFileContentForRepositoryQuery
import com.networkedassets.git4c.boundary.GetFileContentForRepositoryResultRequest
import com.networkedassets.git4c.boundary.inbound.RepositoryToGetFile
import com.networkedassets.git4c.boundary.outbound.FileContent
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.datastore.repositories.MacroSettingsDatabase
import com.networkedassets.git4c.core.process.GetFileProcess
import com.networkedassets.git4c.core.usecase.async.ComputationResultUseCase
import com.networkedassets.git4c.core.usecase.async.MultiThreadAsyncUseCase
Expand All @@ -25,7 +27,8 @@ class GetFileContentForRepositoryUseCase(
val repository = detectRepository(request.repositoryToGetFile)
val branch = request.repositoryToGetFile.branch
try {
val file = process.getFile(repository, branch, request.repositoryToGetFile.file)
val macro = Macro()
val file = process.getFile(repository, branch, request.repositoryToGetFile.file, macro)
success(requestId, file)
} catch (e: Exception) {
error(requestId, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.networkedassets.git4c.boundary.GetMethodsForExistingRepositoryResultR
import com.networkedassets.git4c.boundary.outbound.Methods
import com.networkedassets.git4c.boundary.outbound.VerificationStatus
import com.networkedassets.git4c.boundary.outbound.exceptions.NotFoundException
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.datastore.repositories.RepositoryDatabase
import com.networkedassets.git4c.core.process.GetMethodsProcess
Expand All @@ -27,7 +28,8 @@ class GetMethodsForExistingRepositoryUseCase(
?: return error(requestId, NotFoundException(request.transactionInfo, VerificationStatus.REMOVED))

try {
val methods = process.getMethods(repository, details.branch, details.file)
val macro = Macro()
val methods = process.getMethods(repository, details.branch, details.file, macro)
success(requestId, methods)
} catch (e: Exception) {
error(requestId, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.networkedassets.git4c.boundary.GetMethodsForPredefinedRepositoryResul
import com.networkedassets.git4c.boundary.outbound.Methods
import com.networkedassets.git4c.boundary.outbound.VerificationStatus
import com.networkedassets.git4c.boundary.outbound.exceptions.NotFoundException
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.datastore.repositories.PredefinedRepositoryDatabase
import com.networkedassets.git4c.core.datastore.repositories.RepositoryDatabase
Expand All @@ -30,7 +31,8 @@ class GetMethodsForPredefinedRepositoryUseCase(
?: return error(requestId, NotFoundException(request.transactionInfo, VerificationStatus.REMOVED))

try {
val methods = process.getMethods(repository, details.branch, details.file)
val macro = Macro()
val methods = process.getMethods(repository, details.branch, details.file, macro)
success(requestId, methods)
} catch (e: Exception) {
error(requestId, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.networkedassets.git4c.boundary.GetMethodsForRepositoryQuery
import com.networkedassets.git4c.boundary.GetMethodsForRepositoryResultRequest
import com.networkedassets.git4c.boundary.inbound.RepositoryToGetMethods
import com.networkedassets.git4c.boundary.outbound.Methods
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.core.bussiness.ComputationCache
import com.networkedassets.git4c.core.process.GetMethodsProcess
import com.networkedassets.git4c.core.usecase.async.ComputationResultUseCase
Expand All @@ -27,7 +28,8 @@ class GetMethodsForRepositoryUseCase(
val file = request.repositoryToGetMethods.file

try {
val methods = process.getMethods(repository, branch, file)
val macro = Macro()
val methods = process.getMethods(repository, branch, file, macro)
success(requestId, methods)
} catch (e: Exception) {
error(requestId, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,17 @@ class GetSpacesWithMacroUseCase(
val macroId = it

val macro = macroSettingsDatabase.get(macroId) ?: return@macro null
val repositoryUuid = macro.repositoryUuid ?: return@macro null
val repository = repositoryDatabase.get(repositoryUuid) ?: return@macro null

val globs = globForMacroDatabase.getByMacro(macroId)

if (macro.type != null && macro.type == MacroType.SINGLEFILE) {
return@macro SinglePageMacro(macroId, repository.repositoryPath, globs.first().glob)
return@macro SinglePageMacro(macroId, globs.first().glob)
} else if (macro.type != null && macro.type == MacroType.MULTIFILE) {
return@macro MultiPageMacro(macroId, repository.repositoryPath)
return@macro MultiPageMacro(macroId)
} else if (globs.size == 1) {
return@macro SinglePageMacro(macroId, repository.repositoryPath, globs.first().glob)
return@macro SinglePageMacro(macroId, globs.first().glob)
} else {
return@macro MultiPageMacro(macroId, repository.repositoryPath)
return@macro MultiPageMacro(macroId)
}

}.filterNotNull().toList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.networkedassets.git4c.core.bussiness

import com.networkedassets.git4c.core.business.ExtractionResult
import com.networkedassets.git4c.core.business.Macro
import com.networkedassets.git4c.data.macro.documents.item.ConvertedDocumentsItem
import com.networkedassets.git4c.data.macro.documents.item.DocumentsItem

interface ConverterPlugin : Plugin {
fun convert(fileData: ImportedFileData, extractionResult: ExtractionResult): ConvertedDocumentsItem?
fun convert(fileData: ImportedFileData, extractionResult: ExtractionResult, macro: Macro): ConvertedDocumentsItem?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.networkedassets.git4c.core.business

import com.networkedassets.git4c.core.bussiness.ImportedFileData

/**
* For given file FileIgnorer returns list of files that shouldn't be converted
*/
interface FileIgnorer {
fun getFilesToIgnore(fileData: ImportedFileData): List<String>
fun supportedExtensions(): List<String>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.networkedassets.git4c.core.business

import com.networkedassets.git4c.core.bussiness.ImportedFileData

class FileIgnorerList(
private vararg val ignorers: FileIgnorer
): FileIgnorer {

override fun getFilesToIgnore(fileData: ImportedFileData): List<String> {
if (!extentions.contains(fileData.extension)) return emptyList()
val ignorer = ignorers.first { it.supportedExtensions().contains(fileData.extension) }
return ignorer.getFilesToIgnore(fileData)
}

override fun supportedExtensions() = extentions.toList()

private val extentions by lazy { ignorers.flatMap { it.supportedExtensions() }.toSet() }

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package com.networkedassets.git4c.core.business

import com.networkedassets.git4c.data.MacroSettings

data class Macro(val uuid: String, val type: MacroType) {
constructor() : this("", MacroType.SINGLEFILE)

enum class MacroType {
MULTIFILE,
SINGLEFILE
}

companion object {
fun from(macroSettings: MacroSettings): Macro {
val macroType = Macro.MacroType.valueOf(macroSettings.type?.name ?: MacroType.SINGLEFILE.name)
val macro = Macro(macroSettings.uuid, macroType)
return macro
}
}
}
Loading

0 comments on commit dc22d9f

Please sign in to comment.