/** * Caches the given group under its id AND fully qualified name.<p> * * @param group the group to cache */ public void cacheGroup(CmsGroup group) { if (m_disabled.get(CacheType.GROUP) != null) { return; } m_cacheGroup.put(group.getId().toString(), group); m_cacheGroup.put(group.getName(), group); }
/** * Caches the given group under its id AND fully qualified name.<p> * * @param group the group to cache */ public void cacheGroup(CmsGroup group) { if (m_disabled.get(CacheType.GROUP) != null) { return; } m_cacheGroup.put(group.getId().toString(), group); m_cacheGroup.put(group.getName(), group); }
/** * Removes the given group from the cache.<p> * * The group is removed by name AND also by uuid.<p> * * @param group the group to remove from cache */ public void uncacheGroup(CmsGroup group) { m_cacheGroup.remove(group.getId().toString()); m_cacheGroup.remove(group.getName()); }
/** * Removes the given group from the cache.<p> * * The group is removed by name AND also by uuid.<p> * * @param group the group to remove from cache */ public void uncacheGroup(CmsGroup group) { m_cacheGroup.remove(group.getId().toString()); m_cacheGroup.remove(group.getName()); }
/** * Sets the manager Group name.<p> * * @param managerGroup the manager Group name to set */ public void setManagerGroup(String managerGroup) { CmsGroup group = checkGroup(managerGroup); if (group != null) { m_project.setManagerGroupId(group.getId()); } }
/** * Sets the user Group name.<p> * * @param userGroup the user Group name to set */ public void setUserGroup(String userGroup) { CmsGroup group = checkGroup(userGroup); if (group != null) { m_project.setGroupId(group.getId()); } }
/** * @see org.opencms.db.I_CmsProjectDriver#readProjectsForGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public List<CmsProject> readProjectsForGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { List<CmsProject> projects = new ArrayList<CmsProject>(); try { // create the statement Query q = m_sqlManager.createQuery(dbc, C_PROJECTS_READ_BYGROUP_2); q.setParameter(1, group.getId().toString()); q.setParameter(2, group.getId().toString()); List<CmsDAOProjects> res = q.getResultList(); for (CmsDAOProjects p : res) { projects.add(internalCreateProject(p)); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return (projects); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List getListItems() throws CmsException { List ret = new ArrayList(); // get content List groups = getGroups(); Iterator itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = (CmsGroup)itGroups.next(); CmsListItem item = getList().newItem(group.getId().toString()); item.set(LIST_COLUMN_NAME, group.getName()); ret.add(item); } return ret; }
/** * @see org.opencms.db.I_CmsProjectDriver#readProjectsForManagerGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public List<CmsProject> readProjectsForManagerGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { List<CmsProject> projects = new ArrayList<CmsProject>(); try { // create the statement Query q = m_sqlManager.createQuery(dbc, C_PROJECTS_READ_BYMANAGER_1); q.setParameter(1, group.getId().toString()); List<CmsDAOProjects> res = q.getResultList(); for (CmsDAOProjects p : res) { projects.add(internalCreateProject(p)); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return (projects); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); // get content List<CmsGroup> groups = getGroups(); Iterator<CmsGroup> itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = itGroups.next(); CmsListItem item = getList().newItem(group.getId().toString()); item.set(LIST_COLUMN_NAME, group.getName()); item.set(LIST_COLUMN_DISPLAY, OpenCms.getWorkplaceManager().translateGroupName(group.getName(), true)); ret.add(item); } return ret; }
/** * @see org.opencms.db.I_CmsUserDriver#readChildGroups(org.opencms.db.CmsDbContext, java.lang.String) */ public List<CmsGroup> readChildGroups(CmsDbContext dbc, String parentGroupFqn) throws CmsDataAccessException { List<CmsGroup> children = new ArrayList<CmsGroup>(); try { // get parent group CmsGroup parent = m_driverManager.getUserDriver(dbc).readGroup(dbc, parentGroupFqn); // parent group exists, so get all children if (parent != null) { // create statement Query q = m_sqlManager.createQuery(dbc, C_GROUPS_GET_CHILD_1); q.setParameter(1, parent.getId().toString()); List<CmsDAOGroups> res = q.getResultList(); // create new Cms group objects for (CmsDAOGroups g : res) { children.add(internalCreateGroup(g)); } } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return children; }
/** * @see org.opencms.db.I_CmsProjectDriver#readProjectsForManagerGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public List<CmsProject> readProjectsForManagerGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { List<CmsProject> projects = new ArrayList<CmsProject>(); ResultSet res = null; PreparedStatement stmt = null; Connection conn = null; try { // create the statement conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROJECTS_READ_BYMANAGER_1"); stmt.setString(1, group.getId().toString()); res = stmt.executeQuery(); while (res.next()) { projects.add(internalCreateProject(res)); } } 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, res); } return (projects); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); // get content List<CmsGroup> groups = getGroups(); Iterator<CmsGroup> itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = itGroups.next(); CmsListItem item = getList().newItem(group.getId().toString()); item.set(LIST_COLUMN_NAME, group.getName()); item.set(LIST_COLUMN_DISPLAY, OpenCms.getWorkplaceManager().translateGroupName(group.getName(), false)); item.set(LIST_COLUMN_DESCRIPTION, group.getDescription(getLocale())); ret.add(item); } return ret; }
/** * Saves an existing project.<p> */ private void saveProject() { CmsObject cms = A_CmsUI.getCmsObject(); try { m_project.setDescription(m_fieldDescription.getValue()); m_project.setGroupId(cms.readGroup(m_fieldUser.getValue()).getId()); m_project.setManagerGroupId(cms.readGroup(m_fieldManager.getValue()).getId()); m_project.setDeleteAfterPublishing(m_fieldDeleteAfterPublish.getValue().booleanValue()); cms.writeProject(m_project); updateProjectResources(); } catch (Throwable t) { CmsErrorDialog.showErrorDialog(t); } }
/** * Sets a new parent group for an already existing group.<p> * * @param dbc the current database context * @param groupName the name of the group that should be written * @param parentGroupName the name of the parent group to set, * or <code>null</code> if the parent * group should be deleted. * * @throws CmsException if operation was not successful * @throws CmsDataAccessException if the group with <code>groupName</code> could not be read from VFS */ public void setParentGroup(CmsDbContext dbc, String groupName, String parentGroupName) throws CmsException, CmsDataAccessException { CmsGroup group = readGroup(dbc, groupName); CmsUUID parentGroupId = CmsUUID.getNullUUID(); // if the group exists, use its id, else set to unknown. if (parentGroupName != null) { parentGroupId = readGroup(dbc, parentGroupName).getId(); } group.setParentId(parentGroupId); // write the changes to the cms writeGroup(dbc, group); }
/** * Sets a new parent group for an already existing group.<p> * * @param dbc the current database context * @param groupName the name of the group that should be written * @param parentGroupName the name of the parent group to set, * or <code>null</code> if the parent * group should be deleted. * * @throws CmsException if operation was not successful * @throws CmsDataAccessException if the group with <code>groupName</code> could not be read from VFS */ public void setParentGroup(CmsDbContext dbc, String groupName, String parentGroupName) throws CmsException, CmsDataAccessException { CmsGroup group = readGroup(dbc, groupName); CmsUUID parentGroupId = CmsUUID.getNullUUID(); // if the group exists, use its id, else set to unknown. if (parentGroupName != null) { parentGroupId = readGroup(dbc, parentGroupName).getId(); } group.setParentId(parentGroupId); // write the changes to the cms writeGroup(dbc, group); }
/** * @see org.opencms.db.I_CmsUserDriver#writeGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { PreparedStatement stmt = null; Connection conn = null; if (group != null) { try { conn = getSqlManager().getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_GROUPS_WRITE_GROUP_4"); stmt.setString(1, m_sqlManager.validateEmpty(group.getDescription())); stmt.setInt(2, group.getFlags()); stmt.setString(3, group.getParentId().toString()); stmt.setString(4, group.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); } } else { throw new CmsDbEntryNotFoundException( org.opencms.db.Messages.get().container(org.opencms.db.Messages.ERR_UNKNOWN_GROUP_1, "null")); } }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { CmsListItemDetails details = getList().getMetadata().getItemDetailDefinition(LIST_DETAIL_OTHEROU); boolean withOtherOus = hasGroupsInOtherOus() && (details != null) && details.isVisible(); List<CmsListItem> ret = new ArrayList<CmsListItem>(); // get content List<CmsGroup> groups = getGroups(withOtherOus); Iterator<CmsGroup> itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = itGroups.next(); CmsListItem item = getList().newItem(group.getId().toString()); item.set(LIST_COLUMN_NAME, group.getName()); item.set(LIST_COLUMN_DISPLAY, OpenCms.getWorkplaceManager().translateGroupName(group.getName(), false)); item.set(LIST_COLUMN_DESCRIPTION, group.getDescription(getLocale())); item.set(LIST_COLUMN_ORGUNIT, CmsOrganizationalUnit.SEPARATOR + group.getOuFqn()); ret.add(item); } return ret; }
/** * @see org.opencms.db.I_CmsUserDriver#writeGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { if (group != null) { try { Query q = m_sqlManager.createQuery(dbc, C_GROUPS_WRITE_GROUP_4); q.setParameter(1, group.getId().toString()); List<CmsDAOGroups> res = q.getResultList(); for (CmsDAOGroups g : res) { g.setGroupDescription(m_sqlManager.validateEmpty(group.getDescription())); g.setGroupFlags(group.getFlags()); g.setParentGroupId(group.getParentId().toString()); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } } else { throw new CmsDbEntryNotFoundException( org.opencms.db.Messages.get().container(org.opencms.db.Messages.ERR_UNKNOWN_GROUP_1, "null")); } }
/** * Creates the list of widgets for this dialog.<p> */ @Override protected void defineWidgets() { // initialize the user object to use for the dialog initGroupObject(); setKeyPrefix(KEY_PREFIX); // widgets to display if ((m_group.getId() == null) && isEditable(m_group)) { addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsInputWidget())); } else { addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsDisplayWidget())); } if (isEditable(m_group)) { addWidget(new CmsWidgetDialogParameter(this, "description", PAGES[0], new CmsTextareaWidget())); addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget())); addWidget(new CmsWidgetDialogParameter(m_group, "enabled", PAGES[0], new CmsCheckboxWidget())); } else { addWidget(new CmsWidgetDialogParameter(this, "description", PAGES[0], new CmsDisplayWidget())); addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget())); addWidget(new CmsWidgetDialogParameter(m_group, "enabled", PAGES[0], new CmsDisplayWidget())); } }