-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BACKLOG-22005 Migrate and improve html filtering api (#4)
* BACKLOG-22005 Add graphql API * BACKLOG-22005 Update api to show current config * BACKLOG-22005 Update jahia-depends
- Loading branch information
Showing
15 changed files
with
613 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/org/jahia/modules/richtext/graphql/GraphQLSiteSettingsExtensionsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (C) 2002-2020 Jahia Solutions Group SA. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jahia.modules.richtext.graphql; | ||
|
||
import org.jahia.modules.graphql.provider.dxm.DXGraphQLExtensionsProvider; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
/** | ||
* Uses DXGraphQLExtensionsProvider class scanning to implement graphql API support | ||
*/ | ||
@Component(immediate = true) | ||
public class GraphQLSiteSettingsExtensionsProvider implements DXGraphQLExtensionsProvider { | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/jahia/modules/richtext/graphql/models/GqlHTMLFiltering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.jahia.modules.richtext.graphql.models; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
|
||
@GraphQLDescription("Model for HTML filter settings of a site") | ||
public class GqlHTMLFiltering { | ||
|
||
private String siteKey; | ||
private boolean filteringEnabled; | ||
|
||
public GqlHTMLFiltering(String siteKey, boolean filteringEnabled) { | ||
this.siteKey = siteKey; | ||
this.filteringEnabled = filteringEnabled; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("siteKey") | ||
@GraphQLDescription("Site key") | ||
public String getSiteKey() { | ||
return siteKey; | ||
} | ||
|
||
|
||
@GraphQLField | ||
@GraphQLName("filteringEnabled") | ||
@GraphQLDescription("Indicates if html filtering is enabled or not") | ||
public Boolean getFilteringEnabled() { | ||
return filteringEnabled; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ain/java/org/jahia/modules/richtext/graphql/models/GqlHTMLFilteringRemovedAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jahia.modules.richtext.graphql.models; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@GraphQLDescription("Model for HTML filtering remove attributes") | ||
public class GqlHTMLFilteringRemovedAttributes { | ||
|
||
private String element; | ||
private Set<String> attributes = new HashSet<>(); | ||
|
||
@GraphQLField | ||
@GraphQLName("element") | ||
@GraphQLDescription("Element for which attributes were removed") | ||
public String getElement() { | ||
return element; | ||
} | ||
|
||
|
||
@GraphQLField | ||
@GraphQLName("attributes") | ||
@GraphQLDescription("Removed attributes") | ||
public Set<String> getAttributes() { | ||
return attributes; | ||
} | ||
|
||
public void setElement(String element) { | ||
this.element = element; | ||
} | ||
|
||
public void setAttributes(Set<String> attributes) { | ||
this.attributes = attributes; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/org/jahia/modules/richtext/graphql/models/GqlHTMLFilteringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.jahia.modules.richtext.graphql.models; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@GraphQLDescription("Model for HTML filter test") | ||
public class GqlHTMLFilteringTest { | ||
|
||
private String html; | ||
private List<GqlHTMLFilteringRemovedAttributes> removeAttributes = new ArrayList<>(); | ||
private Set<String> removeElements = new HashSet<>(); | ||
|
||
|
||
@GraphQLField | ||
@GraphQLName("html") | ||
@GraphQLDescription("Html after filtering") | ||
public String getHtml() { | ||
return html; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("removedElements") | ||
@GraphQLDescription("List of removed elements. Any attributes removed with the tag are not reported") | ||
public Set<String> getRemovedElements() { | ||
return removeElements; | ||
} | ||
|
||
|
||
@GraphQLField | ||
@GraphQLName("removedAttributes") | ||
@GraphQLDescription("Removed attributes") | ||
public List<GqlHTMLFilteringRemovedAttributes> getRemovedAttributes() { | ||
return removeAttributes; | ||
} | ||
|
||
public void setHtml(String html) { | ||
this.html = html; | ||
} | ||
|
||
public void setRemoveAttributes(List<GqlHTMLFilteringRemovedAttributes> removeAttributes) { | ||
this.removeAttributes = removeAttributes; | ||
} | ||
|
||
public void setRemoveElements(Set<String> removeElements) { | ||
this.removeElements = removeElements; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/jahia/modules/richtext/graphql/models/GqlRichTextConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.jahia.modules.richtext.graphql.models; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@GraphQLDescription("Model for richtext configuration") | ||
public class GqlRichTextConfig { | ||
|
||
private Set<String> protocols = new HashSet<>(); | ||
private Set<String> elements = new HashSet<>(); | ||
private List<GqlRichTextConfigAttribute> attributes = new ArrayList<>(); | ||
|
||
@GraphQLField | ||
@GraphQLName("protocols") | ||
@GraphQLDescription("Protocols") | ||
public Set<String> getProtocols() { | ||
return protocols; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("elements") | ||
@GraphQLDescription("HTML elements") | ||
public Set<String> getElements() { | ||
return elements; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("attributes") | ||
@GraphQLDescription("HTML attributes") | ||
public List<GqlRichTextConfigAttribute> getAttributes() { | ||
return attributes; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/org/jahia/modules/richtext/graphql/models/GqlRichTextConfigAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jahia.modules.richtext.graphql.models; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@GraphQLDescription("Model for richtext configuration attribute") | ||
public class GqlRichTextConfigAttribute { | ||
|
||
private String attribute; | ||
private Set<String> elements = new HashSet<>(); | ||
private String pattern; | ||
|
||
@GraphQLField | ||
@GraphQLName("attribute") | ||
@GraphQLDescription("Html attribute") | ||
public String getAttribute() { | ||
return attribute; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("elements") | ||
@GraphQLDescription("Elements for which attribute is applied") | ||
public Set<String> getElements() { | ||
return elements; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("pattern") | ||
@GraphQLDescription("Pattern used to validate attribute value") | ||
public String getPattern() { | ||
return pattern; | ||
} | ||
|
||
@GraphQLField | ||
@GraphQLName("isGlobal") | ||
@GraphQLDescription("Indicates if attribute is configured globally or for specific elements") | ||
public Boolean isGlobal() { | ||
return elements.isEmpty(); | ||
} | ||
|
||
public void setAttribute(String attribute) { | ||
this.attribute = attribute; | ||
} | ||
|
||
public void setPattern(String pattern) { | ||
this.pattern = pattern; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...a/org/jahia/modules/richtext/graphql/mutation/RichTextConfigurationMutationExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jahia.modules.richtext.graphql.mutation; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
import graphql.annotations.annotationTypes.GraphQLTypeExtension; | ||
import org.jahia.modules.graphql.provider.dxm.DXGraphQLProvider; | ||
import org.jahia.modules.richtext.graphql.mutation.impl.GqlRichTextConfigurationMutation; | ||
|
||
@GraphQLTypeExtension(DXGraphQLProvider.Mutation.class) | ||
public class RichTextConfigurationMutationExtension { | ||
|
||
@GraphQLField | ||
@GraphQLName("richtextConfiguration") | ||
@GraphQLDescription("Entry point for richtext configuration mutations") | ||
public static GqlRichTextConfigurationMutation getRichtextConfiguration() { | ||
return new GqlRichTextConfigurationMutation(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...va/org/jahia/modules/richtext/graphql/mutation/impl/GqlRichTextConfigurationMutation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jahia.modules.richtext.graphql.mutation.impl; | ||
|
||
import graphql.annotations.annotationTypes.GraphQLDescription; | ||
import graphql.annotations.annotationTypes.GraphQLField; | ||
import graphql.annotations.annotationTypes.GraphQLName; | ||
import org.jahia.modules.richtext.graphql.mutation.impl.htmlFiltering.GqlHtmlFilteringMutation; | ||
|
||
@GraphQLName("RichTextConfigurationMutation") | ||
@GraphQLDescription("RichText configuration mutations entry point") | ||
public class GqlRichTextConfigurationMutation { | ||
|
||
@GraphQLField | ||
@GraphQLName("htmlFiltering") | ||
@GraphQLDescription("HTML filtering mutation") | ||
public GqlHtmlFilteringMutation getHtmlFiltering() { | ||
return new GqlHtmlFilteringMutation(); | ||
} | ||
} |
Oops, something went wrong.