CCM NG: Only small things (better JAXB bindings)
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4192 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
167ca2f9eb
commit
aa1aeef686
|
|
@ -130,7 +130,7 @@ public class Category extends CcmObject implements InheritsPermissions,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}
|
@JoinColumn(name = "OBJECT_ID")}
|
||||||
))
|
))
|
||||||
@XmlElementWrapper(name = "title", namespace = CAT_XML_NS)
|
@XmlElement(name = "title", namespace = CAT_XML_NS)
|
||||||
private LocalizedString title;
|
private LocalizedString title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -144,7 +144,7 @@ public class Category extends CcmObject implements InheritsPermissions,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}
|
@JoinColumn(name = "OBJECT_ID")}
|
||||||
))
|
))
|
||||||
@XmlElementWrapper(name = "title", namespace = CAT_XML_NS)
|
@XmlElement(name = "description", namespace = CAT_XML_NS)
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -183,6 +183,7 @@ public class Category extends CcmObject implements InheritsPermissions,
|
||||||
*/
|
*/
|
||||||
@OneToMany(mappedBy = "parentCategory")
|
@OneToMany(mappedBy = "parentCategory")
|
||||||
@XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS)
|
@XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS)
|
||||||
|
@XmlElement(name = "category")
|
||||||
private List<Category> subCategories;
|
private List<Category> subCategories;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,14 @@ import com.arsdigita.ui.login.LoginApplicationCreator;
|
||||||
import com.arsdigita.ui.login.LoginServlet;
|
import com.arsdigita.ui.login.LoginServlet;
|
||||||
import com.arsdigita.ui.login.LoginApplicationSetup;
|
import com.arsdigita.ui.login.LoginApplicationSetup;
|
||||||
import com.arsdigita.ui.login.LoginConstants;
|
import com.arsdigita.ui.login.LoginConstants;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.xml.bind.JAXB;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.libreccm.categorization.Domain;
|
||||||
|
|
||||||
import org.libreccm.modules.CcmModule;
|
import org.libreccm.modules.CcmModule;
|
||||||
import org.libreccm.modules.InitEvent;
|
import org.libreccm.modules.InitEvent;
|
||||||
|
|
@ -68,24 +76,47 @@ import org.libreccm.web.ApplicationType;
|
||||||
com.arsdigita.xml.formatters.DateFormatterConfig.class,
|
com.arsdigita.xml.formatters.DateFormatterConfig.class,
|
||||||
org.libreccm.configuration.ExampleConfiguration.class,
|
org.libreccm.configuration.ExampleConfiguration.class,
|
||||||
org.libreccm.security.EmailTemplates.class,
|
org.libreccm.security.EmailTemplates.class,
|
||||||
org.libreccm.security.OneTimeAuthConfig.class,
|
org.libreccm.security.OneTimeAuthConfig.class,})
|
||||||
})
|
|
||||||
public class CcmCore implements CcmModule {
|
public class CcmCore implements CcmModule {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(CcmCore.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void install(final InstallEvent event) {
|
public void install(final InstallEvent event) {
|
||||||
|
LOGGER.info("Setting up system users...");
|
||||||
final SystemUsersSetup systemUsersSetup = new SystemUsersSetup(
|
final SystemUsersSetup systemUsersSetup = new SystemUsersSetup(
|
||||||
event);
|
event);
|
||||||
systemUsersSetup.setupSystemUsers();
|
systemUsersSetup.setupSystemUsers();
|
||||||
|
|
||||||
|
LOGGER.info("Setting up admin application (/ccm/admin/)...");
|
||||||
final AdminApplicationSetup adminSetup
|
final AdminApplicationSetup adminSetup
|
||||||
= new AdminApplicationSetup(event);
|
= new AdminApplicationSetup(event);
|
||||||
adminSetup.setup();
|
adminSetup.setup();
|
||||||
|
|
||||||
|
LOGGER.info("Setting up login application...");
|
||||||
final LoginApplicationSetup loginSetup
|
final LoginApplicationSetup loginSetup
|
||||||
= new LoginApplicationSetup(event);
|
= new LoginApplicationSetup(event);
|
||||||
loginSetup.setup();
|
loginSetup.setup();
|
||||||
|
|
||||||
|
LOGGER.info("Importing category domains from bundle (if any)...");
|
||||||
|
final Properties integrationProps = new Properties();
|
||||||
|
try (final InputStream inputStream = getClass().getResourceAsStream(
|
||||||
|
CoreConstants.INTEGRATION_PROPS)) {
|
||||||
|
if (inputStream == null) {
|
||||||
|
LOGGER.warn("Integration properties file was not found.");
|
||||||
|
} else {
|
||||||
|
integrationProps.load(inputStream);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.warn("Failed to read integration properties. "
|
||||||
|
+ "Using empty proeprties.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (integrationProps.containsKey("bundle.domains")) {
|
||||||
|
importDomains(integrationProps.getProperty("bundle.domains"),
|
||||||
|
event.getEntityManager());
|
||||||
|
}
|
||||||
|
|
||||||
// Load category domains from bundle/classpath
|
// Load category domains from bundle/classpath
|
||||||
// File format: JAXB (but Jackson for reading the XML)
|
// File format: JAXB (but Jackson for reading the XML)
|
||||||
}
|
}
|
||||||
|
|
@ -104,4 +135,32 @@ public class CcmCore implements CcmModule {
|
||||||
//Nothing
|
//Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void importDomains(final String domainFiles,
|
||||||
|
final EntityManager entityManager) {
|
||||||
|
final String[] tokens = domainFiles.split(",");
|
||||||
|
|
||||||
|
for (final String token : tokens) {
|
||||||
|
importDomain(token, entityManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importDomain(final String domainFile,
|
||||||
|
final EntityManager entityManager) {
|
||||||
|
// ToDo Will be implemented when general importer is ready
|
||||||
|
// LOGGER.info("Importing category domain from {}...", domainFile);
|
||||||
|
// try (final InputStream inputStream = getClass().getResourceAsStream(
|
||||||
|
// domainFile)) {
|
||||||
|
// if (inputStream == null) {
|
||||||
|
// LOGGER.warn("Category domain file {} was not found. Ignoring.",
|
||||||
|
// domainFile);
|
||||||
|
// } else {
|
||||||
|
// final Domain domain = JAXB.unmarshal(inputStream, Domain.class);
|
||||||
|
// entityManager.persist(domain);
|
||||||
|
// }
|
||||||
|
// } catch (IOException ex) {
|
||||||
|
// LOGGER.warn("Failed to load category domain file {}. "
|
||||||
|
// + "Domain will not be imported.",
|
||||||
|
// domainFile);
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
@ -68,6 +70,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
+ "WHERE p.object = :object")
|
+ "WHERE p.object = :object")
|
||||||
})
|
})
|
||||||
@XmlRootElement(name = "permission", namespace = CORE_XML_NS)
|
@XmlRootElement(name = "permission", namespace = CORE_XML_NS)
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Permission implements Serializable {
|
public class Permission implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5178045844045517958L;
|
private static final long serialVersionUID = -5178045844045517958L;
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
@ -82,6 +84,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
})
|
})
|
||||||
@DefaultEntityGraph(Role.ENTITY_GRPAH_WITH_MEMBERS)
|
@DefaultEntityGraph(Role.ENTITY_GRPAH_WITH_MEMBERS)
|
||||||
@XmlRootElement(name = "role", namespace = CORE_XML_NS)
|
@XmlRootElement(name = "role", namespace = CORE_XML_NS)
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@SuppressWarnings({"PMD.ShortClassName", "PMD.TooManyMethods"})
|
@SuppressWarnings({"PMD.ShortClassName", "PMD.TooManyMethods"})
|
||||||
public class Role implements Serializable {
|
public class Role implements Serializable {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ import javax.persistence.NamedSubgraph;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
@ -119,6 +121,7 @@ import javax.xml.bind.annotation.XmlTransient;
|
||||||
})
|
})
|
||||||
@DefaultEntityGraph("User.withGroupAndRoleMemberships")
|
@DefaultEntityGraph("User.withGroupAndRoleMemberships")
|
||||||
@XmlRootElement(name = "user", namespace = CORE_XML_NS)
|
@XmlRootElement(name = "user", namespace = CORE_XML_NS)
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
//Supressing a few warnings from PMD because they misleading here.
|
//Supressing a few warnings from PMD because they misleading here.
|
||||||
//User is perfectly fine class name, and the complexity is not to high...
|
//User is perfectly fine class name, and the complexity is not to high...
|
||||||
@SuppressWarnings({"PMD.ShortClassName", "PMD.LongVariable"})
|
@SuppressWarnings({"PMD.ShortClassName", "PMD.LongVariable"})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue