Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public static class ContentTypes {
public static final String JSON = "application/json";
}

public static final String PATH_SEPARATOR = "/";

public static final String SPLIT_PATH_PATTERN = Pattern.quote("/");

public static final Pattern TAXONOMY_VALUE = Pattern.compile("taxonomy\\.([a-zA-Z0-9-]+)\\.yaml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

public enum Scope {
REQUEST,
GLOBAL,
SITE,
MODULE,
SERVER
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import com.condation.cms.api.db.cms.ReadOnlyFile;
import com.condation.cms.api.repository.ContentResource;
import java.io.IOException;
import java.io.Serializable;
import java.util.Map;
Expand All @@ -36,8 +37,20 @@ public interface ContentParser {

void clearCache(String uri);

Content parse(final ContentResource contentResource) throws IOException;

Map<String, Object> parseMeta(final ContentResource contentResource) throws IOException;

/**
* @deprecated use {@link #parse(ContentResource)} instead
*/
@Deprecated(since = "8.4.0", forRemoval = false)
Content parse(final ReadOnlyFile contentFile) throws IOException;

/**
* @deprecated use {@link #parseMeta(ContentResource)} instead
*/
@Deprecated(since = "8.4.0", forRemoval = false)
Map<String, Object> parseMeta(final ReadOnlyFile contentFile) throws IOException;

record ContentRecord(String content, String meta) implements Serializable {}
Expand Down
54 changes: 47 additions & 7 deletions cms-api/src/main/java/com/condation/cms/api/db/Content.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,68 @@
* @author thmar
*/
public interface Content {
/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#isVisible(ContentNode)}
* after resolving the node via {@link com.condation.cms.api.repository.ContentRepository#get(String)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
boolean isVisible (String uri);

Check warning on line 41 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF0&open=AaClIUBhlCHPt0AVdbF0&pullRequest=775


/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#isVisible(ContentNode)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
boolean isVisible (ContentNode node);

Check warning on line 47 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF1&open=AaClIUBhlCHPt0AVdbF1&pullRequest=775


/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#sections(ContentNode)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
List<ContentNode> listSectionEntries(final ReadOnlyFile contentFile);

Check warning on line 53 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF2&open=AaClIUBhlCHPt0AVdbF2&pullRequest=775


/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#children(String)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
List<ContentNode> listContent(final ReadOnlyFile base, final String start);

Check warning on line 59 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF3&open=AaClIUBhlCHPt0AVdbF3&pullRequest=775


/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#directories(String)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
List<ContentNode> listDirectories(final ReadOnlyFile base, final String start);

Check warning on line 65 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF4&open=AaClIUBhlCHPt0AVdbF4&pullRequest=775

@Deprecated(since = "8.3.0")

/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#get(String)}
*/
@Deprecated(since = "8.4.0")
Optional<ContentNode> byUri (final String uri);

/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#get(String)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
Optional<ContentNode> byPath (final String path);

Check warning on line 77 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF5&open=AaClIUBhlCHPt0AVdbF5&pullRequest=775

/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#findByUrl(String)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
Optional<ContentNode> byUrl (final String url);

Check warning on line 83 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF6&open=AaClIUBhlCHPt0AVdbF6&pullRequest=775

Optional<Map<String,Object>> getMeta(final String path);


/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#query(BiFunction)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
public <T> ContentQuery<T> query(final BiFunction<ContentNode, Integer, T> nodeMapper);

Check warning on line 91 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF7&open=AaClIUBhlCHPt0AVdbF7&pullRequest=775

/**
* @deprecated use {@link com.condation.cms.api.repository.ContentRepository#query(String, BiFunction)}
*/
@Deprecated(since = "8.4.0", forRemoval = false)
public <T> ContentQuery<T> query(final String startURI, final BiFunction<ContentNode, Integer, T> nodeMapper);

Check warning on line 97 in cms-api/src/main/java/com/condation/cms/api/db/Content.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUBhlCHPt0AVdbF8&open=AaClIUBhlCHPt0AVdbF8&pullRequest=775

default List<ContentNode> searchByTitle (@NonNull String input) {
return searchByTitle(input, VariantSearchMode.ALL);
Expand Down
17 changes: 17 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/db/ContentNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,23 @@
return SectionUtil.isSectionEntry(name);
}

/**
* @deprecated use
* {@code ContentRepository.variantContext(node).isVariant()};
* this method depends on the filesystem path convention
*/
@Deprecated(since = "8.4.0", forRemoval = false)
public boolean isVariant() {

Check warning on line 135 in cms-api/src/main/java/com/condation/cms/api/db/ContentNode.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaCcDb5BtnVYF_KGrogH&open=AaCcDb5BtnVYF_KGrogH&pullRequest=775
return variantPathSegment() >= 0;
}

/**
* @deprecated use
* {@code ContentRepository.variantContext(node).activeVariantId()};
* this method depends on the filesystem path convention
*/
@Deprecated(since = "8.4.0", forRemoval = false)
public Optional<String> variantId() {

Check warning on line 145 in cms-api/src/main/java/com/condation/cms/api/db/ContentNode.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaCcDb5BtnVYF_KGrogI&open=AaCcDb5BtnVYF_KGrogI&pullRequest=775
var pathParts = normalizedPathParts();
var variantSegment = variantPathSegment(pathParts);
if (variantSegment < 0 || variantSegment + 2 >= pathParts.length) {
Expand All @@ -142,8 +154,13 @@
/**
* Returns the indexed path of the canonical page represented by this
* variant.
*
* @deprecated use
* {@code ContentRepository.variantContext(node).canonical().uri()};
* this method depends on the filesystem path convention
*/
@Deprecated(since = "8.4.0", forRemoval = false)
public Optional<String> originalUri() {

Check warning on line 163 in cms-api/src/main/java/com/condation/cms/api/db/ContentNode.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=CondationCMS_cms-server&issues=AaClIUHElCHPt0AVdbF9&open=AaClIUHElCHPt0AVdbF9&pullRequest=775
var pathParts = normalizedPathParts();
var variantSegment = variantPathSegment(pathParts);
if (variantSegment < 0 || variantSegment + 1 >= pathParts.length) {
Expand Down
13 changes: 13 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/db/ContentQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.condation.cms.api.Constants;
import java.util.List;
import java.util.Map;
import java.util.function.BiPredicate;

/**
*
Expand Down Expand Up @@ -91,6 +92,18 @@ ContentQuery<T> within(

ContentQuery<T> expression(final String expressions);

/**
* Adds backend-specific comparison operators without exposing the concrete
* query implementation to callers.
*/
default ContentQuery<T> customOperators(
Map<String, BiPredicate<Object, Object>> operators) {
if (!operators.isEmpty()) {
throw new UnsupportedOperationException("custom query operators are not supported");
}
return this;
}

/**
* Restricts the query to items whose title matches the input.
*
Expand Down
4 changes: 2 additions & 2 deletions cms-api/src/main/java/com/condation/cms/api/db/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/

import com.condation.cms.api.db.taxonomy.Taxonomies;
import com.condation.cms.api.db.collection.Collections;
import com.condation.cms.api.db.cms.ReadOnlyFileSystem;
import com.condation.cms.api.repository.MutableCollectionRepository;


/**
Expand All @@ -42,7 +42,7 @@ public interface DB extends AutoCloseable{

public Content getContent();

public Collections getCollections();
public MutableCollectionRepository getCollectionRepository();

public Taxonomies getTaxonomies();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import com.condation.cms.api.db.ContentQuery;
import java.util.Optional;

/**
* A named, file-backed collection.
*/
/** A named collection, independent of its persistence backend. */
public interface Collection {

String name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author t.marx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
public record ConfigurationFeature(Configuration configuration) implements Feature {

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author t.marx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE})
public record DBFeature(DB db) implements Feature {

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
*
* @author t.marx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE})
public record EventBusFeature(EventBus eventBus) implements Feature {
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
*
* @author t.marx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE})
public record MessagingFeature(Messaging messaging) implements Feature {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.condation.cms.api.feature.features;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/

import com.condation.cms.api.annotations.FeatureScope;
import com.condation.cms.api.feature.Feature;
import com.condation.cms.api.repository.MutableCollectionRepository;
import com.condation.cms.api.repository.MutableContentRepository;

/** Mutable repositories available only to site-level and module code. */
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE})
public record MutableRepositoryFeature(
MutableContentRepository contentRepository,
MutableCollectionRepository collectionRepository) implements Feature {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.condation.cms.api.feature.features;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/

import com.condation.cms.api.annotations.FeatureScope;
import com.condation.cms.api.feature.Feature;
import com.condation.cms.api.repository.CollectionRepository;
import com.condation.cms.api.repository.ContentRepository;

/** Read-only repositories available in site, module and request contexts. */
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
public record RepositoryFeature(
ContentRepository contentRepository,
CollectionRepository collectionRepository) implements Feature {
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @author t.marx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
public record ServerPropertiesFeature(ServerProperties serverProperties) implements Feature {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @author t.marx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
public record SitePropertiesFeature(SiteProperties siteProperties) implements Feature {

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public record TemplateEngineFeature(TemplateEngine templateEngine) implements Fe

public String render(String template, Map<String, Object> model, RequestContext requestContext) {
try {
var templateModel = new TemplateEngine.Model(null, null, requestContext);
var templateModel = new TemplateEngine.Model(null, requestContext);
templateModel.values.putAll(model);
return templateEngine.render(template, templateModel);
} catch (IOException ioe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author t.marx
*/
@AllArgsConstructor
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
public class ThemeFeature implements Feature {

private Theme theme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author thorstenmarx
*/
@FeatureScope({FeatureScope.Scope.GLOBAL, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
@FeatureScope({FeatureScope.Scope.SITE, FeatureScope.Scope.MODULE, FeatureScope.Scope.REQUEST})
public record WorkflowFeature(Workflow workflow) implements Feature {

}
Loading
Loading