/** * Returns the resource for the given item. * * <p> * * @param cms the cms object * @param item the item * @return the resource */ public CmsResource getResource(CmsObject cms, CmsListItem item) { CmsResource res = m_resCache.get(item.getId()); if (res == null) { CmsUUID id = new CmsUUID(item.getId()); if (!id.isNullUUID()) { try { res = cms.readResource(id, CmsResourceFilter.ALL); m_resCache.put(item.getId(), res); } catch (CmsException e) { // should never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } } } return res; }
/** * Returns a dummy list item. * * <p> * * @param list the list object to create the entry for * @return a dummy list item */ protected CmsListItem getDummyListItem(CmsHtmlList list) { CmsListItem item = list.newItem(CmsUUID.getNullUUID().toString()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_NAME, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_TITLE, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_TYPE, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_SIZE, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_PERMISSIONS, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATELASTMOD, new Date()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_USERLASTMOD, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATECREATE, new Date()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_USERCREATE, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATEREL, new Date()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATEEXP, new Date()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_STATE, ""); item.set(A_CmsListExplorerDialog.LIST_COLUMN_LOCKEDBY, ""); return item; }
/** * Returns a list item created from the resource information, differs between valid resources and * invalid resources. * * <p> * * @param resource the resource to create the list item from * @param list the list * @param showPermissions if to show permissions * @param showDateLastMod if to show the last modification date * @param showUserLastMod if to show the last modification user * @param showDateCreate if to show the creation date * @param showUserCreate if to show the creation date * @param showDateRel if to show the date released * @param showDateExp if to show the date expired * @param showState if to show the state * @param showLockedBy if to show the lock user * @param showSite if to show the site * @return a list item created from the resource information */ protected CmsListItem createResourceListItem( CmsResource resource, CmsHtmlList list, boolean showPermissions, boolean showDateLastMod, boolean showUserLastMod, boolean showDateCreate, boolean showUserCreate, boolean showDateRel, boolean showDateExp, boolean showState, boolean showLockedBy, boolean showSite) { CmsListItem item = list.newItem(resource.getStructureId().toString()); // get an initialized resource utility CmsResourceUtil resUtil = getWp().getResourceUtil(); resUtil.setResource(resource); item.set(A_CmsListExplorerDialog.LIST_COLUMN_NAME, resUtil.getPath()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_ROOT_PATH, resUtil.getFullPath()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_TITLE, resUtil.getTitle()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_TYPE, resUtil.getResourceTypeName()); item.set(A_CmsListExplorerDialog.LIST_COLUMN_SIZE, resUtil.getSizeString()); if (showPermissions) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_PERMISSIONS, resUtil.getPermissionString()); } if (showDateLastMod) { item.set( A_CmsListExplorerDialog.LIST_COLUMN_DATELASTMOD, new Date(resource.getDateLastModified())); } if (showUserLastMod) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_USERLASTMOD, resUtil.getUserLastModified()); } if (showDateCreate) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATECREATE, new Date(resource.getDateCreated())); } if (showUserCreate) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_USERCREATE, resUtil.getUserCreated()); } if (showDateRel) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATEREL, new Date(resource.getDateReleased())); } if (showDateExp) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_DATEEXP, new Date(resource.getDateExpired())); } if (showState) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_STATE, resUtil.getStateName()); } if (showLockedBy) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_LOCKEDBY, resUtil.getLockedByName()); } if (showSite) { item.set(A_CmsListExplorerDialog.LIST_COLUMN_SITE, resUtil.getSiteTitle()); } setAdditionalColumns(item, resUtil); return item; }