Some more JavaDoc

Former-commit-id: e13f137534
pull/6/head
Jens Pelzetter 2020-09-08 16:52:14 +02:00
parent a4133ad692
commit c84ccd49f7
147 changed files with 1201 additions and 244 deletions

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Java based migrations for the H2 database.
*/
package db.migrations.org.libreccm.ccm_core.h2;

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Java based database migrations that use no database specific SQL.
*/
package db.migrations.org.libreccm.ccm_core;

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Java based migrations for PostgreSQL.
*/
package db.migrations.org.libreccm.ccm_core.pgsql;

View File

@ -27,10 +27,12 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
*
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Deprecated
public class AdminJsfApplicationCreator implements ApplicationCreator<CcmApplication>{
@Inject

View File

@ -28,6 +28,7 @@ import java.util.UUID;
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
public class AdminJsfApplicationSetup extends AbstractCcmApplicationSetup {
public static final String ADMIN_APP_NAME = "CcmAdminJsf";

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 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
*/
/**
* Some experiments with JSF. To be removed.
*
*/
@Deprecated
package org.libreccm.admin.ui;

View File

@ -39,6 +39,7 @@ import java.util.ResourceBundle;
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
@Named
public class SysInfoController {

View File

@ -22,6 +22,7 @@ package org.libreccm.admin.ui.sysinfo;
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
public class SysInfoProperty {
private final String name;

View File

@ -33,7 +33,9 @@ import java.util.stream.Collectors;
import javax.persistence.EntityManager;
/**
*
* Base repository for audited entities. Provides access the the revision of
* an entity.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @param <K> Primary key of the entity.

View File

@ -20,7 +20,8 @@
package org.libreccm.auditing;
/**
*
* Expectation thrown when an query for revision etc fails.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class AuditQueryException extends RuntimeException {

View File

@ -32,7 +32,8 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
/**
*
* Exporter/Importer for {@link Categorization} entities.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -22,7 +22,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.RecursivePermissions;
@ -58,6 +57,7 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
/**
* The category entity represents a single category. Each category is part of a

View File

@ -29,6 +29,7 @@ import java.io.Serializable;
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
*/
@Deprecated
@RequestScoped
public class CategoryIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -5750627754502675522L;

View File

@ -30,7 +30,8 @@ import javax.inject.Inject;
import javax.transaction.Transactional;
/**
*
* Exporter/Importer for {@link Category} entities.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -36,7 +36,7 @@ import java.util.Optional;
import java.util.UUID;
/**
* Provides CRUB operations for {@link Category} objects.
* Provides CRUD operations for {@link Category} objects.
*
* Note: This repository class does no permission checks when retrieving
* categories. This is the responsibility of the application which uses the

View File

@ -18,6 +18,7 @@
*/
package org.libreccm.categorization;
import org.hibernate.LazyInitializationException;
import org.libreccm.l10n.GlobalizationHelper;
import java.util.ArrayList;
@ -29,7 +30,10 @@ import javax.inject.Inject;
import javax.transaction.Transactional;
/**
*
* CDI bean used as interface between Bebop ({@link CategoryTreeModelLite}) and
* CDI. The CDI beans primarly takes are care of transactions and avoids
* {@link LazyInitializationException}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
@ -65,6 +65,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotBlank;
/**
* A domain is collection of categories designed a specific purpose. This entity

View File

@ -29,6 +29,7 @@ import java.io.Serializable;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
@Deprecated
@RequestScoped
public class DomainIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -8504371142795445708L;

View File

@ -29,7 +29,8 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
*
* Exporter/Importer for {@link Domain} entities.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -32,7 +32,9 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
/**
*
* Exporter/Importer for {@link DomainOwnership} entities.
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -19,7 +19,10 @@
package org.libreccm.categorization;
/**
*
* Thrown by {@link CategoryRepository#findByPath(java.lang.String)} and
* {@link CategoryRepository#findByPath(org.libreccm.categorization.Domain, java.lang.String)}
* if the provided category path is invalid.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class InvalidCategoryPathException extends RuntimeException {

View File

@ -16,6 +16,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* This package provides the category system used by CCM.
*/
@XmlSchema(xmlns = {@XmlNs(prefix = "cat", namespaceURI = CAT_XML_NS)})
@XmlAccessorType(XmlAccessType.NONE)
package org.libreccm.categorization;

View File

@ -31,6 +31,8 @@ import java.util.Iterator;
import java.util.Set;
/**
* Utility class providing access the CDI beans in classes not eligible for
* injection.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -40,21 +42,41 @@ public class CdiUtil {
private final BeanManager beanManager;
private CdiUtil(final BeanManager beanManager) {
private CdiUtil(final BeanManager beanManager) {
this.beanManager = beanManager;
}
/**
* Get a new instance of {@code CdiUtil}.
*
* This factory method looks up the {@link BeanManager} using JNDI and
* passes the {@link BeanManager} to the constructor of {@code CdiUtil}.
*
* @return A new instance of {@code CdiUtil}.
*/
public static CdiUtil createCdiUtil() {
try {
final InitialContext context = new InitialContext();
final InitialContext context = new InitialContext();
final BeanManager beanManager = (BeanManager) context.lookup(
"java:comp/BeanManager");
"java:comp/BeanManager"
);
return new CdiUtil(beanManager);
} catch(NamingException ex) {
} catch (NamingException ex) {
throw new IllegalStateException("Unable to lookup BeanManager.", ex);
}
}
/**
* Get an instance of the CDI bean of the provided class.
*
* @param <T> Type of the CDI bean.
* @param beanType The type of the bean to retrieve.
*
* @return An instance of {@code beanType}.
*
* @throws IllegalStateException if no CDI bean of the type {@code beanType}
* is available.
*/
@SuppressWarnings("unchecked")
public <T> T findBean(final Class<T> beanType) {
final Set<Bean<?>> beans = beanManager.getBeans(beanType);

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Utilities for working with CDI.
*/
package org.libreccm.cdi.utils;

View File

@ -19,7 +19,8 @@
package org.libreccm.core.api;
/**
*
* Constants for the RESTful API endpoints provided by ccm-core
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class ApiConstants {
@ -28,7 +29,13 @@ public final class ApiConstants {
// Nothing
}
/**
* Prefix for an ID identifier.
*/
public static final String IDENTIFIER_PREFIX_ID = "ID-";
/**
* Prefix for an UUID identifier
*/
public static final String IDENTIFIER_PREFIX_UUID = "UUID-";
}

View File

@ -17,7 +17,8 @@ import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
*
* JAX-RS application for ccm-core.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ApplicationPath("/api/ccm-core")

View File

@ -19,7 +19,10 @@
package org.libreccm.core.api;
/**
*
* Helper class containing the parts of an extracted identifier.
*
* @see IdentifierExtractor
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ExtractedIdentifier {
@ -35,10 +38,20 @@ public class ExtractedIdentifier {
this.identifier = identifier;
}
/**
* The identifier type.
*
* @return
*/
public IdentifierType getType() {
return type;
}
/**
* The identifier itself.
*
* @return
*/
public String getIdentifier() {
return identifier;
}

View File

@ -23,12 +23,27 @@ import java.util.Objects;
import javax.enterprise.context.Dependent;
/**
*
* Extracts the identifier for an entity from a parameter.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Dependent
public class IdentifierExtractor {
/**
* Extracts the identifier for an entity from a parameter.
*
* If the parameter starts with {@link ApiConstants#IDENTIFIER_PREFIX_ID}
* the identifier is assume to be an ID.
*
* If the parameter starts with {@link ApiConstants#IDENTIFIER_PREFIX_UUID}
* the identifier is assume to be an UUID.
*
* Otherwise the identifier is some property of an entity.
*
* @param identifierParam
* @return
*/
public ExtractedIdentifier extractIdentifier(final String identifierParam) {
Objects.requireNonNull(identifierParam, "identifier param is null.");

View File

@ -19,7 +19,8 @@
package org.libreccm.core.api;
/**
*
* Enum for the supported types of identifiers.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public enum IdentifierType {

View File

@ -33,7 +33,9 @@ import javax.json.JsonArrayBuilder;
import javax.json.JsonValue;
/**
*
* A {@link Collector} implementation that collects {@link JsonValue}s to
* a {@link JsonArray}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class JsonArrayCollector implements Collector<JsonValue, JsonArrayBuilder, JsonArray>{

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Common classes for the RESTful API endpoints provided by ccm-core
*/
package org.libreccm.core.api;

View File

@ -22,7 +22,8 @@ import org.libreccm.configuration.Configuration;
import org.libreccm.configuration.Setting;
/**
*
* Configuration for the CCM files system.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Configuration(descBundle

View File

@ -30,20 +30,10 @@ public class FileAccessException extends Exception {
private static final String MESSAGE_TEMPLATE = "Error accessing file '%s'.";
// /**
// * Creates a new instance of <code>FileAccessException</code> without detail
// * message.
// */
// FileAccessException() {
// super();
// }
FileAccessException(final String path) {
super(String.format(MESSAGE_TEMPLATE, path));
}
// FileAccessException(final Exception ex) {
// super(ex);
// }
FileAccessException(final String path, final Exception ex) {
super(String.format(MESSAGE_TEMPLATE, path), ex);
}

View File

@ -29,24 +29,11 @@ public class FileAlreadyExistsException extends Exception {
private static final long serialVersionUID = 2237027823060973043L;
private static final String MESSAGE_TEMPLATE = "The file '%s' already exists.";
// /**
// * Creates a new instance of <code>FileAlreadyExistsException</code> without
// * detail message.
// */
// FileAlreadyExistsException() {
// super();
// }
FileAlreadyExistsException(final String path) {
super(String.format(MESSAGE_TEMPLATE, path));
}
// FileAlreadyExistsException(final Exception ex) {
// super(ex);
// }
FileAlreadyExistsException(final String path, final Exception ex) {
super(String.format(MESSAGE_TEMPLATE, path), ex);
}

View File

@ -27,25 +27,16 @@ package org.libreccm.files;
public class FileDoesNotExistException extends Exception {
private static final long serialVersionUID = 1L;
private static final String MESSAGE_TEMPLATE = "The file '%s' does not exist.";
// /**
// * Creates a new instance of <code>FileDoesNotExistException</code> without
// * detail message.
// */
// FileDoesNotExistException() {
// }
private static final String MESSAGE_TEMPLATE
= "The file '%s' does not exist.";
FileDoesNotExistException(final String path) {
super(String.format(MESSAGE_TEMPLATE, path));
}
// FileDoesNotExistException(final Exception ex) {
// super(ex);
// }
FileDoesNotExistException(final String path, final Exception ex) {
super(String.format(MESSAGE_TEMPLATE, path), ex);
}
}

View File

@ -24,7 +24,12 @@ import java.io.Reader;
import java.io.Writer;
import java.util.List;
import javax.enterprise.context.RequestScoped;
/**
* Interface for a file system adapter. Implement this interface to add support
* for a method for storing (large} files. The implementation must be a CDI
* bean. It is recommanded that the bean is {@link RequestScoped}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -136,15 +141,15 @@ public interface FileSystemAdapter {
InsufficientPermissionsException;
String getMimeType(String path) throws FileAccessException;
long getSize(String path) throws FileAccessException;
void copy(String sourcePath,
String targetPath,
void copy(String sourcePath,
String targetPath,
boolean recursive) throws FileAccessException;
void move(String sourcePath, String targetPath) throws FileAccessException;
/**
* checks if the provided path points to a directory.
*
@ -243,8 +248,7 @@ public interface FileSystemAdapter {
* @throws FileDoesNotExistException If the requested file does not
* exist.
* @throws DirectoryNotEmptyException If the directory is not empty
* <em>and</em> {@code recursively}
* is set to {@code false}.
* <em>and</em> {@code recursively} is set to {@code false}.
* @throws InsufficientPermissionsException If the user which runs the
* application server does not have
* the permission to access the

View File

@ -29,24 +29,11 @@ public class NoDirectoryException extends Exception {
private static final long serialVersionUID = -5811387600385322767L;
private static final String MESSAGE_TEMPLATE = "The file '%s' is not a directory.";
// /**
// * Creates a new instance of <code>NoDirectoryException</code> without
// * detail message.
// */
// NoDirectoryException() {
// super();
// }
NoDirectoryException(final String path) {
super(String.format(MESSAGE_TEMPLATE, path));
}
// NoDirectoryException(final Exception ex) {
// super(ex);
// }
NoDirectoryException(final String path, final Exception ex) {
super(String.format(MESSAGE_TEMPLATE, path), ex);
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2020 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
*/
/**
* This package provides an API for managing (large) files in different sources.
*
* For details please refer to the documentation of the classes. The main entry
* point is {@link CcmFiles}.
*
*/
package org.libreccm.files;

View File

@ -21,7 +21,6 @@ package org.libreccm.formbuilder;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
@ -29,6 +28,16 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Entities for the form builder migrated from PDL. Not tested yet.
*/
package org.libreccm.formbuilder.actions;

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Base entities for the form builder. Migrated from PDL, not tested yet.
*/
package org.libreccm.formbuilder;

View File

@ -19,7 +19,9 @@
package org.libreccm.imexport;
/**
*
* Thrown by the {@link AbstractEntityImExporter} if the something is wrong
* with the dependencies between entity types (eg circular dependencies).
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class DependencyException extends Exception {

View File

@ -24,7 +24,8 @@ import java.util.List;
import java.util.Objects;
/**
*
* A node in the dependency tree managed by {@link EntityImExporterTreeManager}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
final class EntityImExporterTreeNode {

View File

@ -20,7 +20,8 @@
package org.libreccm.imexport;
/**
*
* Thrown if something goes wrong during an export.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ExportException extends Exception {

View File

@ -20,7 +20,8 @@
package org.libreccm.imexport;
/**
*
* Thrown if something goes wrong during an import process.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ImportExpection extends Exception {

View File

@ -23,7 +23,8 @@ import java.util.Date;
import java.util.List;
/**
*
* Java class containg the properties of an parsed import manifest.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ImportManifest {

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 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
*/
/**
* The classes in this package provide a facility from exporting and importing
* entities to and from CCM installation.
*/
package org.libreccm.imexport;

View File

@ -27,7 +27,8 @@ import javax.inject.Inject;
import javax.persistence.EntityManager;
/**
*
* CDI producer for the {@link AuditReader} of Hibernate Envers.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ApplicationScoped

View File

@ -6,7 +6,9 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
*
* CDI producer providing access to the JPA {@link EntityManager} using
* {@code @Inject}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ApplicationScoped

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* General classes for JPA
*/
package org.libreccm.jpa;

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Utility classes for JPA.
*/
package org.libreccm.jpa.utils;

View File

@ -43,6 +43,11 @@ import java.util.concurrent.Callable;
import java.util.stream.Collectors;
/**
* This CDI bean provides most functions for localization in CCM.
*
* In addition to providing the negoiated locale is also provides some utility
* methods for working with {@link LocalizedString}.
*
* Provides the locale which has been selected based on the available languages
* configured in the {@link KernelConfig}, the preferred languages of the client
* provided an the request, the (optional) {@code lang} attribute in the current
@ -95,8 +100,8 @@ public class GlobalizationHelper implements Serializable {
*
* First tries to get a value for the negotiated locale. If the
* {@code localizedString} does not have a value for the negotiated locale
* the default locale set in {@link KernelConfig} is used. If that also
* values the first value available locale (ordered alphabetically) is used.
* the default locale set in {@link KernelConfig} is used. If that also failes
* the first value available locale (ordered alphabetically) is used.
*
* @param localizedString
*
@ -136,6 +141,16 @@ public class GlobalizationHelper implements Serializable {
.getValue();
}
/**
* Retrieve the value of a {@link LocalizedString} for the current locale.
* This variant allows it to provide a method which provides a fallback
* which is used when the localized string has no value for the current
* locale and the default locale.
*
* @param localizedString
* @param fallbackProvider
* @return
*/
public String getValueFromLocalizedString(
final LocalizedString localizedString,
final Callable<String> fallbackProvider) {
@ -159,6 +174,11 @@ public class GlobalizationHelper implements Serializable {
}
}
/**
* Gets the negotiated locale.
*
* @return
*/
public Locale getNegotiatedLocale() {
final KernelConfig kernelConfig = confManager.findConfiguration(
@ -186,6 +206,11 @@ public class GlobalizationHelper implements Serializable {
return preferred;
}
/**
* Gets the locale selected by the user agent.
*
* @return
*/
public Locale getSelectedLocale() {
// Get the current session, create one if there is none
final HttpSession session = request.getSession(true);
@ -215,6 +240,11 @@ public class GlobalizationHelper implements Serializable {
return selected;
}
/**
* Lists all available locales.
*
* @return All locales configured in the {@link KernelConfig}.
*/
public List<Locale> getAvailableLocales() {
final KernelConfig kernelConfig = confManager
@ -230,6 +260,11 @@ public class GlobalizationHelper implements Serializable {
.collect(Collectors.toList());
}
/**
* Sets the selected locale.
*
* @param locale
*/
public void setSelectedLocale(final Locale locale) {
final HttpSession session = request.getSession(true);
@ -310,6 +345,11 @@ public class GlobalizationHelper implements Serializable {
return new GlobalizedMessagesUtil(bundleName);
}
/**
* Helper function for converting a string to a locale.
* @param language
* @return The locale, or null if the string is not a locale.
*/
private Locale scanLocale(final String language) {
if (language == null || language.isEmpty()) {
return null;

View File

@ -19,7 +19,8 @@
package org.libreccm.l10n;
/**
*
* Constants for the classes in the {@link org.libreccm.l10n} package.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class L10NConstants {

View File

@ -20,6 +20,8 @@ package org.libreccm.l10n.jaxb;
import static org.libreccm.l10n.L10NConstants.*;
import org.libreccm.l10n.LocalizedString;
import java.io.Serializable;
import java.util.Objects;
@ -29,7 +31,8 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
/**
*
* Simple bean class for the value of a {@link LocalizedString} used by JAXB.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@XmlAccessorType(XmlAccessType.FIELD)

View File

@ -21,6 +21,7 @@ package org.libreccm.l10n.jaxb;
import static org.libreccm.l10n.L10NConstants.*;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import org.libreccm.l10n.LocalizedString;
import java.io.Serializable;
import java.util.ArrayList;
@ -32,7 +33,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
/**
*
* Simple bean class for the values of a {@link LocalizedString} used by JAXB.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@XmlAccessorType(XmlAccessType.FIELD)

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 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
*/
/**
* Utility classes for processing {@link LocalizedString} with JAXB.
*/
package org.libreccm.l10n.jaxb;

View File

@ -16,6 +16,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* This package provides several classes for localizing texts.
*/
@XmlSchema(xmlns = {@XmlNs(prefix = "l10n", namespaceURI = L10N_XML_NS)})
@XmlAccessorType(XmlAccessType.NONE)
package org.libreccm.l10n;

View File

@ -21,13 +21,24 @@ package org.libreccm.messaging;
import org.libreccm.jpa.utils.MimeTypeConverter;
import javax.activation.MimeType;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -23,7 +23,7 @@ import org.libreccm.jpa.utils.MimeTypeConverter;
import org.libreccm.security.User;
import javax.activation.MimeType;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
@ -32,6 +32,18 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 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
*/
/**
* Entities for messaging. Ported from PDL, old classes had no documentation.
* These might be removed.
*/
package org.libreccm.messaging;

View File

@ -18,12 +18,18 @@
*/
package org.libreccm.modules;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* A JPA entity bean for for installed modules table for use in the LibreCCM
* administration UI.

View File

@ -21,13 +21,20 @@ package org.libreccm.notification;
import org.libreccm.core.CcmObject;
import org.libreccm.security.Party;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
*
* Models the envelope information associated with a digest.

View File

@ -22,13 +22,20 @@ import org.libreccm.core.CcmObject;
import org.libreccm.messaging.Message;
import org.libreccm.security.Party;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
*
* The {@code Notification} class is used to create and send messages via email

View File

@ -21,12 +21,20 @@ package org.libreccm.notification;
import org.libreccm.messaging.Message;
import org.libreccm.security.Party;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
* Represents a notification that has been transferred to the outbound message
* queue. During processing, this class is used to retrieve information
@ -202,13 +210,13 @@ public class QueueItem implements Serializable {
@Override
public String toString() {
return String.format("%s{ "
+ "queueItemId = %d, "
+ "receiver = %s, "
+ "retryCount = %d, "
+ "successful = %b, "
+ "receiverAddress = \"%s\", "
+ "message = %s"
+ " }",
+ "queueItemId = %d, "
+ "receiver = %s, "
+ "retryCount = %d, "
+ "successful = %b, "
+ "receiverAddress = \"%s\", "
+ "message = %s"
+ " }",
super.toString(),
queueItemId,
Objects.toString(receiver),

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 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
*/
/**
* Entites for the notificiation system of CCM. Ported from CCM
* ToDo: Check if these entities are still of use. If no remove them
*/
package org.libreccm.notification;

View File

@ -20,12 +20,17 @@ package org.libreccm.portal;
import org.libreccm.core.Resource;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
*
*

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 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
*/
/**
* Entities for building portals. Ported from PDL.
*
* ToDo: Check if these entities are still useful. If not remove them.
*/
package org.libreccm.portal;

View File

@ -18,7 +18,7 @@
*/
package org.libreccm.runtime;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@ -27,6 +27,17 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -20,13 +20,24 @@ package org.libreccm.search.lucene;
import org.libreccm.security.User;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -20,12 +20,20 @@ package org.libreccm.search.lucene;
import org.libreccm.web.Host;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 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
*/
/**
* Entities ported from the old CCM search system.
*
* ToDo: Check if still useful. Refactor or remove if necssary.
*/
package org.libreccm.search.lucene;

View File

@ -25,7 +25,8 @@ import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
*
* JAX-RS application for authenticating via JSON Web Token
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ApplicationPath("/jwt")

View File

@ -20,7 +20,8 @@
package org.libreccm.security;
/**
*
* Thrown if a challenge for user activation or password reset fails.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ChallengeFailedException extends Exception {

View File

@ -23,6 +23,7 @@ import com.arsdigita.mail.Mail;
import com.arsdigita.ui.login.LoginConstants;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import org.apache.commons.lang.text.StrSubstitutor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -32,11 +33,16 @@ import org.libreccm.core.CoreConstants;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.l10n.LocalizedString;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import static com.arsdigita.ui.login.LoginServlet.*;

View File

@ -31,7 +31,8 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
/**
*
* Exporter/Importer for {@link Group}s.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -35,7 +35,6 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.imexport.Exportable;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -30,12 +30,15 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
/**
* Exporter/Importer for {@link GroupMembership} entities.
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Processes(GroupMembership.class)
public class GroupMembershipImExporter extends AbstractEntityImExporter<GroupMembership> {
public class GroupMembershipImExporter
extends AbstractEntityImExporter<GroupMembership> {
@Inject
private EntityManager entityManager;
@ -44,14 +47,14 @@ public class GroupMembershipImExporter extends AbstractEntityImExporter<GroupMem
return GroupMembership.class;
}
@Override
protected Set<Class<? extends Exportable>> getRequiredEntities() {
final Set<Class<? extends Exportable>> entities = new HashSet<>();
entities.add(User.class);
entities.add(Group.class);
return entities;
}

View File

@ -49,6 +49,7 @@ import javax.transaction.Transactional;
import javax.ws.rs.POST;
/**
* JAX-RS endpoint for generating JSON Web Tokens for authenticiation.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -62,6 +63,16 @@ public class JwtProvider {
@Inject
private Shiro shiro;
/**
* Generates a new JSON Web Token
*
* @param requestCredentials Credentials for authentication as JSON object
* with the properties {@code username} and
* {@code password}.
*
* @return A response with the JSON Web Token for a Forbidden response if
* the credentials are incorrect.
*/
@POST
@Path("/")
@Transactional(Transactional.TxType.REQUIRED)
@ -74,7 +85,6 @@ public class JwtProvider {
.build();
}
final JsonObjectBuilder jsonObjBuilder = Json.createObjectBuilder();
final StringReader credentialsReader = new StringReader(
requestCredentials);
final JsonReader jsonReader = Json.createReader(credentialsReader);
@ -139,6 +149,12 @@ public class JwtProvider {
}
}
/**
* Helper method for generating a secret for the JSON Web Tokens.
*
* Only called if no secret if found in the {@link KernelConfig}. The secret
* is stored in the {@link KernelConfig}.
*/
private void generateSecret() {
final Random random = new SecureRandom();
final byte[] randomBytes = new byte[64];

View File

@ -37,7 +37,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* Shiro filter using JSON Web Tokens for authenticiation.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class JwtVerifyingFilter extends AccessControlFilter {
@ -62,8 +63,9 @@ public class JwtVerifyingFilter extends AccessControlFilter {
final String jwtClaims = jwt.substring(jwt.indexOf((" ")));
final Claims claims = Jwts
.parser()
.parserBuilder()
.setSigningKey(key)
.build()
.parseClaimsJws(jwtClaims)
.getBody();

View File

@ -18,13 +18,27 @@
*/
package org.libreccm.security;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* The {@code OneTimeAuthToken} is used as a one time authentication mechanism
* for several purposes. Usually a {@link OneTimeAuthToken} is used together

View File

@ -29,6 +29,7 @@ import java.io.Serializable;
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
*/
@Deprecated
@RequestScoped
public class PartyIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -1208121020457080214L;

View File

@ -55,7 +55,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* A permission grants a privilege on an object or system wide to {@link Role}.
* A permission grants a privilege on an object or system wide to a
* {@link Role}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -63,48 +64,40 @@ import javax.persistence.TemporalType;
@Table(name = "PERMISSIONS", schema = DB_SCHEMA)
@NamedQueries({
@NamedQuery(name = "Permission.findByUuid",
query = "SELECT p FROM Permission p WHERE p.uuid = :uuid")
,
query = "SELECT p FROM Permission p WHERE p.uuid = :uuid"),
@NamedQuery(name = "Permission.findByCustomPermId",
query = "SELECT p FROM Permission p "
+ "WHERE p.grantedPrivilege = :privilege "
+ "AND p.grantee = :grantee "
+ "AND p.object = :object")
,
+ "AND p.object = :object"),
@NamedQuery(name = "Permission.existsForPrivilegeRoleObject",
query = "SELECT COUNT(p) FROM Permission p "
+ "WHERE p.grantedPrivilege = :privilege "
+ "AND p.grantee = :grantee "
+ "AND p.object = :object")
,
+ "AND p.object = :object"),
@NamedQuery(name = "Permission.existsDirectForPrivilegeRoleObject",
query = "SELECT COUNT(p) FROM Permission p "
+ "WHERE p.grantedPrivilege = :privilege "
+ "AND p.grantee = :grantee "
+ "AND p.object = :object "
+ "AND p.inherited = false")
,
+ "AND p.inherited = false"),
@NamedQuery(name = "Permission.existsInheritedForPrivilegeRoleObject",
query = "SELECT COUNT(p) FROM Permission p "
+ "WHERE p.grantedPrivilege = :privilege "
+ "AND p.grantee = :grantee "
+ "AND p.object = :object "
+ "AND p.inherited = true")
,
+ "AND p.inherited = true"),
@NamedQuery(name = "Permission.existsForPrivilegeAndRole",
query = "SELECT COUNT(p) FROM Permission p "
+ "WHERE p.grantedPrivilege = :privilege "
+ "AND p.grantee = :grantee "
+ "AND p.object IS NULL")
,
+ "AND p.object IS NULL"),
@NamedQuery(name = "Permission.findPermissionsForRole",
query = "SELECT p FROM Permission p "
+ "WHERE p.grantee = :grantee")
,
+ "WHERE p.grantee = :grantee"),
@NamedQuery(name = "Permission.findPermissionsForCcmObject",
query = "SELECT p FROM Permission p "
+ "WHERE p.object = :object")
,
+ "WHERE p.object = :object"),
@NamedQuery(name = "Permission.findPermissionsForRoleAndObject",
query = "SELECT p FROM Permission p "
+ "WHERE p.object = :object and p.grantee = :grantee")

View File

@ -27,9 +27,10 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
*/
@Deprecated
@RequestScoped
public class PermissionIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -8397366681202009916L;

View File

@ -29,7 +29,8 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
*
* Exporter/Importer for {@link Permission}s.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -30,7 +30,7 @@ import java.util.UUID;
/**
* A repository class for {@link Permission}.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/29/17
*/
@RequestScoped

View File

@ -20,7 +20,11 @@ package org.libreccm.security;
import org.libreccm.core.CcmObject;
import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation is used together with the {@link AuthorizationRequired}

View File

@ -22,7 +22,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.search.annotations.Field;
import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.workflow.TaskAssignment;
@ -57,6 +56,7 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

View File

@ -26,9 +26,10 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
*/
@Deprecated
@RequestScoped
public class RoleIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -1651704701257277011L;

View File

@ -28,7 +28,8 @@ import java.util.Set;
import javax.inject.Inject;
/**
*
* Exporter/Importer for {@link Role}s.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Processes(Role.class)

View File

@ -37,8 +37,8 @@ import java.util.UUID;
import java.util.stream.Collectors;
/**
* Manager for roles providing methods for assigning the role the {@link Party}
* entities and for removing them.
* Manager for roles providing methods for assigning the role and adding and
* removing {@link Party} entities entities to the role and for removing them.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -30,7 +30,8 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
/**
*
* Exporter/Importer for {@link RoleMembership}s.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Processes(RoleMembership.class)

View File

@ -29,6 +29,7 @@ import java.io.Serializable;
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class UserIdResolver implements Serializable, ObjectIdResolver {

View File

@ -31,7 +31,8 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
/**
*
* Exporter/Importer for users.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -44,7 +44,6 @@ import java.io.Serializable;
/**
* Provides various operations for user objects.
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -42,7 +42,8 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
*
* Unstable! First try for a RESTful API for user management.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -34,7 +34,8 @@ import java.io.PrintWriter;
import java.util.Set;
/**
*
* Serves static theme resources from the classpath.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@WebServlet(urlPatterns = {"/themes/static/*"})

View File

@ -38,15 +38,15 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
*
* {@link ThemeProvider} implementation that loads themes from the file system
* using {@link CcmFiles}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -53,7 +53,9 @@ import javax.json.JsonObject;
import javax.json.JsonReader;
/**
*
* Implementation of {@link ThemeProvider} for serves themes stored in the
* classpath.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

View File

@ -19,7 +19,8 @@
package org.libreccm.theming;
/**
*
* Some constants for the classes managing themes.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class ThemeConstants {

View File

@ -36,7 +36,9 @@ import javax.ws.rs.core.Response;
/**
*
* JAX-RS endpoint for serving files from a theme.
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped

Some files were not shown because too many files have changed in this diff Show More