Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dprzybyl committed Jul 27, 2023
1 parent faac248 commit 2644d87
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ private Set<String> getAccessControlledPaths(Context context)
for (JackrabbitAccessControlEntry jackrabbitAccessControlEntry : jackrabbitAccessControlEntries) {
Set<Restriction> restrictions = ((ACE) jackrabbitAccessControlEntry).getRestrictions();
for (Restriction restriction : restrictions) {
result.add(restriction.getProperty().getValue(Type.STRING));
if (Type.PATH.equals(restriction.getProperty().getType())) {
result.add(restriction.getProperty().getValue(Type.PATH));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ScriptMoveServlet : AbstractFormServlet<ScriptMoveForm>(ScriptMoveForm::cl
this.modelFactory = modelFactory
}

override fun doPost(form: ScriptMoveForm, resolver: ResourceResolver): ResponseEntity<Any> {
override fun doPost(form: ScriptMoveForm, resourceResolver: ResourceResolver): ResponseEntity<Any> {
return try {
val session = resolver.adaptTo(Session::class.java)!!
val session = resourceResolver.adaptTo(Session::class.java)!!
val dest = StringUtils.defaultIfEmpty(form.dest, StringUtils.substringBeforeLast(form.path, "/"))
val rename = if (containsExtension(form.path)) {
form.rename + if (containsExtension(form.rename)) "" else Apm.FILE_EXT
Expand All @@ -61,15 +61,15 @@ class ScriptMoveServlet : AbstractFormServlet<ScriptMoveForm>(ScriptMoveForm::cl
}
var destPath = "$dest/$rename"
if (form.path != destPath) {
destPath = createUniquePath(destPath, resolver)
destPath = createUniquePath(destPath, resourceResolver)
session.move(form.path, destPath)
session.save()
}
if (!containsExtension(form.path)) {
val valueMap = resolver.getResource(destPath)?.adaptTo(ModifiableValueMap::class.java)
val valueMap = resourceResolver.getResource(destPath)?.adaptTo(ModifiableValueMap::class.java)
valueMap?.put(JcrConstants.JCR_TITLE, form.rename)
}
resolver.commit()
resourceResolver.commit()
ok {
message = "Item successfully moved"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ScriptDto(script: Script) {
val path: String = script.path
val author: String? = script.author
val launchEnabled: Boolean = script.isLaunchEnabled
val launchMode: String = script.launchMode.name.toLowerCase()
val launchMode: String = script.launchMode.name.lowercase()
val lastModified: Date? = script.lastModified
val valid: Boolean = script.isValid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class RequestParameterInjector : Injector, StaticInjectAnnotationProcessorFactor
.mapKeys { it.key as String }
.filterKeys { it.startsWith(prefix) }
.mapKeys { it.key.removePrefix(prefix) }
.mapKeys { it.key.decapitalize() }
.mapKeys { entry -> entry.key.replaceFirstChar { it.lowercase() } }

private fun toLocalDateTime(annotatedElement: AnnotatedElement, parameterValue: org.apache.sling.api.request.RequestParameter): LocalDateTime {
val dateFormat = annotatedElement.getAnnotation(DateFormat::class.java)?.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private class PropertyDelegate<T>(
private val default: T
) {

@Suppress("UNCHECKED_CAST")
operator fun getValue(thisRef: Any?, property: KProperty<*>): T? {
return properties[name] as T ?: default
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface VersionService {

fun getVersionPath(script: Script): String

fun updateVersionIfNeeded(resolver: ResourceResolver, vararg script: Script)
fun updateVersionIfNeeded(resolver: ResourceResolver, vararg scripts: Script)

fun countChecksum(root: Iterable<Script>): String

Expand Down

0 comments on commit 2644d87

Please sign in to comment.