/** * Returns the image resources of the gallery folder which are edited in the dialog form. * * <p> * * @return the images of the gallery folder which are edited in the dialog form */ protected List getImages() { // get all image resources of the folder int imageId; try { imageId = OpenCms.getResourceManager() .getResourceType(CmsResourceTypeImage.getStaticTypeName()) .getTypeId(); } catch (CmsLoaderException e1) { // should really never happen LOG.warn(e1.getLocalizedMessage(), e1); imageId = CmsResourceTypeImage.getStaticTypeId(); } CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION.addRequireType(imageId); try { return getCms().readResources(getParamResource(), filter, false); } catch (CmsException e) { // log, should never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(getLocale())); } return new ArrayList(0); } }
/** * Internal action method. * * <p> * * @param req the current request * @return a map that contains the element settings */ public static Map<String, String> elementSettingTagAction(ServletRequest req) { CmsFlexController controller = CmsFlexController.getController(req); CmsObject cms = controller.getCmsObject(); // try to find element setting on the container element try { CmsContainerElementBean currentElement = OpenCms.getADEManager().getCurrentElement(req); currentElement.initResource(cms); return currentElement.getSettings(); } catch (CmsException e) { // most likely we are not in a container page LOG.debug(e.getLocalizedMessage(), e); return Collections.emptyMap(); } }
/** * 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; }
/** * Checks if the resource operation is an operation on at least one folder. * * <p> * * @return true if the operation an operation on at least one folder, otherwise false */ protected boolean isOperationOnFolder() { Iterator<String> i = getResourceList().iterator(); while (i.hasNext()) { String resName = i.next(); try { CmsResource curRes = getCms().readResource(resName, CmsResourceFilter.ALL); if (curRes.isFolder()) { // found a folder return true; } } catch (CmsException e) { // can usually be ignored if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage()); } } } return false; }
/** * Returns the HTML for the dialog input form to comment the images. * * <p> * * @return the HTML for the dialog input form to comment the images */ public String buildDialogForm() { StringBuffer result = new StringBuffer(16384); Iterator i = getImages().iterator(); result.append("<div style=\"height: 450px; padding: 4px; overflow: auto;\">"); while (i.hasNext()) { CmsResource res = (CmsResource) i.next(); String imageName = res.getName(); String propertySuffix = "" + imageName.hashCode(); result.append(dialogBlockStart(imageName)); result.append("<table border=\"0\">\n"); result.append("<tr>\n\t<td style=\"vertical-align: top;\">"); // create image tag result.append("<img src=\""); StringBuffer link = new StringBuffer(256); link.append(getCms().getSitePath(res)); link.append(getImageScaler().toRequestParam()); result.append(getJsp().link(link.toString())); result.append("\" border=\"0\" alt=\"\" width=\""); result.append(getImageScaler().getWidth()); result.append("\" height=\""); result.append(getImageScaler().getHeight()); result.append("\">"); result.append("</td>\n"); result.append("\t<td class=\"maxwidth\" style=\"vertical-align: top;\">\n"); result.append("\t\t<table border=\"0\">\n"); // build title property input row String title = ""; try { title = getCms() .readPropertyObject(res, CmsPropertyDefinition.PROPERTY_TITLE, false) .getValue(); } catch (CmsException e) { // log, should never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(getLocale())); } } result.append("\t\t<tr>\n\t\t\t<td style=\"white-space: nowrap;\" unselectable=\"on\">"); result.append(key(Messages.GUI_LABEL_TITLE_0)); result.append(":</td>\n\t\t\t<td class=\"maxwidth\">"); result.append("<input type=\"text\" class=\"maxwidth\" name=\""); result.append(PREFIX_TITLE); result.append(propertySuffix); result.append("\" value=\""); if (CmsStringUtil.isNotEmpty(title)) { result.append(CmsEncoder.escapeXml(title)); } result.append("\">"); result.append("</td>\n\t\t</tr>\n"); // build description property input row String description = ""; try { description = getCms() .readPropertyObject(res, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false) .getValue(); } catch (CmsException e) { // log, should never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(getLocale())); } } result.append( "\t\t<tr>\n\t\t\t<td style=\"white-space: nowrap; vertical-align: top;\" unselectable=\"on\">"); result.append(key(Messages.GUI_LABEL_DESCRIPTION_0)); result.append(":</td>\n\t\t\t<td style=\"vertical-align: top; height: 110px;\">"); result.append("<textarea rows=\"8\" class=\"maxwidth\" style=\"overflow: auto;\" name=\""); result.append(PREFIX_DESCRIPTION); result.append(propertySuffix); result.append("\">"); if (CmsStringUtil.isNotEmpty(description)) { result.append(CmsEncoder.escapeXml(description)); } result.append("</textarea>"); result.append("</td>\n\t\t</tr>\n"); result.append("\t\t</table>\n"); result.append("</td>\n</tr>\n"); result.append("</table>\n"); result.append(dialogBlockEnd()); if (i.hasNext()) { // append spacer if another entry follows result.append(dialogSpacer()); } } result.append("</div>"); return result.toString(); }
/** @see org.opencms.workplace.administration.A_CmsImportFromHttp#actionCommit() */ public void actionCommit() throws IOException, ServletException { try { copyFileToServer( OpenCms.getSystemInfo().getPackagesRfsPath() + File.separator + CmsSystemInfo.FOLDER_MODULES); } catch (CmsException e) { // error copying the file to the OpenCms server if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(getLocale()), e); } setException(e); return; } /// copied CmsConfigurationException exception = null; CmsModule module = null; try { String importpath = OpenCms.getSystemInfo().getPackagesRfsPath(); importpath = OpenCms.getSystemInfo() .getAbsoluteRfsPathRelativeToWebInf(importpath + "modules/" + getParamImportfile()); module = CmsModuleImportExportHandler.readModuleFromImport(importpath); // check if all dependencies are fulfilled List dependencies = OpenCms.getModuleManager() .checkDependencies(module, CmsModuleManager.DEPENDENCY_MODE_IMPORT); if (!dependencies.isEmpty()) { StringBuffer dep = new StringBuffer(32); for (int i = 0; i < dependencies.size(); i++) { CmsModuleDependency dependency = (CmsModuleDependency) dependencies.get(i); dep.append("\n - "); dep.append(dependency.getName()); dep.append(" (Version: "); dep.append(dependency.getVersion()); dep.append(")"); } exception = new CmsConfigurationException( Messages.get() .container( Messages.ERR_ACTION_MODULE_DEPENDENCY_2, getParamImportfile(), new String(dep))); } } catch (CmsConfigurationException e) { exception = e; } if ((module != null) && (exception == null)) { // refresh the list Map objects = (Map) getSettings().getListObject(); if (objects != null) { objects.remove(CmsModulesList.class.getName()); } // redirect Map param = new HashMap(); param.put(CmsModulesList.PARAM_MODULE, getParamImportfile()); param.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW); param.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(getJsp(), "/modules")); if (OpenCms.getModuleManager().hasModule(module.getName())) { param.put(CmsModulesUploadFromServer.PARAM_MODULENAME, module.getName()); getToolManager() .jspForwardPage(this, CmsModulesUploadFromServer.REPLACE_ACTION_REPORT, param); } else { getToolManager() .jspForwardPage(this, CmsModulesUploadFromServer.IMPORT_ACTION_REPORT, param); } } else { if (exception != null) { // log it if (LOG.isErrorEnabled()) { LOG.error(exception.getLocalizedMessage(getLocale()), exception); } // then throw to avoid blank page telling nothing due to missing forward throw new CmsRuntimeException(exception.getMessageContainer(), exception); } } }