Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.
/*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
*
* 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.
*
* For further information about Alkacon Software, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.db.jpa;
import org.opencms.configuration.CmsConfigurationManager;
import org.opencms.configuration.CmsParameterConfiguration;
import org.opencms.db.CmsDbContext;
import org.opencms.db.CmsDbEntryNotFoundException;
import org.opencms.db.CmsDbIoException;
import org.opencms.db.CmsDbSqlException;
import org.opencms.db.CmsDriverManager;
import org.opencms.db.CmsPublishList;
import org.opencms.db.CmsPublishedResource;
import org.opencms.db.CmsResourceState;
import org.opencms.db.CmsVisitEntryFilter;
import org.opencms.db.I_CmsDriver;
import org.opencms.db.I_CmsHistoryDriver;
import org.opencms.db.I_CmsProjectDriver;
import org.opencms.db.I_CmsVfsDriver;
import org.opencms.db.generic.Messages;
import org.opencms.db.jpa.persistence.CmsDAOLog;
import org.opencms.db.jpa.persistence.CmsDAOOfflineResources;
import org.opencms.db.jpa.persistence.CmsDAOOfflineStructure;
import org.opencms.db.jpa.persistence.CmsDAOProjectResources;
import org.opencms.db.jpa.persistence.CmsDAOProjectResources.CmsDAOProjectResourcesPK;
import org.opencms.db.jpa.persistence.CmsDAOProjects;
import org.opencms.db.jpa.persistence.CmsDAOPublishHistory;
import org.opencms.db.jpa.persistence.CmsDAOPublishJobs;
import org.opencms.db.jpa.persistence.CmsDAOResourceLocks;
import org.opencms.db.jpa.persistence.CmsDAOStaticExportLinks;
import org.opencms.db.jpa.persistence.CmsDAOUserPublishListEntry;
import org.opencms.db.jpa.utils.CmsQueryIntParameter;
import org.opencms.db.jpa.utils.CmsQueryLongParameter;
import org.opencms.db.jpa.utils.CmsQueryStringParameter;
import org.opencms.db.jpa.utils.I_CmsQueryParameter;
import org.opencms.db.log.CmsLogEntry;
import org.opencms.db.log.CmsLogEntryType;
import org.opencms.db.log.CmsLogFilter;
import org.opencms.db.userpublishlist.CmsUserPublishListEntry;
import org.opencms.file.CmsDataAccessException;
import org.opencms.file.CmsFile;
import org.opencms.file.CmsFolder;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsProperty;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.CmsUser;
import org.opencms.file.CmsVfsResourceAlreadyExistsException;
import org.opencms.file.CmsVfsResourceNotFoundException;
import org.opencms.file.history.CmsHistoryFile;
import org.opencms.file.types.CmsResourceTypeFolder;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.lock.CmsLock;
import org.opencms.lock.CmsLockType;
import org.opencms.main.CmsEvent;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.I_CmsEventListener;
import org.opencms.main.OpenCms;
import org.opencms.publish.CmsPublishJobInfoBean;
import org.opencms.relations.CmsRelationFilter;
import org.opencms.report.I_CmsReport;
import org.opencms.security.CmsOrganizationalUnit;
import org.opencms.security.I_CmsPrincipal;
import org.opencms.staticexport.CmsStaticExportManager;
import org.opencms.util.CmsDataTypeUtil;
import org.opencms.util.CmsPair;
import org.opencms.util.CmsStringUtil;
import org.opencms.util.CmsUUID;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import org.apache.commons.logging.Log;
import com.google.common.collect.Sets;
/**
* JPA database server implementation of the project driver methods.
*
* @since 8.0.0
*/
public class CmsProjectDriver implements I_CmsDriver, I_CmsProjectDriver {
/** Attribute name for reading the project of a resource. */
public static final String DBC_ATTR_READ_PROJECT_FOR_RESOURCE = "DBC_ATTR_READ_PROJECT_FOR_RESOURCE";
/** Query key. */
private static final String C_DELETE_PUBLISH_HISTORY = "C_DELETE_PUBLISH_HISTORY";
/** Query key. */
private static final String C_LOG_DELETE_ENTRIES = "C_LOG_DELETE_ENTRIES";
/** Query key. */
private static final String C_LOG_FILTER_DATE_FROM = "C_LOG_FILTER_DATE_FROM";
/** Query key. */
private static final String C_LOG_FILTER_DATE_TO = "C_LOG_FILTER_DATE_TO";
/** Query key. */
private static final String C_LOG_FILTER_EXCLUDE_TYPE = "C_LOG_FILTER_EXCLUDE_TYPE";
/** Query key. */
private static final String C_LOG_FILTER_INCLUDE_TYPE = "C_LOG_FILTER_INCLUDE_TYPE";
/** Query key. */
private static final String C_LOG_FILTER_RESOURCE_ID = "C_LOG_FILTER_RESOURCE_ID";
/** Query key. */
private static final String C_LOG_FILTER_USER_ID = "C_LOG_FILTER_USER_ID";
/** Query key. */
private static final String C_LOG_READ_ENTRIES = "C_LOG_READ_ENTRIES";
/** Query key. */
private static final String C_PROJECTRESOURCES_DELETEALL_1 = "C_PROJECTRESOURCES_DELETEALL_1";
/** Query key. */
private static final String C_PROJECTRESOURCES_READ_2 = "C_PROJECTRESOURCES_READ_2";
/** Query key. */
private static final String C_PROJECTRESOURCES_READ_BY_ID_1 = "C_PROJECTRESOURCES_READ_BY_ID_1";
/** Query key. */
private static final String C_PROJECTS_READ_1 = "C_PROJECTS_READ_1";
/** Query key. */
private static final String C_PROJECTS_READ_BYGROUP_2 = "C_PROJECTS_READ_BYGROUP_2";
/** Query key. */
private static final String C_PROJECTS_READ_BYMANAGER_1 = "C_PROJECTS_READ_BYMANAGER_1";
/** Query key. */
private static final String C_PROJECTS_READ_BYNAME_2 = "C_PROJECTS_READ_BYNAME_2";
/** Query key. */
private static final String C_PROJECTS_READ_BYOU_1 = "C_PROJECTS_READ_BYOU_1";
/** Query key. */
private static final String C_PROJECTS_READ_BYRESOURCE_1 = "C_PROJECTS_READ_BYRESOURCE_1";
/** Query key. */
private static final String C_PROJECTS_READ_BYUSER_1 = "C_PROJECTS_READ_BYUSER_1";
/** Query key. */
private static final String C_PROJECTS_WRITE_6 = "C_PROJECTS_WRITE_6";
/** Query key. */
private static final String C_PUBLISHJOB_DELETE_PUBLISHLIST = "C_PUBLISHJOB_DELETE_PUBLISHLIST";
/** Query key. */
private static final String C_PUBLISHJOB_READ_JOB = "C_PUBLISHJOB_READ_JOB";
/** Query key. */
private static final String C_PUBLISHJOB_READ_JOBS_IN_TIMERANGE = "C_PUBLISHJOB_READ_JOBS_IN_TIMERANGE";
/** Query key. */
private static final String C_PUBLISHJOB_READ_PUBLISHLIST = "C_PUBLISHJOB_READ_PUBLISHLIST";
/** Query key. */
private static final String C_PUBLISHJOB_READ_REPORT = "C_PUBLISHJOB_READ_REPORT";
/** Query key. */
private static final String C_RESOURCE_LOCKS_DELETEALL = "C_RESOURCE_LOCKS_DELETEALL";
/** Query key. */
private static final String C_RESOURCE_LOCKS_READALL = "C_RESOURCE_LOCKS_READALL";
/** Query key. */
private static final String C_RESOURCES_DELETE_PUBLISH_HISTORY_ENTRY = "C_RESOURCES_DELETE_PUBLISH_HISTORY_ENTRY";
/** Query key. */
private static final String C_RESOURCES_UNMARK = "C_RESOURCES_UNMARK";
/** Query key. */
private static final String C_SELECT_PUBLISHED_RESOURCES = "C_SELECT_PUBLISHED_RESOURCES";
/** Query key. */
private static final String C_STATICEXPORT_DELETE_ALL_PUBLISHED_LINKS = "C_STATICEXPORT_DELETE_ALL_PUBLISHED_LINKS";
/** Query key. */
private static final String C_STATICEXPORT_DELETE_PUBLISHED_LINKS = "C_STATICEXPORT_DELETE_PUBLISHED_LINKS";
/** Query key. */
private static final String C_STATICEXPORT_READ_ALL_PUBLISHED_LINKS = "C_STATICEXPORT_READ_ALL_PUBLISHED_LINKS";
/** Query key. */
private static final String C_STATICEXPORT_READ_PUBLISHED_LINK_PARAMETERS = "C_STATICEXPORT_READ_PUBLISHED_LINK_PARAMETERS";
/** Query key. */
private static final String C_STATICEXPORT_READ_PUBLISHED_RESOURCES = "C_STATICEXPORT_READ_PUBLISHED_RESOURCES";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(org.opencms.db.jpa.CmsProjectDriver.class);
/** The driver manager. */
protected CmsDriverManager m_driverManager;
/** The SQL manager. */
protected CmsSqlManager m_sqlManager;
/**
* @see org.opencms.db.I_CmsProjectDriver#createProject(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.file.CmsUser, org.opencms.file.CmsGroup, org.opencms.file.CmsGroup, java.lang.String, java.lang.String, int, CmsProject.CmsProjectType)
*/
public CmsProject createProject(
CmsDbContext dbc,
CmsUUID id,
CmsUser owner,
CmsGroup group,
CmsGroup managergroup,
String projectFqn,
String description,
int flags,
CmsProject.CmsProjectType type) throws CmsDataAccessException {
CmsProject project = null;
if ((description == null) || (description.length() < 1)) {
description = " ";
}
try {
CmsDAOProjects p = new CmsDAOProjects();
p.setProjectId(id.toString());
p.setUserId(owner.getId().toString());
p.setGroupId(group.getId().toString());
p.setManagerGroupId(managergroup.getId().toString());
p.setProjectName(CmsOrganizationalUnit.getSimpleName(projectFqn));
p.setProjectDescription(description);
p.setProjectFlags(flags);
p.setProjectType(type.getMode());
p.setProjectOu(CmsOrganizationalUnit.SEPARATOR + CmsOrganizationalUnit.getParentFqn(projectFqn));
synchronized (this) {
long createTime = System.currentTimeMillis();
p.setDateCreated(createTime);
m_sqlManager.persist(dbc, p);
try {
// this is an ugly hack, but for MySQL (and maybe other DBs as well)
// there is a UNIQUE INDEX constraint on the project name+createTime
// so theoretically if 2 projects with the same name are created very fast, this
// SQL restraint would be violated if we don't wait here
Thread.sleep(50);
} catch (InterruptedException e) {
// continue
}
project = new CmsProject(
id,
projectFqn,
description,
owner.getId(),
group.getId(),
managergroup.getId(),
flags,
createTime,
type);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
return project;
}
/**
* @see org.opencms.db.I_CmsProjectDriver#createProjectResource(org.opencms.db.CmsDbContext, CmsUUID, java.lang.String)
*/
public void createProjectResource(CmsDbContext dbc, CmsUUID projectId, String resourcePath)
throws CmsDataAccessException {
// do not create entries for online-project
boolean projectResourceExists = false;
try {
readProjectResource(dbc, projectId, resourcePath);
projectResourceExists = true;
} catch (CmsVfsResourceNotFoundException e) {
// resource does not exist yet, everything is okay
projectResourceExists = false;
}
if (projectResourceExists) {
throw new CmsVfsResourceAlreadyExistsException(
Messages.get().container(
Messages.ERR_RESOURCE_WITH_NAME_ALREADY_EXISTS_1,
dbc.removeSiteRoot(resourcePath)));
}
try {
CmsDAOProjectResources pr = new CmsDAOProjectResources();
pr.setProjectId(projectId.toString());
pr.setResourcePath(resourcePath);
m_sqlManager.persist(dbc, pr);
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#createPublishJob(org.opencms.db.CmsDbContext, org.opencms.publish.CmsPublishJobInfoBean)
*/
public void createPublishJob(CmsDbContext dbc, CmsPublishJobInfoBean publishJob) throws CmsDataAccessException {
try {
CmsPublishJobInfoBean currentJob = readPublishJob(dbc, publishJob.getPublishHistoryId());
LOG.error("wanted to write: " + publishJob);
LOG.error("already on db: " + currentJob);
return;
} catch (CmsDbEntryNotFoundException e) {
// ok, this is the expected behavior
}
try {
CmsDAOPublishJobs pj = new CmsDAOPublishJobs();
pj.setHistoryId(publishJob.getPublishHistoryId().toString());
pj.setProjectId(publishJob.getProjectId().toString());
pj.setProjectName(publishJob.getProjectName());
pj.setUserId(publishJob.getUserId().toString());
pj.setPublishLocale(publishJob.getLocale().toString());
pj.setPublishFlags(publishJob.getFlags());
pj.setResourceCount(publishJob.getSize());
pj.setEnqueueTime(publishJob.getEnqueueTime());
pj.setStartTime(publishJob.getStartTime());
pj.setFinishTime(publishJob.getFinishTime());
byte[] publishList = internalSerializePublishList(publishJob.getPublishList());
pj.setPublishList(publishList);
m_sqlManager.persist(dbc, pj);
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
} catch (IOException e) {
throw new CmsDbIoException(
Messages.get().container(
Messages.ERR_SERIALIZING_PUBLISHLIST_1,
publishJob.getPublishHistoryId().toString()),
e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteAllStaticExportPublishedResources(org.opencms.db.CmsDbContext, int)
*/
public void deleteAllStaticExportPublishedResources(CmsDbContext dbc, int linkType) throws CmsDataAccessException {
try {
Query q = m_sqlManager.createQuery(dbc, C_STATICEXPORT_DELETE_ALL_PUBLISHED_LINKS);
q.setParameter(1, Integer.valueOf(linkType));
List res = q.getResultList();
for (CmsDAOStaticExportLinks sel : res) {
m_sqlManager.remove(dbc, sel);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteLog(org.opencms.db.CmsDbContext, org.opencms.db.log.CmsLogFilter)
*/
public void deleteLog(CmsDbContext dbc, CmsLogFilter filter) throws CmsDataAccessException {
try {
StringBuffer queryBuf = new StringBuffer(256);
queryBuf.append(m_sqlManager.readQuery(C_LOG_DELETE_ENTRIES));
CmsPair> conditionsAndParams = prepareLogConditions(filter);
queryBuf.append(conditionsAndParams.getFirst());
if (LOG.isDebugEnabled()) {
LOG.debug(queryBuf.toString());
}
Query q = m_sqlManager.createQueryFromJPQL(dbc, queryBuf.toString());
List params = conditionsAndParams.getSecond();
for (int i = 0; i < params.size(); i++) {
I_CmsQueryParameter param = conditionsAndParams.getSecond().get(i);
param.insertIntoQuery(q, i + 1);
}
// execute
q.executeUpdate();
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteProject(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject)
*/
public void deleteProject(CmsDbContext dbc, CmsProject project) throws CmsDataAccessException {
// delete the resources from project_resources
deleteProjectResources(dbc, project);
// remove the project id form all resources within their project
unmarkProjectResources(dbc, project);
// finally delete the project
try {
CmsDAOProjects p = m_sqlManager.find(dbc, CmsDAOProjects.class, project.getUuid().toString());
if (p != null) {
m_sqlManager.remove(dbc, p);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteProjectResource(org.opencms.db.CmsDbContext, CmsUUID, java.lang.String)
*/
public void deleteProjectResource(CmsDbContext dbc, CmsUUID projectId, String resourceName)
throws CmsDataAccessException {
try {
CmsDAOProjectResourcesPK pk = new CmsDAOProjectResourcesPK();
pk.setProjectId(projectId.toString());
pk.setResourcePath(resourceName);
CmsDAOProjectResources pr = m_sqlManager.find(dbc, CmsDAOProjectResources.class, pk);
if (pr != null) {
m_sqlManager.remove(dbc, pr);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteProjectResources(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject)
*/
public void deleteProjectResources(CmsDbContext dbc, CmsProject project) throws CmsDataAccessException {
try {
Query q = m_sqlManager.createQuery(dbc, C_PROJECTRESOURCES_DELETEALL_1);
q.setParameter(1, project.getUuid().toString());
List res = q.getResultList();
for (CmsDAOProjectResources pr : res) {
m_sqlManager.remove(dbc, pr);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deletePublishHistory(org.opencms.db.CmsDbContext, CmsUUID, int)
*/
public void deletePublishHistory(CmsDbContext dbc, CmsUUID projectId, int maxpublishTag)
throws CmsDataAccessException {
try {
Query q = m_sqlManager.createQuery(dbc, projectId, C_DELETE_PUBLISH_HISTORY);
q.setParameter(1, Integer.valueOf(maxpublishTag));
List res = q.getResultList();
for (CmsDAOPublishHistory ph : res) {
m_sqlManager.remove(dbc, ph);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deletePublishHistoryEntry(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, org.opencms.db.CmsPublishedResource)
*/
public void deletePublishHistoryEntry(
CmsDbContext dbc,
CmsUUID publishHistoryId,
CmsPublishedResource publishedResource) throws CmsDataAccessException {
try {
Query q = m_sqlManager.createQuery(dbc, C_RESOURCES_DELETE_PUBLISH_HISTORY_ENTRY);
q.setParameter(1, publishHistoryId.toString());
q.setParameter(2, Integer.valueOf(publishedResource.getPublishTag()));
q.setParameter(3, publishedResource.getStructureId().toString());
q.setParameter(4, publishedResource.getRootPath());
List res = q.getResultList();
for (CmsDAOPublishHistory ph : res) {
m_sqlManager.remove(dbc, ph);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deletePublishJob(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID)
*/
public void deletePublishJob(CmsDbContext dbc, CmsUUID publishHistoryId) throws CmsDataAccessException {
try {
CmsDAOPublishJobs pj = m_sqlManager.find(dbc, CmsDAOPublishJobs.class, publishHistoryId.toString());
if (pj != null) {
m_sqlManager.remove(dbc, pj);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deletePublishList(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID)
*/
public void deletePublishList(CmsDbContext dbc, CmsUUID publishHistoryId) throws CmsDataAccessException {
try {
Query q = m_sqlManager.createQuery(dbc, C_PUBLISHJOB_DELETE_PUBLISHLIST);
q.setParameter(1, publishHistoryId.toString());
List res = q.getResultList();
for (CmsDAOPublishJobs pj : res) {
pj.setPublishList(null);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteStaticExportPublishedResource(org.opencms.db.CmsDbContext, java.lang.String, int, java.lang.String)
*/
public void deleteStaticExportPublishedResource(
CmsDbContext dbc,
String resourceName,
int linkType,
String linkParameter) throws CmsDataAccessException {
try {
Query q = m_sqlManager.createQuery(dbc, C_STATICEXPORT_DELETE_PUBLISHED_LINKS);
q.setParameter(1, resourceName);
q.setParameter(2, Integer.valueOf(linkType));
q.setParameter(3, linkParameter);
List res = q.getResultList();
for (CmsDAOStaticExportLinks sel : res) {
m_sqlManager.remove(dbc, sel);
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#deleteUserPublishListEntries(org.opencms.db.CmsDbContext, java.util.List)
*/
public void deleteUserPublishListEntries(CmsDbContext dbc, List publishListDeletions)
throws CmsDataAccessException {
try {
for (CmsUserPublishListEntry entry : publishListDeletions) {
Query q = m_sqlManager.createQuery(dbc, "C_USER_PUBLISH_LIST_DELETE_2");
q.setParameter(1, entry.getUserId().toString());
q.setParameter(2, entry.getStructureId().toString());
q.executeUpdate();
}
} catch (PersistenceException e) {
throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e);
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#destroy()
*/
public void destroy() throws Throwable {
m_sqlManager = null;
m_driverManager = null;
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_DRIVER_1, getClass().getName()));
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#fillDefaults(org.opencms.db.CmsDbContext)
*/
public void fillDefaults(CmsDbContext dbc) throws CmsDataAccessException {
try {
if (readProject(dbc, CmsProject.ONLINE_PROJECT_ID) != null) {
// online-project exists - no need of filling defaults
return;
}
} catch (CmsDataAccessException exc) {
// ignore the exception - the project was not readable so fill in the defaults
}
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_FILL_DEFAULTS_0));
}
String adminUser = OpenCms.getDefaultUsers().getUserAdmin();
CmsUser admin = m_driverManager.readUser(dbc, adminUser);
String administratorsGroup = OpenCms.getDefaultUsers().getGroupAdministrators();
CmsGroup administrators = m_driverManager.readGroup(dbc, administratorsGroup);
String usersGroup = OpenCms.getDefaultUsers().getGroupUsers();
CmsGroup users = m_driverManager.readGroup(dbc, usersGroup);
////////////////////////////////////////////////////////////////////////////////////////////
// online project stuff
////////////////////////////////////////////////////////////////////////////////////////////
// create the online project
CmsProject onlineProject = createProject(
dbc,
CmsProject.ONLINE_PROJECT_ID,
admin,
users,
administrators,
CmsProject.ONLINE_PROJECT_NAME,
"The Online project",
I_CmsPrincipal.FLAG_ENABLED,
CmsProject.PROJECT_TYPE_NORMAL);
// create the root-folder for the online project
CmsFolder rootFolder = new CmsFolder(
new CmsUUID(),
new CmsUUID(),
"/",
CmsResourceTypeFolder.RESOURCE_TYPE_ID,
0,
onlineProject.getUuid(),
CmsResource.STATE_CHANGED,
0,
admin.getId(),
0,
admin.getId(),
CmsResource.DATE_RELEASED_DEFAULT,
CmsResource.DATE_EXPIRED_DEFAULT,
0);
m_driverManager.getVfsDriver(dbc).createResource(dbc, onlineProject.getUuid(), rootFolder, null);
// important: must access through driver manager to ensure proper cascading
m_driverManager.getProjectDriver(dbc).createProjectResource(
dbc,
onlineProject.getUuid(),
rootFolder.getRootPath());
// create the system-folder for the online project
CmsFolder systemFolder = new CmsFolder(
new CmsUUID(),
new CmsUUID(),
"/system",
CmsResourceTypeFolder.RESOURCE_TYPE_ID,
0,
onlineProject.getUuid(),
CmsResource.STATE_CHANGED,
0,
admin.getId(),
0,
admin.getId(),
CmsResource.DATE_RELEASED_DEFAULT,
CmsResource.DATE_EXPIRED_DEFAULT,
0);
m_driverManager.getVfsDriver(dbc).createResource(dbc, onlineProject.getUuid(), systemFolder, null);
////////////////////////////////////////////////////////////////////////////////////////////
// setup project stuff
////////////////////////////////////////////////////////////////////////////////////////////
// important: must access through driver manager to ensure proper cascading
CmsProject setupProject = m_driverManager.getProjectDriver(dbc).createProject(
dbc,
CmsUUID.getConstantUUID(SETUP_PROJECT_NAME),
admin,
administrators,
administrators,
SETUP_PROJECT_NAME,
"The Project for the initial import",
I_CmsPrincipal.FLAG_ENABLED,
CmsProject.PROJECT_TYPE_TEMPORARY);
rootFolder.setState(CmsResource.STATE_CHANGED);
// create the root-folder for the offline project
CmsResource offlineRootFolder = m_driverManager.getVfsDriver(dbc).createResource(
dbc,
setupProject.getUuid(),
rootFolder,
null);
offlineRootFolder.setState(CmsResource.STATE_UNCHANGED);
m_driverManager.getVfsDriver(dbc).writeResource(
dbc,
setupProject.getUuid(),
offlineRootFolder,
CmsDriverManager.NOTHING_CHANGED);
// important: must access through driver manager to ensure proper cascading
m_driverManager.getProjectDriver(dbc).createProjectResource(
dbc,
setupProject.getUuid(),
offlineRootFolder.getRootPath());
systemFolder.setState(CmsResource.STATE_CHANGED);
// create the system-folder for the offline project
CmsResource offlineSystemFolder = m_driverManager.getVfsDriver(dbc).createResource(
dbc,
setupProject.getUuid(),
systemFolder,
null);
offlineSystemFolder.setState(CmsResource.STATE_UNCHANGED);
m_driverManager.getVfsDriver(dbc).writeResource(
dbc,
setupProject.getUuid(),
offlineSystemFolder,
CmsDriverManager.NOTHING_CHANGED);
}
/**
* @see org.opencms.db.I_CmsProjectDriver#getSqlManager()
*/
public CmsSqlManager getSqlManager() {
return m_sqlManager;
}
/**
* @see org.opencms.db.I_CmsProjectDriver#getUsersPubList(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID)
*/
public List getUsersPubList(CmsDbContext dbc, CmsUUID userId) throws CmsDataAccessException {
List result = new ArrayList();
try {
Query q = m_sqlManager.createQuery(dbc, "C_USER_PUBLISH_LIST_READ_1");
q.setParameter(1, userId.toString());
List