Removed some remaining classes that depended on Bebop

pull/28/head
Jens Pelzetter 2022-03-24 19:38:53 +01:00
parent b681c769b9
commit f74b858a93
16 changed files with 15 additions and 1436 deletions

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.contenttypes;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface AuthoringKit {
Class<Object> createComponent();
AuthoringStep[] steps();
}

View File

@ -1,129 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.contenttypes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* Encapsulates the informations about an authoring kit.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class AuthoringKitInfo {
/**
* The create component (the form used to collect the mandatory data for the
* content type).
*/
private Class<Object> createComponent;
/**
* The authoring steps of the authoring kit.
*/
private List<AuthoringStepInfo> authoringSteps;
protected AuthoringKitInfo() {
authoringSteps = new ArrayList<>();
}
public Class<Object> getCreateComponent() {
return createComponent;
}
public void setCreateComponent(
final Class<Object> createComponent) {
this.createComponent = createComponent;
}
public List<AuthoringStepInfo> getAuthoringSteps() {
if (authoringSteps == null) {
return null;
} else {
return Collections.unmodifiableList(authoringSteps);
}
}
protected void setAuthoringSteps(
final List<AuthoringStepInfo> authoringSteps) {
this.authoringSteps = authoringSteps;
}
protected void addAuthoringStep(final AuthoringStepInfo authoringStep) {
authoringSteps.add(authoringStep);
}
protected void removeAuthoringStep(final AuthoringStepInfo authoringStep) {
authoringSteps.remove(authoringStep);
}
@Override
public int hashCode() {
int hash = 3;
hash = 59 * hash + Objects.hashCode(createComponent);
hash = 59 * hash + Objects.hashCode(authoringSteps);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AuthoringKitInfo)) {
return false;
}
final AuthoringKitInfo other = (AuthoringKitInfo) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(createComponent, other.getCreateComponent())) {
return false;
}
return Objects.equals(authoringSteps, other.getAuthoringSteps());
}
public boolean canEqual(final Object obj) {
return obj instanceof AuthoringKitInfo;
}
@Override
public final String toString() {
return toString("");
}
public String toString(final String data) {
return String.format("%s{ "
+ "createComponent = \"%s\", "
+ "authoringSteps = { %s }%s"
+ " }",
super.toString(),
Objects.toString(createComponent),
Objects.toString(authoringSteps),
data);
}
}

View File

@ -1,86 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.contenttypes;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Form;
/**
* Annotation used inside the {@link AuthoringKit} annotation to describe the
* authoring steps belonging to an authoring kit.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
public @interface AuthoringStep {
/**
* Key of the label in the {@link #labelBundle()}. If blank (default) the
* simple name of the annotated class with the suffix {@code .label} is
* used.
*
* @return The label key of the authoring step.
*/
String labelKey() default "";
/**
* Bundle providing the localised label for the authoring step. If omitted
* the default bundle for the content type will be used. The default bundle
* is the fully qualified name of the content type class with the suffix
* {@code Bundle}.
*
* @return The bundle providing the label for the authoring step.
*/
String labelBundle() default "";
/**
* Key of the description in the {@link #descriptionBundle()}. If blank
* (default) the simple name of the annotated class with the suffix
* {@code .description} is used.
*
* @return The description key of the authoring step.
*/
String descriptionKey() default "";
/**
* Bundle providing the localised description for the authoring step. If
* omitted the default bundle for the content type will be used. The default
* bundle is the fully qualified name of the content type class with the
* suffix {@code Bundle}.
*
* @return The bundle providing the description for the authoring step.
*/
String descriptionBundle() default "";
/**
* The position of the authoring step.
*
* @return The position of the authoring step.
*/
int order();
/**
* The component (usually a {@link Form} providing the UI for the authoring
* step.
*
* @return The class providing the UI for the authoring step.
*/
Class<? extends Component> component();
}

View File

@ -1,182 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.contenttypes;
import com.arsdigita.bebop.Component;
import java.util.Objects;
/**
* Encapsulates the information about an authoring step.
*
* @see AuthoringStep
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class AuthoringStepInfo {
/**
* The bundle which provides the label for the authoring step.
*/
private String labelBundle;
/**
* The key of label for the authoring step in the {@link #labelBundle}
*/
private String labelKey;
/**
* The bundle which provides the description for the authoring step.
*/
private String descriptionBundle;
/**
* The key of the description for the authoring step in the
* {@link #descriptionBundle}.
*/
private String descriptionKey;
private int order;
private Class<? extends Component> component;
protected AuthoringStepInfo() {
super();
}
public String getLabelBundle() {
return labelBundle;
}
public void setLabelBundle(final String labelBundle) {
this.labelBundle = labelBundle;
}
public String getLabelKey() {
return labelKey;
}
public void setLabelKey(final String labelKey) {
this.labelKey = labelKey;
}
public String getDescriptionBundle() {
return descriptionBundle;
}
public void setDescriptionBundle(final String descriptionBundle) {
this.descriptionBundle = descriptionBundle;
}
public String getDescriptionKey() {
return descriptionKey;
}
public void setDescriptionKey(final String descriptionKey) {
this.descriptionKey = descriptionKey;
}
public int getOrder() {
return order;
}
public void setOrder(final int order) {
this.order = order;
}
public Class<? extends Component> getComponent() {
return component;
}
public void setComponent(final Class<? extends Component> component) {
this.component = component;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + Objects.hashCode(labelBundle);
hash = 53 * hash + Objects.hashCode(labelKey);
hash = 53 * hash + Objects.hashCode(descriptionBundle);
hash = 53 * hash + Objects.hashCode(descriptionKey);
hash = 53 * hash + Objects.hashCode(order);
hash = 53 * hash + Objects.hashCode(component);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AuthoringStepInfo)) {
return false;
}
final AuthoringStepInfo other = (AuthoringStepInfo) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(this.labelBundle, other.getLabelBundle())) {
return false;
}
if (!Objects.equals(this.labelKey, other.getLabelKey())) {
return false;
}
if (!Objects.equals(this.descriptionBundle,
other.getDescriptionBundle())) {
return false;
}
if (!Objects.equals(this.descriptionKey, other.getDescriptionKey())) {
return false;
}
if (order != other.getOrder()) {
return false;
}
return Objects.equals(this.component, other.getComponent());
}
public boolean canEqual(final Object obj) {
return obj instanceof AuthoringStepInfo;
}
@Override
public final String toString() {
return toString("");
}
public String toString(final String data) {
return String.format("%s{ "
+ "labelBundle = \"%s\", "
+ "labelKey = \"%s\", "
+ "descriptionBundle = \"%s\","
+ "descriptionKey = \"%s\","
+ "order = %d, "
+ "component = \"%s\"%s }",
super.toString(),
labelBundle,
labelKey,
descriptionKey,
descriptionBundle,
order,
Objects.toString(component),
data);
}
}

View File

@ -48,7 +48,6 @@ public class ContentTypeInfo {
private String descriptionKey;
private Class<? extends ContentItem> contentItemClass;
private AuthoringKitInfo authoringKit;
public String getLabelBundle() {
return labelBundle;
@ -91,13 +90,6 @@ public class ContentTypeInfo {
this.contentItemClass = contentItemClass;
}
public AuthoringKitInfo getAuthoringKit() {
return authoringKit;
}
public void setAuthoringKit(final AuthoringKitInfo authoringKit) {
this.authoringKit = authoringKit;
}
@Override
public int hashCode() {
@ -107,7 +99,6 @@ public class ContentTypeInfo {
hash = 97 * hash + Objects.hashCode(descriptionBundle);
hash = 97 * hash + Objects.hashCode(descriptionKey);
hash = 97 * hash + Objects.hashCode(contentItemClass);
hash = 97 * hash + Objects.hashCode(authoringKit);
return hash;
}
@ -139,11 +130,7 @@ public class ContentTypeInfo {
return false;
}
if (!Objects.equals(contentItemClass, other.getContentItemClass())) {
return false;
}
return Objects.equals(authoringKit, other.getAuthoringKit());
return Objects.equals(contentItemClass, other.getContentItemClass());
}
public boolean canEqual(final Object obj) {
@ -162,7 +149,6 @@ public class ContentTypeInfo {
+ "descriptionBundle = \"%s\", "
+ "descriptionKey = \"%s\","
+ "contentItemClass = \"%s\", "
+ "authoringKit = { %s }%s"
+ " }",
super.toString(),
labelBundle,
@ -170,7 +156,6 @@ public class ContentTypeInfo {
descriptionBundle,
descriptionKey,
Objects.toString(contentItemClass),
Objects.toString(authoringKit),
data);
}

View File

@ -44,6 +44,7 @@ import javax.transaction.Transactional;
public class ContentTypesManager {
private static final String DEFAULT_DESCRIPTION_KEY = "description";
private static final String DEFAULT_LABEL_KEY = "label";
/**
@ -62,10 +63,10 @@ public class ContentTypesManager {
.load(CcmModule.class);
final SortedSet<Class<? extends ContentItem>> contentTypes
= new TreeSet<>(
= new TreeSet<>(
(type1, type2) -> {
return type1.getName().compareTo(type2.getName());
}
return type1.getName().compareTo(type2.getName());
}
);
for (final CcmModule module : modules) {
@ -82,7 +83,6 @@ public class ContentTypesManager {
availableContentTypes = contentTypes
.stream()
.filter(type -> type.getAnnotation(AuthoringKit.class) != null)
.map(contentTypeClass -> createContentTypeInfo(contentTypeClass))
.collect(Collectors.toList());
}
@ -96,8 +96,8 @@ public class ContentTypesManager {
* @return A {@link ContentTypeInfo} object describing the content type.
*/
private ContentTypeInfo createContentTypeInfo(
final Class<? extends ContentItem> contentTypeClass) {
final Class<? extends ContentItem> contentTypeClass
) {
Objects.requireNonNull(contentTypeClass);
final ContentTypeInfo contentTypeInfo = new ContentTypeInfo();
@ -141,87 +141,9 @@ public class ContentTypesManager {
}
}
final AuthoringKit authoringKit = contentTypeClass
.getAnnotation(AuthoringKit.class);
if (authoringKit != null) {
final AuthoringKitInfo authoringKitInfo = new AuthoringKitInfo();
authoringKitInfo.setCreateComponent(authoringKit.createComponent());
final List<AuthoringStepInfo> steps = Arrays
.stream(authoringKit.steps())
.map(step -> createAuthoringStepInfo(contentTypeClass, step))
.collect(Collectors.toList());
authoringKitInfo.setAuthoringSteps(steps);
steps.sort((step1, step2) -> Integer.compare(step1.getOrder(),
step2.getOrder()));
contentTypeInfo.setAuthoringKit(authoringKitInfo);
}
return contentTypeInfo;
}
/**
* Helper method for creating an info object about an authoring step.
*
* @param contentTypeClass The class which provides the implementation of
* the content type.
* @param authoringStep The {@link AuthoringStep} annotation providing
* the information about the authoring step.
*
* @return An {@link AuthoringStepInfo} object describing the authoring
* step.
*
*/
private AuthoringStepInfo createAuthoringStepInfo(
final Class<? extends ContentItem> contentTypeClass,
final AuthoringStep authoringStep) {
Objects.requireNonNull(contentTypeClass);
Objects.requireNonNull(authoringStep);
final AuthoringStepInfo stepInfo = new AuthoringStepInfo();
stepInfo.setComponent(authoringStep.component());
stepInfo.setOrder(authoringStep.order());
final String defaultBundleName = String.join(
"",
contentTypeClass.getClass().getName(),
"Bundle");
if (authoringStep.labelBundle().isEmpty()) {
stepInfo.setLabelBundle(defaultBundleName);
} else {
stepInfo.setLabelBundle(authoringStep.labelBundle());
}
if (authoringStep.labelKey().isEmpty()) {
stepInfo.setLabelKey(
String.join(".",
authoringStep.component().getSimpleName(),
DEFAULT_LABEL_KEY));
} else {
stepInfo.setLabelKey(authoringStep.labelKey());
}
if (authoringStep.descriptionBundle().isEmpty()) {
stepInfo.setDescriptionBundle(defaultBundleName);
} else {
stepInfo.setDescriptionBundle(authoringStep.descriptionBundle());
}
if (authoringStep.descriptionKey().isEmpty()) {
stepInfo.setDescriptionKey(
String.join(".",
authoringStep.component().getSimpleName(),
DEFAULT_DESCRIPTION_KEY));
} else {
stepInfo.setDescriptionKey(authoringStep.descriptionKey());
}
return stepInfo;
}
/**
* Retrieves a list of all content types currently available on the system.
*

View File

@ -1,74 +0,0 @@
/*
* Copyright (C) 2017 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.ui.authoring;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Provides meta information about an authoring step which is independent from
* the type of the content item.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ContentItemAuthoringStep {
/**
* Key of the label in the {@link #labelBundle()}. If blank (default) the
* simple name of the annotated class with the suffix {@code .label} is
* used.
*
* @return The label key of the authoring step.
*/
String labelKey() default "";
/**
* Bundle providing the localised label for the authoring step. If omitted
* the default bundle will be used. The default bundle is the fully
* qualified name of the authoring step class with the suffix
* {@code Bundle}.
*
* @return The bundle providing the label for the authoring step.
*/
String labelBundle() default "";
/**
* Key of the description in the {@link #descriptionBundle()}. If blank
* (default) the simple name of the annotated class with the suffix
* {@code .description} is used.
*
* @return The description key of the authoring step.
*/
String descriptionKey() default "";
/**
* Bundle providing the localised description for the authoring step. If
* omitted the default bundle will be used. The default bundle is the fully
* qualified name of the authoring step class with the suffix
* {@code Bundle}.
*
* @return The bundle providing the description for the authoring step.
*/
String descriptionBundle() default "";
}

View File

@ -1,161 +0,0 @@
/*
* Copyright (C) 2017 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.ui.authoring;
import com.arsdigita.bebop.Component;
import java.util.Objects;
/**
* Information about a authoring step which is independent from the type of the
* content item.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ContentItemAuthoringStepInfo {
private Class<? extends Component> step;
/**
* The bundle which provides the label for the authoring step.
*/
private String labelBundle;
/**
* The key of label for the authoring step in the {@link #labelBundle}
*/
private String labelKey;
/**
* The bundle which provides the description for the authoring step.
*/
private String descriptionBundle;
/**
* The key of the description for the authoring step in the
* {@link #descriptionBundle}.
*/
private String descriptionKey;
public Class<? extends Component> getStep() {
return step;
}
public void setStep(Class<? extends Component> step) {
this.step = step;
}
public String getLabelBundle() {
return labelBundle;
}
public void setLabelBundle(String labelBundle) {
this.labelBundle = labelBundle;
}
public String getLabelKey() {
return labelKey;
}
public void setLabelKey(String labelKey) {
this.labelKey = labelKey;
}
public String getDescriptionBundle() {
return descriptionBundle;
}
public void setDescriptionBundle(String descriptionBundle) {
this.descriptionBundle = descriptionBundle;
}
public String getDescriptionKey() {
return descriptionKey;
}
public void setDescriptionKey(String descriptionKey) {
this.descriptionKey = descriptionKey;
}
@Override
public int hashCode() {
int hash = 7;
hash = 53 * hash + Objects.hashCode(step);
hash = 53 * hash + Objects.hashCode(labelBundle);
hash = 53 * hash + Objects.hashCode(labelKey);
hash = 53 * hash + Objects.hashCode(descriptionBundle);
hash = 53 * hash + Objects.hashCode(descriptionKey);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ContentItemAuthoringStepInfo)) {
return false;
}
final ContentItemAuthoringStepInfo other
= (ContentItemAuthoringStepInfo) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(labelBundle, other.getLabelBundle())) {
return false;
}
if (!Objects.equals(labelKey, other.getLabelKey())) {
return false;
}
if (!Objects.equals(descriptionBundle, other.getDescriptionBundle())) {
return false;
}
if (!Objects.equals(descriptionKey, other.getDescriptionKey())) {
return false;
}
return Objects.equals(step, other.getStep());
}
public boolean canEqual(final Object obj) {
return obj instanceof ContentItemAuthoringStep;
}
@Override
public final String toString() {
return toString("");
}
public String toString(final String data) {
return String.format("%s{ "
+ "labelBundle = \"%s\", "
+ "labelKey = \"%s\", "
+ "descriptionBundle = \"%s\", "
+ "descriptionKey = \"%s\","
+ "step = \"%s\"%s }",
super.toString(),
labelBundle,
labelKey,
descriptionBundle,
descriptionKey,
Objects.toString(step),
data);
}
}

View File

@ -1,142 +0,0 @@
/*
* Copyright (C) 2017 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.librecms.ui.authoring;
import com.arsdigita.bebop.Component;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.UnexpectedErrorException;
import org.librecms.contentsection.ContentSectionConfig;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
* Provides easy access to information about the default authoring step which
* are available for every content type.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class ContentItemAuthoringStepManager {
@Inject
private ConfigurationManager confManager;
private List<ContentItemAuthoringStepInfo> stepInfos;
@PostConstruct
protected void initialize() {
final ContentSectionConfig config = confManager
.findConfiguration(ContentSectionConfig.class);
final List<String> classNames = Collections.emptyList();
stepInfos = classNames
.stream()
.map(className -> createStepInfo(className))
.collect(Collectors.toList());
}
public List<ContentItemAuthoringStepInfo> getContentItemAuthoringStepInfos() {
return Collections.unmodifiableList(stepInfos);
}
@SuppressWarnings("unchecked")
private ContentItemAuthoringStepInfo createStepInfo(final String className) {
Objects.requireNonNull(className);
if (className.isEmpty()) {
throw new IllegalArgumentException("The name of the authoring step "
+ "class can't be empty.");
}
final Class<? extends Component> clazz;
try {
clazz = (Class<? extends Component>) Class.forName(className);
} catch (ClassNotFoundException ex) {
throw new UnexpectedErrorException(String
.format("No class for class name \"%s\" available.",
className),
ex);
}
return createStepInfo(clazz);
}
private ContentItemAuthoringStepInfo createStepInfo(
final Class<? extends Component> clazz) {
final ContentItemAuthoringStepInfo stepInfo
= new ContentItemAuthoringStepInfo();
final ContentItemAuthoringStep step = clazz
.getAnnotation(ContentItemAuthoringStep.class);
final String defaultBundleName = String
.join("", clazz.getName(), "Bundle");
final String defaultLabelKey = String.join(".",
clazz.getSimpleName(),
"label");
final String defaultDescKey = String.join(".",
clazz.getSimpleName(),
"description");
if (step == null) {
stepInfo.setLabelBundle(defaultBundleName);
stepInfo.setDescriptionBundle(defaultBundleName);
stepInfo.setLabelKey(defaultLabelKey);
stepInfo.setDescriptionKey(defaultDescKey);
} else {
if (step.labelBundle() == null || step.labelBundle().isEmpty()) {
stepInfo.setLabelBundle(defaultBundleName);
} else {
stepInfo.setLabelBundle(step.labelBundle());
}
if (step.labelKey() == null || step.labelKey().isEmpty()) {
stepInfo.setLabelKey(defaultLabelKey);
} else {
stepInfo.setLabelKey(step.labelKey());
}
if (step.descriptionBundle() == null
|| step.descriptionBundle().isEmpty()) {
stepInfo.setDescriptionBundle(defaultBundleName);
} else {
stepInfo.setDescriptionBundle(step.descriptionBundle());
}
if (step.descriptionKey() == null
|| step.descriptionKey().isEmpty()) {
stepInfo.setDescriptionKey(defaultDescKey);
}
}
stepInfo.setStep(clazz);
return stepInfo;
}
}

View File

@ -1,8 +1,8 @@
drop table CCM_CMS.CATEGORY_TREE_COMPONENTS;
drop table CCM_CMS.FIXED_CONTENT_ITEM_COMPONENTS;
drop table CCM_CMS.GREETING_ITEM_COMPONENTS;
drop table CCM_CMS.CATEGORIZED_ITEM_COMPONENTS;
drop table CCM_CMS.CONTENT_ITEM_COMPONENTS;
drop table if exists CCM_CMS.CATEGORY_TREE_COMPONENTS;
drop table if exists CCM_CMS.FIXED_CONTENT_ITEM_COMPONENTS;
drop table if exists CCM_CMS.GREETING_ITEM_COMPONENTS;
drop table if exists CCM_CMS.CATEGORIZED_ITEM_COMPONENTS;
drop table if exists CCM_CMS.CONTENT_ITEM_COMPONENTS;
drop table CCM_CMS.ITEM_LIST_ORDER;
drop table CCM_CMS.ITEM_LIST_COMPONENTS;
drop table if exists CCM_CMS.ITEM_LIST_ORDER;
drop table if exists CCM_CMS.ITEM_LIST_COMPONENTS;

View File

@ -37,8 +37,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
AuthoringKitInfo.class,
AuthoringStepInfo.class,
ContentTypeInfo.class
});
}

View File

@ -336,7 +336,6 @@ public class CcmIntegrator implements Integrator {
Connection connection = null;
LOGGER.info("Removing schemas for modules scheduled for uninstall...");
try {
//Get JDBC connection
final DataSource dataSource = (DataSource) sessionFactory
.getProperties().get(DATASOURCE_PROPERTY);

View File

@ -26,7 +26,6 @@ import org.libreccm.modules.Module;
import org.libreccm.modules.RequiredModule;
import org.libreccm.modules.ShutdownEvent;
import org.libreccm.modules.UnInstallEvent;
import org.libreccm.shortcuts.ui.ShortcutsSettingsPane;
import org.libreccm.ui.admin.applications.shortcuts.ShortcutsApplicationController;
import org.libreccm.web.ApplicationType;
@ -45,7 +44,6 @@ import org.libreccm.web.ApplicationType;
name = ShortcutsConstants.SHORTCUTS_APP_TYPE,
descBundle = ShortcutsConstants.SHORTCUTS_BUNDLE,
singleton = true,
settingsPane = ShortcutsSettingsPane.class,
creator = ShortcutsApplicationCreator.class,
applicationController = ShortcutsApplicationController.class
)}

View File

@ -1,160 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.shortcuts.ui;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.shortcuts.Shortcut;
import org.libreccm.shortcuts.ShortcutManager;
import org.libreccm.shortcuts.ShortcutRepository;
import org.libreccm.shortcuts.ShortcutsConstants;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* For for creating and editing shortcuts.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ShortcutForm extends Form {
private static final String URL_KEY = "urlKey";
private static final String REDIRECT = "redirect";
private final TextField urlKeyField;
private final TextField redirectField;
private final SaveCancelSection saveCancelSection;
public ShortcutForm(
final ShortcutsSettingsPane shortcutsPane,
final ParameterSingleSelectionModel<String> selectedShortcut) {
super("shortcutForm");
urlKeyField = new TextField(URL_KEY);
urlKeyField.setLabel(new GlobalizedMessage(
"shortcuts.ui.admin.url_key.label",
ShortcutsConstants.SHORTCUTS_BUNDLE));
add(urlKeyField);
redirectField = new TextField(REDIRECT);
redirectField.setLabel(new GlobalizedMessage(
"shortcuts.ui.admin.redirect.label",
ShortcutsConstants.SHORTCUTS_BUNDLE));
add(redirectField);
saveCancelSection = new SaveCancelSection();
add(saveCancelSection);
addValidationListener(e -> {
final PageState state = e.getPageState();
final FormData data = e.getFormData();
final String urlKey = data.getString(URL_KEY);
if (urlKey == null || urlKey.trim().isEmpty()) {
data.addError(URL_KEY, new GlobalizedMessage(
"shortcuts.ui.admin.url_key.error.not_empty",
ShortcutsConstants.SHORTCUTS_BUNDLE));
return;
}
// The URL to redirect must start with a '/' and end with a '/'.
// Between the starting and the ending '/' only the characters
// 'a' to 'z', 'A' to 'Z', '0' to '9', '_', '-' and '.' may appear.
if (!Pattern.matches("^/[-a-zA-Z0-9_./]+/$", urlKey)) {
data.addError(URL_KEY, new GlobalizedMessage(
"shortcuts.ui.admin.url_key.error.invalid",
ShortcutsConstants.SHORTCUTS_BUNDLE));
return;
}
if (data.getString(REDIRECT) == null
|| data.getString(REDIRECT).trim().isEmpty()) {
data.addError(URL_KEY, new GlobalizedMessage(
"shortcuts.ui.admin.redirect.not_empty",
ShortcutsConstants.SHORTCUTS_BUNDLE));
return;
}
final String redirect = data.getString(REDIRECT).toLowerCase(
Locale.ROOT);
if (!redirect.startsWith("http://")
&& !redirect.startsWith("https://")
&& !redirect.startsWith("/")) {
data.addError(URL_KEY, new GlobalizedMessage(
"shortcuts.ui.admin.redirect.error.invalid",
ShortcutsConstants.SHORTCUTS_BUNDLE));
}
});
addInitListener(e -> {
final PageState state = e.getPageState();
final FormData data = e.getFormData();
if (selectedShortcut.isSelected(state)) {
final ShortcutRepository repo = CdiUtil.createCdiUtil()
.findBean(ShortcutRepository.class);
final Shortcut shortcut = repo.findById(Long.parseLong(
selectedShortcut.getSelectedKey(state))).get();
urlKeyField.setValue(state, shortcut.getUrlKey());
redirectField.setValue(state, shortcut.getRedirect());
}
});
addProcessListener(e -> {
final PageState state = e.getPageState();
final FormData data = e.getFormData();
if (saveCancelSection.getSaveButton().isSelected(state)) {
final Shortcut shortcut;
if (selectedShortcut.isSelected(state)) {
final ShortcutRepository repo = CdiUtil.createCdiUtil()
.findBean(ShortcutRepository.class);
shortcut = repo.findById(Long.parseLong(selectedShortcut
.getSelectedKey(state))).get();
shortcut.setUrlKey(data.getString(URL_KEY));
shortcut.setRedirect(data.getString(REDIRECT));
repo.save(shortcut);
} else {
final ShortcutManager shortcutManager = CdiUtil
.createCdiUtil().findBean(ShortcutManager.class);
shortcutManager.createShortcut(data.getString(URL_KEY),
data.getString(REDIRECT));
}
}
selectedShortcut.clearSelection(state);
shortcutsPane.showShortcutsTable(state);
});
}
}

View File

@ -1,124 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.shortcuts.ui;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.admin.applications.AbstractAppSettingsPane;
import org.libreccm.shortcuts.ShortcutsConstants;
/**
* Pane which is used in the {@code /ccm/admin/} application for providing
* an admininstration UI for shortcuts.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ShortcutsSettingsPane extends AbstractAppSettingsPane {
/**
* Parameter for the selected shortcut.
*/
private final StringParameter selectedShortcutParam;
/**
* Selection model for the selected shortcut.
*/
private final ParameterSingleSelectionModel<String> selectedShortcut;
/**
* Table listing all shortcuts.
*/
private final ShortcutsTable shortcutsTable;
/**
* Link for creating a new shortcut.
*/
private final ActionLink addShortcutLink;
/**
* Form for creating and editing shortcuts.
*/
private final ShortcutForm shortcutForm;
public ShortcutsSettingsPane(
final ParameterSingleSelectionModel<String> selectedAppType,
final ParameterSingleSelectionModel<String> selectedAppInstance) {
super(selectedAppType, selectedAppInstance);
selectedShortcutParam = new StringParameter("selectedShortcut");
selectedShortcut = new ParameterSingleSelectionModel<>(
selectedShortcutParam);
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
final Label heading = new Label(new GlobalizedMessage(
"shortcuts.ui.admin.heading", ShortcutsConstants.SHORTCUTS_BUNDLE));
heading.setClassAttr("heading");
panel.add(heading);
shortcutsTable = new ShortcutsTable(this, selectedShortcut);
panel.add(shortcutsTable);
shortcutForm = new ShortcutForm(this, selectedShortcut);
panel.add(shortcutForm);
addShortcutLink = new ActionLink(new GlobalizedMessage(
"shortcuts.ui.admin.add_shortcut",
ShortcutsConstants.SHORTCUTS_BUNDLE));
addShortcutLink.addActionListener(e -> {
showShortcutForm(e.getPageState());
});
panel.add(addShortcutLink);
add(panel);
}
@Override
protected void createWidgets() {
}
@Override
public void register(final Page page) {
super.register(page);
page.addGlobalStateParam(selectedShortcutParam);
page.setVisibleDefault(shortcutsTable, true);
page.setVisibleDefault(shortcutForm, false);
page.setVisibleDefault(addShortcutLink, true);
}
void showShortcutForm(final PageState state) {
shortcutsTable.setVisible(state, false);
shortcutForm.setVisible(state, true);
addShortcutLink.setVisible(state, false);
}
void showShortcutsTable(final PageState state) {
shortcutsTable.setVisible(state, true);
shortcutForm.setVisible(state, false);
addShortcutLink.setVisible(state, true);
}
}

View File

@ -1,225 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.shortcuts.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.LockableImpl;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.shortcuts.Shortcut;
import org.libreccm.shortcuts.ShortcutRepository;
import org.libreccm.shortcuts.ShortcutsConstants;
import java.util.List;
/**
* Table which lists all shortcuts.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ShortcutsTable extends Table {
private static final int COL_URL_KEY = 0;
private static final int COL_REDIRECT = 1;
private static final int COL_EDIT = 2;
private static final int COL_DELETE = 3;
private final ShortcutsSettingsPane shortcutsPane;
public ShortcutsTable(
final ShortcutsSettingsPane shortcutsPane,
final ParameterSingleSelectionModel<String> selectedShortcut) {
super();
this.shortcutsPane = shortcutsPane;
final TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn(
COL_URL_KEY,
new Label(new GlobalizedMessage(
"shortcuts.ui.admin.shortcuts_table.col_url_key.header",
ShortcutsConstants.SHORTCUTS_BUNDLE))
));
columnModel.add(new TableColumn(
COL_REDIRECT,
new Label(new GlobalizedMessage(
"shortcuts.ui.admin.shortcuts_table.col_redirect.header",
ShortcutsConstants.SHORTCUTS_BUNDLE))
));
columnModel.add(new TableColumn(
COL_EDIT,
new Label(new GlobalizedMessage(
"shortcuts.ui.admin.shortcuts_table.col_edit.header",
ShortcutsConstants.SHORTCUTS_BUNDLE))
));
columnModel.add(new TableColumn(
COL_DELETE,
new Label(new GlobalizedMessage(
"shortcuts.ui.admin.shortcuts_table.col_delete.header",
ShortcutsConstants.SHORTCUTS_BUNDLE))
));
columnModel.get(COL_EDIT).setCellRenderer(new TableCellRenderer() {
@Override
public Component getComponent(final Table table,
final PageState state,
final Object value,
final boolean isSelected,
final Object key,
final int row,
final int column) {
return new ControlLink((Component) value);
}
});
columnModel.get(COL_DELETE).setCellRenderer(new TableCellRenderer() {
@Override
public Component getComponent(final Table table,
final PageState state,
final Object value,
final boolean isSelected,
final Object key,
final int row,
final int column) {
return new ControlLink((Component) value);
}
});
addTableActionListener(new TableActionListener() {
@Override
public void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState();
switch (event.getColumn()) {
case COL_EDIT:
selectedShortcut.setSelectedKey(state,
event.getRowKey());
shortcutsPane.showShortcutForm(state);
break;
case COL_DELETE: {
final ShortcutRepository repo = CdiUtil.createCdiUtil()
.findBean(ShortcutRepository.class);
final Shortcut shortcut = repo.findById(Long.parseLong(
(String) event.getRowKey())).get();
repo.delete(shortcut);
break;
}
}
}
@Override
public void headSelected(final TableActionEvent event) {
//nothing
}
});
setModelBuilder(new ShortcutsTableModelBuilder());
setEmptyView(new Label(new GlobalizedMessage(
"shortcuts.ui.admin.table.empty",
ShortcutsConstants.SHORTCUTS_BUNDLE)));
}
private class ShortcutsTableModelBuilder extends LockableImpl implements
TableModelBuilder {
@Override
public TableModel makeModel(final Table table, final PageState state) {
return new ShortcutsTableModel();
}
}
private class ShortcutsTableModel implements TableModel {
private final List<Shortcut> shortcuts;
private int index = -1;
public ShortcutsTableModel() {
final ShortcutRepository repo = CdiUtil.createCdiUtil().findBean(
ShortcutRepository.class);
shortcuts = repo.findAll();
shortcuts.sort((s1, s2) -> {
return s1.getUrlKey().compareTo(s2.getUrlKey());
});
}
@Override
public int getColumnCount() {
return 4;
}
@Override
public boolean nextRow() {
index++;
return index < shortcuts.size();
}
@Override
public Object getElementAt(final int columnIndex) {
final Shortcut shortcut = shortcuts.get(index);
switch (columnIndex) {
case COL_URL_KEY:
return shortcut.getUrlKey();
case COL_REDIRECT:
return shortcut.getRedirect();
case COL_EDIT:
return new Label(new GlobalizedMessage(
"shortcuts.ui.admin.shortcuts_table.edit",
ShortcutsConstants.SHORTCUTS_BUNDLE));
case COL_DELETE:
return new Label(new GlobalizedMessage(
"shortcuts.ui.admin.shortcuts_table.delete",
ShortcutsConstants.SHORTCUTS_BUNDLE));
default:
throw new IllegalArgumentException(
"Not a valid column index");
}
}
@Override
public Object getKeyAt(final int columnIndex) {
return Long.toString(shortcuts.get(index).getShortcutId());
}
}
}