/** * @see org.opencms.main.CmsException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable) */ @Override public CmsException createException(CmsMessageContainer container, Throwable cause) { return new CmsDbConsistencyException(container, cause); } }
/** * @see org.opencms.main.CmsException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable) */ @Override public CmsException createException(CmsMessageContainer container, Throwable cause) { return new CmsDbConsistencyException(container, cause); } }
throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3, resource.getRootPath(),
break; default: throw new CmsDbConsistencyException( Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3, break; default: throw new CmsDbConsistencyException( Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3,
/** * Moves an user to the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to move the user to * @param user the user that is to be moved to the organizational unit * * @throws CmsException if something goes wrong * * @see org.opencms.security.CmsOrgUnitManager#setUsersOrganizationalUnit(CmsObject, String, String) */ public void setUsersOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsUser user) throws CmsException { if (!getGroupsOfUser(dbc, user.getName(), false).isEmpty()) { throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_ORGUNIT_MOVE_USER_2, orgUnit.getName(), user.getName())); } // move the principal m_userDriver.setUsersOrganizationalUnit(dbc, orgUnit, user); // remove the principal from cache m_monitor.clearUserCache(user); // fire user modified event Map eventData = new HashMap(); eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString()); eventData.put(I_CmsEventListener.KEY_OU_NAME, user.getOuFqn()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_SET_OU); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData)); }
throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName()));
throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName()));
throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName()));
throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName()));
throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_TOO_MANY_PROPERTIES_3, key, property.setResourceValue(propertyValue); } else { throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3, resource.getRootPath(),
throw new CmsDbConsistencyException( Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3,
/** * Returns the count of properties for a property definition.<p> * * @param dbc the current database context * @param propertyDefinition the property definition to test * @param projectId the ID of the current project * * @return the amount of properties for a property definition * @throws CmsDataAccessException if something goes wrong */ protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition propertyDefinition, CmsUUID projectId) throws CmsDataAccessException { int count = 0; try { // create statement Query q = m_sqlManager.createQuery(dbc, projectId, C_PROPERTIES_READALL_COUNT); q.setParameter(1, propertyDefinition.getId().toString()); try { count = CmsDataTypeUtil.numberToInt((Number)q.getSingleResult()); } catch (NoResultException e) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName())); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return count; }
/** * Returns the amount of properties for a propertydefinition.<p> * * @param dbc the current database context * @param metadef the propertydefinition to test * @param projectId the ID of the current project * * @return the amount of properties for a propertydefinition * @throws CmsDataAccessException if something goes wrong */ protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition metadef, CmsUUID projectId) throws CmsDataAccessException { int returnValue; try { // create statement Query q = m_sqlManager.createQuery(dbc, projectId, C_PROPERTIES_READALL_COUNT); q.setParameter(1, metadef.getId().toString()); try { returnValue = CmsDataTypeUtil.numberToInt((Number)q.getSingleResult()); } catch (NoResultException e) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName())); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return returnValue; }
throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ORGUNIT_MOVE_USER_2, orgUnit.getName(), user.getName()));
throw new CmsDbConsistencyException( Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3,
throw new CmsDbConsistencyException( Messages.get().container( Messages.ERR_TOO_MANY_PROPERTIES_3, property.setResourceValue(propertyValue); } else { throw new CmsDbConsistencyException( Messages.get().container( Messages.ERR_UNKNOWN_PROPERTY_VALUE_MAPPING_3,
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition Query q = m_sqlManager.createQuery(dbc, C_PROPERTYDEF_DELETE_HISTORY); q.setParameter(1, metadef.getId().toString()); @SuppressWarnings("unchecked") List<CmsDAOHistoryPropertyDef> res = q.getResultList(); for (CmsDAOHistoryPropertyDef hpd : res) { m_sqlManager.remove(dbc, hpd); } } catch (PersistenceException e) { throw new CmsDataAccessException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, Messages.ERR_JPA_PERSITENCE_1), e); } }
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTYDEF_DELETE_HISTORY"); stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } }
throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_COUNTING_VISITED_RESOURCES_1, user.getName()));
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTYDEF_DELETE_HISTORY"); stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException(Messages.get().container( Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } }