List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:org.gss_project.gss.server.rest.Webdav.java
/** * Propfind helper method.//from www .ja va2 s. c o m * * @param req The servlet request * @param resources Resources object associated with this context * @param generatedXML XML response to the Propfind request * @param path Path of the current resource * @param type Propfind type * @param propertiesVector If the propfind type is find properties by name, * then this Vector contains those properties * @param resource the resource object */ private void parseProperties(HttpServletRequest req, XMLWriter generatedXML, String path, int type, Vector<String> propertiesVector, Object resource) { // Exclude any resource in the /WEB-INF and /META-INF subdirectories // (the "toUpperCase()" avoids problems on Windows systems) if (path.toUpperCase().startsWith("/WEB-INF") || path.toUpperCase().startsWith("/META-INF")) return; Folder folderLocal = null; FileHeader fileLocal = null; if (resource instanceof Folder) folderLocal = (Folder) resource; else fileLocal = (FileHeader) resource; // Retrieve the creation date. long creation = 0; if (folderLocal != null) creation = folderLocal.getAuditInfo().getCreationDate().getTime(); else creation = fileLocal.getAuditInfo().getCreationDate().getTime(); // Retrieve the modification date. long modification = 0; if (folderLocal != null) modification = folderLocal.getAuditInfo().getCreationDate().getTime(); else modification = fileLocal.getAuditInfo().getCreationDate().getTime(); generatedXML.writeElement(null, "D:response", XMLWriter.OPENING); String status = new String( "HTTP/1.1 " + WebdavStatus.SC_OK + " " + WebdavStatus.getStatusText(WebdavStatus.SC_OK)); // Generating href element generatedXML.writeElement(null, "D:href", XMLWriter.OPENING); String href = req.getContextPath() + req.getServletPath(); if (href.endsWith("/") && path.startsWith("/")) href += path.substring(1); else href += path; if (folderLocal != null && !href.endsWith("/")) href += "/"; generatedXML.writeText(rewriteUrl(href)); generatedXML.writeElement(null, "D:href", XMLWriter.CLOSING); String resourceName = path; int lastSlash = path.lastIndexOf('/'); if (lastSlash != -1) resourceName = resourceName.substring(lastSlash + 1); if (resourceName.isEmpty()) resourceName = "/"; switch (type) { case FIND_ALL_PROP: generatedXML.writeElement(null, "D:propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "D:prop", XMLWriter.OPENING); generatedXML.writeProperty(null, "D:creationdate", getISOCreationDate(creation)); generatedXML.writeElement(null, "D:displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement(null, "D:displayname", XMLWriter.CLOSING); if (fileLocal != null) { generatedXML.writeProperty(null, "D:getlastmodified", FastHttpDateFormat.formatDate(modification, null)); generatedXML.writeProperty(null, "D:getcontentlength", String.valueOf(fileLocal.getCurrentBody().getFileSize())); String contentType = fileLocal.getCurrentBody().getMimeType(); if (contentType != null) generatedXML.writeProperty(null, "D:getcontenttype", contentType); generatedXML.writeProperty(null, "D:getetag", getETag(fileLocal, null)); generatedXML.writeElement(null, "D:resourcetype", XMLWriter.NO_CONTENT); } else { generatedXML.writeElement(null, "D:resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "D:collection", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:resourcetype", XMLWriter.CLOSING); } generatedXML.writeProperty(null, "D:source", ""); String supportedLocks = "<D:lockentry>" + "<D:lockscope><D:exclusive/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>" + "<D:lockentry>" + "<D:lockscope><D:shared/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>"; generatedXML.writeElement(null, "D:supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement(null, "D:supportedlock", XMLWriter.CLOSING); generateLockDiscovery(path, generatedXML); generatedXML.writeElement(null, "D:prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "D:status", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:propstat", XMLWriter.CLOSING); break; case FIND_PROPERTY_NAMES: generatedXML.writeElement(null, "D:propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "D:prop", XMLWriter.OPENING); generatedXML.writeElement(null, "D:creationdate", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:displayname", XMLWriter.NO_CONTENT); if (fileLocal != null) { generatedXML.writeElement(null, "D:getcontentlanguage", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:getcontentlength", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:getcontenttype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:getetag", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:getlastmodified", XMLWriter.NO_CONTENT); } generatedXML.writeElement(null, "D:resourcetype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:source", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:lockdiscovery", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "D:status", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:propstat", XMLWriter.CLOSING); break; case FIND_BY_PROPERTY: Vector<String> propertiesNotFound = new Vector<String>(); // Parse the list of properties generatedXML.writeElement(null, "D:propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "D:prop", XMLWriter.OPENING); Enumeration<String> properties = propertiesVector.elements(); while (properties.hasMoreElements()) { String property = properties.nextElement(); if (property.equals("D:creationdate")) generatedXML.writeProperty(null, "D:creationdate", getISOCreationDate(creation)); else if (property.equals("D:displayname")) { generatedXML.writeElement(null, "D:displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement(null, "D:displayname", XMLWriter.CLOSING); } else if (property.equals("D:getcontentlanguage")) { if (folderLocal != null) propertiesNotFound.addElement(property); else generatedXML.writeElement(null, "D:getcontentlanguage", XMLWriter.NO_CONTENT); } else if (property.equals("D:getcontentlength")) { if (folderLocal != null) propertiesNotFound.addElement(property); else generatedXML.writeProperty(null, "D:getcontentlength", String.valueOf(fileLocal.getCurrentBody().getFileSize())); } else if (property.equals("D:getcontenttype")) { if (folderLocal != null) propertiesNotFound.addElement(property); else // XXX Once we properly store the MIME type in the // file, // retrieve it from there. generatedXML.writeProperty(null, "D:getcontenttype", getServletContext().getMimeType(fileLocal.getName())); } else if (property.equals("D:getetag")) { if (folderLocal != null) propertiesNotFound.addElement(property); else generatedXML.writeProperty(null, "D:getetag", getETag(fileLocal, null)); } else if (property.equals("D:getlastmodified")) { if (folderLocal != null) propertiesNotFound.addElement(property); else generatedXML.writeProperty(null, "D:getlastmodified", FastHttpDateFormat.formatDate(modification, null)); } else if (property.equals("D:resourcetype")) { if (folderLocal != null) { generatedXML.writeElement(null, "D:resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "D:collection", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:resourcetype", XMLWriter.CLOSING); } else generatedXML.writeElement(null, "D:resourcetype", XMLWriter.NO_CONTENT); } else if (property.equals("D:source")) generatedXML.writeProperty(null, "D:source", ""); else if (property.equals("D:supportedlock")) { supportedLocks = "<D:lockentry>" + "<D:lockscope><D:exclusive/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>" + "<D:lockentry>" + "<D:lockscope><D:shared/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>"; generatedXML.writeElement(null, "D:supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement(null, "D:supportedlock", XMLWriter.CLOSING); } else if (property.equals("D:lockdiscovery")) { if (!generateLockDiscovery(path, generatedXML)) propertiesNotFound.addElement(property); } else propertiesNotFound.addElement(property); } generatedXML.writeElement(null, "D:prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "D:status", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:propstat", XMLWriter.CLOSING); Enumeration propertiesNotFoundList = propertiesNotFound.elements(); if (propertiesNotFoundList.hasMoreElements()) { status = new String("HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND + " " + WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND)); generatedXML.writeElement(null, "D:propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "D:prop", XMLWriter.OPENING); while (propertiesNotFoundList.hasMoreElements()) generatedXML.writeElement(null, (String) propertiesNotFoundList.nextElement(), XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "D:prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "D:status", XMLWriter.CLOSING); generatedXML.writeElement(null, "D:propstat", XMLWriter.CLOSING); } break; } generatedXML.writeElement(null, "D:response", XMLWriter.CLOSING); }
From source file:sos.settings.SOSSettingsDialog.java
/** * Alle Applikationen anzeigen/*from ww w .j a va 2 s . c om*/ * * @param applicationsTitle * Titel * @param applications * Werte (siehe getDialogApplications) * @return boolean Fehlerzustand * @throws Exception * @see #showDialogApplications(String, Vector) */ private boolean showDialogApplications(String applicationsTitle, Vector applications) throws Exception { this.debug(3, "showDialogApplications : applicationsTitle = " + applicationsTitle + " applications = " + applications); if (applicationsTitle != null) { this.dialogApplicationsTitle = applicationsTitle; } if (applications != null) { this.dialogApplications = applications; } if (this.dialogApplications == null) { this.dialogApplications = new Vector(); } if (this.dialogApplications.size() == 0) { if (this.error() == false) { this.setError(this.rb.getMessage("sos.settings.dialog.err_not_found_apps"), SOSClassUtil.getMethodName()); } } this.showTableBegin(); this.showNavigation(new Integer(1), null, null, null); try { this.getTopLevelRights(); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); this.showTableEnd(); return false; } if (!this.hasTopLevelReadRight && !this.hasTopLevelCreateRight) { this.showTableEnd(); return false; } // JS Code fir's Help schreiben this.openHelpWin(); //$normalize_field_name = $this->normalize_field_name; String imgLink = "<img src=\"" + this.imgDir + this.imgAction + "\" border=\"0\" hspace=\"4\" vspace=\"1\">"; String thisCon = (this.site.indexOf('?') != -1) ? "&" : "?"; String querySession = "?"; if (!this.sessionUseTransSID && !this.sessionVAR.equals("")) { querySession = thisCon + this.sessionVAR + "=" + this.sessionID + "&"; } else { querySession = thisCon; } if (this.enableApplicationManager == true && this.hasTopLevelCreateRight) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); String link = "<a class=\"" + this.styleLinkNavigation + "\" href=\"" + this.site + querySession + "action=new&range=application\">"; this.out.println(" <td class=\"" + this.styleTd + "\">"); if (this.hasCreateRight == true) { this.out.println(link + imgLink + this.dialogApplicationsNewTitle + "</a>"); } this.out.println(" </td>"); this.out.println(" </tr>"); } String sqlHelp = " select \"APPLICATION\",\"SECTION\", \"NAME\" "; sqlHelp += " from " + this.settings.source + " s "; sqlHelp += " where s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entrySection + "\" and "; sqlHelp += " s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entryName + "\" and "; sqlHelp += " s.\"DOCUMENTATION\" is not null "; Hashtable helpTexts = new Hashtable(); try { Vector helpText = this.connection.getArrayAsVector(sqlHelp); if (helpText.size() > 0) { for (Enumeration el = helpText.elements(); el.hasMoreElements();) { HashMap hm = (HashMap) el.nextElement(); helpTexts.put(hm.get("application").toString() + hm.get("section").toString() + hm.get("name").toString(), "Help"); } this.hasHelps = true; } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } try { for (Enumeration el = this.dialogApplications.elements(); el.hasMoreElements();) { HashMap application = (HashMap) el.nextElement(); String linkSections = "<a href=\"" + this.site + querySession + "action=show&range=sections&application=" + this.response .encodeURL(application.get(this.settings.entryApplication.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type") + "\">"; String linkApplication = ""; if (this.enableApplicationManager == true) { linkApplication = "<a href=\"" + this.site + querySession + "action=show&range=application&application=" + this.response.encodeURL( application.get(this.settings.entryApplication.toLowerCase()).toString()) + "\">"; } else { linkApplication = linkSections; } String k = application.get(this.settings.entryApplication.toLowerCase()).toString() + application.get(this.settings.entrySection.toLowerCase()).toString() + application.get(this.settings.entryName.toLowerCase()).toString(); String linkHelp = " "; if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response.encodeURL( application.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response .encodeURL(application.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response .encodeURL(application.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } try { this.getRights(application.get("application").toString(), null, null); if (this.hasReadRight == false && this.hasCreateRight == false) { continue; } } catch (Exception e) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td class=\"" + this.styleTd + "\" width=\"50%\">"); this.out.println(" " + application.get(this.settings.entrySettingTitle.toLowerCase())); this.out.println(" </td>"); this.out.print(" <td>"); this.showError("ACL : " + e.getMessage()); this.out.println("</td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); this.out.println(" </tr>"); continue; } this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td class=\"" + this.styleTd + "\" width=\"50%\">"); this.out.println(linkApplication + imgLink + "</a>" + linkSections + application.get(this.settings.entrySettingTitle.toLowerCase()) + "</a>"); this.out.println(" </td>"); this.out.println(" <td>" + linkHelp + "</td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); this.out.println(" </tr>"); } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } this.showActions(new Integer(1), null, null, null); this.showTableEnd(); return true; }
From source file:sos.settings.SOSSettingsDialog.java
/** * Alle Sektionen einer Applikation anzeigen * /* w w w . ja v a 2s. c om*/ * @param sectionsTitle * Titel * @param sections * Werte (siehe getDialogSections) * @return boolean Fehlerzustand * @throws Exception * @see #showDialogSections(String, Vector) */ private boolean showDialogSections(String sectionsTitle, Vector sections) throws Exception { this.debug(3, "showDialogSections : sectionsTitle = " + sectionsTitle + " sections = " + sections); if (sectionsTitle != null) { this.dialogSectionsTitle = sectionsTitle; } if (sections != null) { this.dialogSections = sections; } if (this.dialogSections == null) { this.dialogSections = new Vector(); } if (this.dialogSections.size() == 0) { if (this.error() == false) { this.setError(this.rb.getMessage("sos.settings.dialog.err_not_found_sections"), SOSClassUtil.getMethodName()); } } String imgLink = "<img src=\"" + this.imgDir + this.imgAction + "\" border=\"0\" hspace=\"4\" vspace=\"1\">"; String thisCon = (this.site.indexOf('?') != -1) ? "&" : "?"; String querySession = "?"; if (!this.sessionUseTransSID && !this.sessionVAR.equals("")) { querySession = thisCon + this.sessionVAR + "=" + this.sessionID + "&"; } else { querySession = thisCon; } this.showTableBegin(); this.showNavigation(new Integer(1), this.dialogApplicationIndex, null, null); this.aclRange = "application"; try { this.getRights(this.settings.application, null, null); } catch (Exception e) { this.setError("ACL : " + e.getMessage(), SOSClassUtil.getMethodName()); } // JS Code fir's Help schreiben this.openHelpWin(); String link = ""; if (this.dialogApplicationIndex.intValue() >= 0 && this.enableSectionManager == true) { if (this.applicationType == 1) { // Schema if (this.hasReadRight == true || this.hasWriteRight == true || this.hasCreateRight == true) { this.out.println("<tr class=\"" + this.styleTr + "\">"); link = "<a class=\"" + this.styleLinkNavigation + "\" href=\"" + this.site + querySession + "action=new&range=section&application=" + this.response.encodeURL(this.settings.application) + "&application_type=" + this.applicationType + "\">"; this.out.println(" <td class=\"" + this.styleTd + "\">" + link + imgLink + this.dialogSectionsNewTitle + "</a></td>"); this.out.println(" </tr>"); } } else { if (this.hasCreateRight == true) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); link = "<a class=\"" + this.styleLinkNavigation + "\" href=\"" + this.site + querySession + "action=new&range=section&application=" + this.response.encodeURL(this.settings.application) + "&application_type=" + this.applicationType + "\">"; this.out.println(" <td class=\"" + this.styleTd + "\">" + link + imgLink + this.dialogSectionsNewTitle + "</a></td>"); this.out.println(" </tr>"); } } } String sqlHelp = " select \"APPLICATION\",\"SECTION\", \"NAME\" "; sqlHelp += " from " + this.settings.source + " s "; sqlHelp += " where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "; sqlHelp += " s.\"" + this.settings.entryApplication + "\" <> s.\"" + this.settings.entrySection + "\" and "; sqlHelp += " s.\"" + this.settings.entrySection + "\" = s.\"" + this.settings.entryName + "\" and "; sqlHelp += " s.\"DOCUMENTATION\" is not null "; Hashtable helpTexts = new Hashtable(); try { Vector helpText = this.connection.getArrayAsVector(sqlHelp); if (helpText.size() > 0) { for (Enumeration el = helpText.elements(); el.hasMoreElements();) { HashMap hm = (HashMap) el.nextElement(); helpTexts.put(hm.get("application").toString() + hm.get("section").toString() + hm.get("name").toString(), "Help"); } this.hasHelps = true; } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } for (Enumeration el = this.dialogSections.elements(); el.hasMoreElements();) { HashMap section = (HashMap) el.nextElement(); String linkHelp = " "; String linkEntries = ""; String linkSection = ""; boolean hasRights = true; boolean isSchema = false; if (section.get("name").toString().equals(this.settings.entrySchemaSection)) { isSchema = true; if (this.hasCreateRight == true) { // Schema bearbeiten linkEntries = "<a class=\"" + this.styleLinkNavigation + "\" href=\"" + this.site + querySession + "action=show&range=entries&application=" + this.response.encodeURL(this.settings.application) + "§ion=" + this.response .encodeURL(section.get(this.settings.entrySection.toLowerCase()).toString()) + "&application_type=" + this.applicationType + "§ion_type=" + section.get("entry_type").toString() + "\">"; linkSection = linkEntries; } else { hasRights = false; } } else { String k = this.settings.application + section.get(this.settings.entrySection.toLowerCase()).toString() + section.get(this.settings.entrySection.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response.encodeURL(this.settings.application) + "§ion=" + this.response .encodeURL(section.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response .encodeURL(section.get(this.settings.entrySection.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } linkEntries = "<a href=\"" + this.site + querySession + "action=show&range=entries&application=" + this.response.encodeURL(this.settings.application) + "§ion=" + this.response.encodeURL(section.get(this.settings.entrySection.toLowerCase()).toString()) + "&application_type=" + this.applicationType + "§ion_type=" + section.get("entry_type").toString() + "\">"; linkSection = (this.enableSectionManager == true) ? "<a href=\"" + this.site + querySession + "action=show&range=section&application=" + this.response.encodeURL(this.settings.application) + "§ion=" + this.response.encodeURL( section.get(this.settings.entrySection.toLowerCase()).toString()) + "\">" : linkEntries; } this.aclRange = "section"; try { this.getRights(section.get("application").toString(), section.get("section").toString(), null); if (this.hasReadRight == false && this.hasCreateRight == false) { continue; } } catch (Exception e) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td class=\"" + this.styleTd + "\" width=\"50%\">"); this.out.println(" " + section.get(this.settings.entrySettingTitle.toLowerCase()).toString()); this.out.println(" </td>"); this.out.println(" <td>"); this.showError("ACL : " + e.getMessage()); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); this.out.println(" </tr>"); continue; } if (hasRights) { String sectionTitle = (isSchema) ? this.rb.getMessage("sos.settings.dialog.dialog_sections_schema_title") : section.get(this.settings.entrySettingTitle.toLowerCase()).toString(); this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td class=\"" + this.styleTd + "\" width=\"50%\">"); this.out.println(" " + linkSection + imgLink + "</a>" + linkEntries + sectionTitle + "</a>"); this.out.println(" </td>"); this.out.println(" <td>" + linkHelp + "</td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); this.out.println(" </tr>"); } } // enumeration this.showActions(new Integer(1), this.dialogApplicationIndex, null, null); this.showTableEnd(); return true; }
From source file:sos.settings.SOSSettingsDialog.java
/** * Dokumentation anzeigen/*w ww. j a va 2 s . co m*/ * * @throws Exception */ private void showHelps() throws Exception { this.debug(3, "showHelps"); String orderBy = ""; if (this.documentationSort != null && !this.documentationSort.equals("")) { orderBy = " order by " + this.documentationSort; } String applicationsTitle = this.rb.getMessage("sos.settings.dialog.label_all_apps_title"); String sectionsTitle = " "; StringBuffer sql = new StringBuffer(); sql.append( " select s.\"APPLICATION\", s.\"SECTION\", s.\"NAME\", s.\"VALUE\",s.\"DEFAULT_VALUE\",s.\"TITLE\", s.\"INPUT_TYPE\",s.\"INPUT_SIZE\",s.\"DISPLAY_TYPE\",s.\"DISPLAY_SIZE\", s.\"ENTRY_TYPE\", s.\"FORCED\" "); sql.append(" from " + this.settings.source + " s "); StringBuffer appSql = new StringBuffer(); appSql.append(" select s.\"TITLE\" "); appSql.append(" from " + this.settings.source + " s "); String section = ""; String function = ""; if (this.item.equalsIgnoreCase("application")) { sql.append(" where s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entrySection + "\" and "); sql.append(" s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entryName + "\" "); sql.append(orderBy); function = "application"; } else if (this.item.equalsIgnoreCase("section")) { sql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sql.append(" s.\"" + this.settings.entryApplication + "\" <> s.\"" + this.settings.entrySection + "\" and "); sql.append(" s.\"" + this.settings.entrySection + "\" = s.\"" + this.settings.entryName + "\" "); sql.append(orderBy); appSql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); appSql.append(" s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entrySection + "\" and "); appSql.append(" s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entryName + "\" "); try { applicationsTitle = this.connection.getSingleValue(appSql.toString()); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } function = "section"; } else if (this.item.equalsIgnoreCase("entry")) { section = this.settings.section; if (this.settings.section.equals(this.settings.entrySchemaSection)) { section = this.settings.entrySchemaSection; } else { this.setDialogSections(); if (this.dialogSections != null && this.dialogSections.size() != 0) { HashMap hs = (HashMap) this.dialogSections.firstElement(); if (hs.containsKey("section")) { if (hs.get("section").toString().equals(this.settings.entrySchemaSection)) { section = this.settings.entrySchemaSection; } } } } sql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" = " + this.dbQuoted(section) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" "); sql.append(orderBy); appSql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); appSql.append(" s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entrySection + "\" and "); appSql.append(" s.\"" + this.settings.entryApplication + "\" = s.\"" + this.settings.entryName + "\" "); try { applicationsTitle = this.connection.getSingleValue(appSql.toString()); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } StringBuffer secSql = new StringBuffer(); secSql.append(" select s.\"TITLE\" "); secSql.append(" from " + this.settings.source + " s "); secSql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); secSql.append( " s.\"" + this.settings.entrySection + "\" = " + this.dbQuoted(section) + " and "); secSql.append(" s.\"" + this.settings.entrySection + "\" = s.\"" + this.settings.entryName + "\" "); try { sectionsTitle = this.connection.getSingleValue(secSql.toString()); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } function = "entry"; } Vector items = null; try { items = this.connection.getArrayAsVector(sql.toString()); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); return; } if (items != null) { for (Enumeration el = items.elements(); el.hasMoreElements();) { HashMap item = (HashMap) el.nextElement(); byte[] documentation = null; try { documentation = this.connection.getBlob("select \"DOCUMENTATION\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(item.get("application").toString()) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(item.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(item.get("name").toString()) + " "); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); return; } if (documentation != null) { item.put("documentation", new String(documentation)); } else { item.put("documentation", ""); } if (item.get("documentation").equals("")) { item.put("documentation", " "); } if (item.get("value").equals("")) { item.put("value", " "); } if (item.get("default_value").equals("")) { item.put("default_value", " "); } if (item.get("input_type").equals("")) { item.put("input_type", " "); } if (item.get("input_size").equals("")) { item.put("input_size", " "); } if (item.get("display_type").equals("")) { item.put("display_type", " "); } if (item.get("display_size").equals("")) { item.put("display_size", " "); } if (item.get("entry_type").equals("")) { item.put("entry_type", " "); } if (item.get("forced").equals("")) { item.put("forced", " "); } item.put("application_title", applicationsTitle); item.put("section_title", sectionsTitle); //kein schema /* * if (!item.get("section").toString().equals( * this.settings.entrySchemaSection) && * !item.get("name").toString().equals( * this.settings.entrySchemaSection)) { */ if (function.equals("application")) { this.docuApplication(item); } else if (function.equals("section")) { this.docuSection(item); } else if (function.equals("entry")) { this.docuEntry(item); } //} } } }
From source file:sos.settings.SOSSettingsDialog.java
/** * Dokumentation anzeigen/* w w w .ja va2s . c o m*/ * * @throws Exception */ private void showDocumentation() throws Exception { this.debug(3, "showDocumentation"); StringBuffer sqlStmt = new StringBuffer( "select \"TITLE\",\"APPLICATION\",\"SECTION\",\"NAME\",\"VALUE\",\"DISPLAY_TYPE\",\"INPUT_TYPE\" from " + this.settings.source); String sqlAnd = " where "; String[] display_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_display_type_entries") .split(";"); String[] input_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_input_type_entries") .split(";"); if (this.settings.section.equals(this.settings.entrySchemaSection)) { this.settings.section = this.settings.entrySchemaSection; } if (!this.settings.application.equals("")) { sqlStmt.append(sqlAnd + " \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application)); sqlAnd = " and "; } if (!this.settings.section.equals("")) { sqlStmt.append( sqlAnd + " \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section)); sqlAnd = " and "; } sqlStmt.append(" order by \"" + this.settings.entryApplication + "\",\"" + this.settings.entrySection + "\",\"" + this.settings.entryName + "\""); try { Vector results = this.connection.getArrayAsVector(sqlStmt.toString()); LinkedHashMap applications = new LinkedHashMap(); LinkedHashMap sections = new LinkedHashMap(); LinkedHashMap entries = new LinkedHashMap(); for (Enumeration el = results.elements(); el.hasMoreElements();) { HashMap result = (HashMap) el.nextElement(); if (result.get("application").toString().equals(result.get("section").toString()) && result.get("application").toString().equals(result.get("name").toString())) { applications.put(result.get("application").toString(), result); } else if (result.get("section").toString().equals(result.get("name").toString()) && !result.get("section").toString().equals(result.get("application").toString())) { String key = result.get("application").toString(); LinkedHashMap section = new LinkedHashMap(); if (sections.containsKey(key)) { section = (LinkedHashMap) sections.get(key); } section.put(result.get("section").toString(), result); sections.put(key, section); } else { String appKey = result.get("application").toString(); String secKey = result.get("section").toString(); LinkedHashMap section = new LinkedHashMap(); LinkedHashMap entry = new LinkedHashMap(); if (entries.containsKey(appKey)) { section = (LinkedHashMap) entries.get(appKey); if (section.containsKey(secKey)) { entry = (LinkedHashMap) section.get(secKey); } } entry.put(result.get("name").toString(), result); section.put(secKey, entry); entries.put(appKey, section); } } //out.print(entries); results = null; this.styleBorder = "1\" bgcolor=\"#ffffff\" bordercolorlight=\"#D2D2D2\" bordercolordark=\"#ffffff"; this.showTableBegin(); if (applications.size() != 0) { Iterator appIt = applications.entrySet().iterator(); while (appIt.hasNext()) { Map.Entry application = (Map.Entry) appIt.next(); String app_key = application.getKey().toString(); HashMap app_value = (HashMap) application.getValue(); this.out.println("<tr>"); this.out.println(" <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">" + app_value.get("title") + "</td>"); this.out.println(" <td nowrap>" + app_value.get("name") + "</td>"); this.out.println(" <td nowrap> </td>"); this.out.println("</tr>"); if (sections.containsKey(app_key)) { HashMap appSections = (HashMap) sections.get(app_key); Iterator secIt = appSections.entrySet().iterator(); while (secIt.hasNext()) { Map.Entry section = (Map.Entry) secIt.next(); String sec_key = section.getKey().toString(); HashMap sec_value = (HashMap) section.getValue(); if (!sec_value.get("name").toString().equals(this.settings.entrySchemaSection)) { this.out.println("<tr>"); this.out.println(" <td nowrap> </td>"); this.out.println( " <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">" + sec_value.get("title") + "</td>"); this.out.println(" <td nowrap>" + sec_value.get("name") + "</td>"); this.out.println(" <td nowrap> </td>"); this.out.println("</tr>"); if (entries.containsKey(app_key)) { HashMap secEntrie = (HashMap) entries.get(app_key); if (secEntrie.containsKey(sec_key)) { HashMap secEntries = (HashMap) secEntrie.get(sec_key); Iterator entIt = secEntries.entrySet().iterator(); while (entIt.hasNext()) { Map.Entry entry = (Map.Entry) entIt.next(); String ent_key = entry.getKey().toString(); HashMap ent_value = (HashMap) entry.getValue(); this.out.println("<tr>"); this.out.println(" <td width=\"20\" nowrap> </td>"); this.out.println(" <td width=\"20\" nowrap> </td>"); this.out.println(" <td width=\"35%\" nowrap valign=\"top\">" + ent_value.get("title") + "</td>"); this.out.println(" <td width=\"10%\" nowrap valign=\"top\">" + ent_value.get("name") + "</td>"); this.out.println(" <td nowrap valign=\"top\">"); if (ent_value.get("input_type").toString().equals("5")) { // long_value this.out.println("[ " + this.rb.getMessage( "sos.settings.dialog.dialog_long_value_title") + " ]"); if (ent_value.get("display_type").toString().equals("4")) { this.out.println(" " + display_type_entries[4]); } } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt this.out.println("[ " + input_type_entries[6] + " ]"); } else { if (ent_value.get("display_type").toString().endsWith("3")) { this.out.println("<pre>" + this.htmlSpecialChars( ent_value.get("value").toString()) + "</pre>"); } else { this.out.println( this.htmlSpecialChars(ent_value.get("value").toString()) + " "); } } this.out.println(" </td>"); this.out.println("</tr>"); } } } } } } } } // if applications else if (sections.size() != 0) { try { HashMap application = this.connection.getSingle("select \"TITLE\",\"NAME\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.application)); Iterator secIt = sections.entrySet().iterator(); if (sections.containsKey(this.settings.application)) { HashMap appSections = (HashMap) sections.get(this.settings.application); Iterator secI = appSections.entrySet().iterator(); while (secI.hasNext()) { Map.Entry section = (Map.Entry) secI.next(); String sec_key = section.getKey().toString(); HashMap sec_value = (HashMap) section.getValue(); this.out.println("<tr>"); this.out.println( " <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">" + application.get("title") + "</td>"); this.out.println(" <td nowrap>" + application.get("name") + "</td>"); this.out.println(" <td nowrap> </td>"); this.out.println("</tr>"); this.out.println("<tr>"); this.out.println(" <td nowrap> </td>"); this.out.println( " <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">" + sec_value.get("title") + "</td>"); this.out.println(" <td nowrap>" + sec_value.get("name") + "</td>"); this.out.println(" <td nowrap> </td>"); this.out.println("</tr>"); if (entries.containsKey(this.settings.application)) { HashMap secEntrie = (HashMap) entries.get(this.settings.application); if (secEntrie.containsKey(sec_key)) { HashMap secEntries = (HashMap) secEntrie.get(sec_key); Iterator entI = secEntries.entrySet().iterator(); while (entI.hasNext()) { Map.Entry entry = (Map.Entry) entI.next(); String ent_key = entry.getKey().toString(); HashMap ent_value = (HashMap) entry.getValue(); this.out.println("<tr>"); this.out.println(" <td width=\"3%\" nowrap> </td>"); this.out.println(" <td width=\"3%\" nowrap> </td>"); this.out.println(" <td width=\"35%\" nowrap valign=\"top\">" + ent_value.get("title") + "</td>"); this.out.println(" <td width=\"10%\" nowrap valign=\"top\">" + ent_value.get("name") + "</td>"); this.out.println(" <td nowrap valign=\"top\">"); if (ent_value.get("input_type").toString().equals("5")) { // long_value this.out.println("[ " + this.rb.getMessage( "sos.settings.dialog.dialog_long_value_title") + " ]"); if (ent_value.get("display_type").toString().equals("4")) { this.out.println(" " + display_type_entries[4]); } } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt this.out.println("[ " + input_type_entries[6] + " ]"); } else { if (ent_value.get("display_type").toString().endsWith("3")) { this.out.println("<pre>" + this.htmlSpecialChars(ent_value.get("value").toString()) + "</pre>"); } else { this.out.println( this.htmlSpecialChars(ent_value.get("value").toString())); } } this.out.println(" </td>"); this.out.println("</tr>"); } } } } //out.print(section); } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); return; } } this.showTableEnd(); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); return; } }
From source file:com.flexoodb.engines.FlexJAXBDBDataEngine2.java
public Collection<Object> runQuery(String query, Class c, boolean usedefaultimplementation) throws Exception { Vector v = new Vector(); Connection conn = null;/*from w ww . ja v a 2s. c om*/ try { conn = (Connection) _pool.getConnection(); String tablename = query.split("\\s")[3]; // always search the index! if (checkTable(tablename, conn, false)) { StringBuffer q = new StringBuffer("where "); if (query.toUpperCase().indexOf("WHERE") > 0) { String sub = query.substring(query.toUpperCase().indexOf("WHERE") + 5); sub = sub.replaceAll("<=", " <eq; "); sub = sub.replaceAll(">=", " >eq; "); sub = sub.replaceAll("<>", " &nteq; "); sub = sub.replaceAll("=", " = "); sub = sub.replaceAll(">", " > "); sub = sub.replaceAll("<", " < "); sub = sub.replaceAll("<eq;", "<="); sub = sub.replaceAll(">eq;", ">="); sub = sub.replaceAll("&nteq;", "<>").trim(); //System.out.println("from:"+sub); boolean done = false; boolean id = false; int seq = 0; String col = null; String condition = null; while (!done) { int x = sub.indexOf(" "); String word = sub.substring(0, x < 0 ? sub.length() : x); int wlen = word.length(); if (word.startsWith("'")) { word = sub.substring(1, sub.indexOf("'", 1)); wlen = word.length() + 2; } //System.out.println("w:"+word+"< "+wlen+" wl:"+word.length()); // check if its a predicate if (":like:=:>:<:<=:>=:<>:".indexOf(":" + word.toLowerCase() + ":") > -1) { condition = word; seq = 2; } else if (":and:or:not:".indexOf(":" + word.toLowerCase() + ":") > -1) { q.append(" " + word.trim() + " "); seq = 0; } else if (seq == 0)// it must be a field! { seq = 1; // fields sequence if (word.trim().equalsIgnoreCase("parentid") || word.trim().equalsIgnoreCase("id")) { q.append(" " + word.trim()); id = true; } else if (word.trim().equalsIgnoreCase("order")) { String[] order = sub.split("\\s"); if (!order[2].equalsIgnoreCase("id") && !order[2].equalsIgnoreCase("parentid")) { // get the 3rd word -- ie the field if (!q.toString().toUpperCase().endsWith("WHERE")) { q.append(" and "); } q.append(" (element='" + order[2] + "')"); q.append(" " + order[0] + " by value " + sub.substring(sub.indexOf(order[2]) + order[2].length()).trim()); } else { q.append(" " + sub); } done = true; } else if (word.trim().equalsIgnoreCase("element") || word.trim().equalsIgnoreCase("limit") || word.trim().equalsIgnoreCase("desc") || word.trim().equalsIgnoreCase("asc")) { q.append(" " + sub); done = true; } else { word = word.replaceAll("'", "\'").trim(); //q.append(" (element='"+word.trim().replaceAll("'","")+"'"); q.append(" (element='" + word + "'"); //col = word.trim().replaceAll("'",""); col = word; } } else if (seq == 2) { //word = word.replaceAll("'"," "); word = word.replaceAll("'", "\'"); if (id) { q.append("" + condition + "'" + word.trim() + "'"); } else { boolean valchanged = false; try { // we look for dates! if (col != null) { Method met = c.getMethod( "get" + col.substring(0, 1).toUpperCase() + col.substring(1), (Class[]) null); Class c1 = (Class) met.getGenericReturnType(); if (c1.getSimpleName().equalsIgnoreCase("XMLGregorianCalendar") && !word.isEmpty()) { //q.append(" and str_to_date(value,\"%Y-%m-%d\") "+condition+" '"+word.trim().replaceAll("'","")+"')"); q.append(" and str_to_date(value,\"%Y-%m-%d\") " + condition + " '" + word.trim() + "')"); valchanged = true; } } } catch (Exception e) { e.printStackTrace(); } if (!valchanged) { //q.append(" and value "+condition+" '"+word.trim().replaceAll("'","")+"')"); q.append(" and value " + condition + " '" + word.trim() + "')"); } col = null; } seq = 0; condition = null; id = false; } sub = sub.substring(wlen).trim(); if (x < 0 || sub.length() == 0) { done = true; } } } else { int tl = tablename.length(); q = new StringBuffer(query.substring(query.indexOf(tablename) + tl)); } PreparedStatement ps = null; boolean searchindex = false; if (!usedefaultimplementation) { ps = (PreparedStatement) conn.prepareStatement( "select distinct id from " + tablename.toLowerCase() + " " + q.toString()); } else { ps = (PreparedStatement) conn.prepareStatement( "select distinct id from " + tablename.toLowerCase() + "_index " + q.toString()); searchindex = true; } System.out.println(">>>Query:" + ps.toString() + "<<< " + usedefaultimplementation); ResultSet rec = ps.executeQuery(); // check if a record was found while (rec != null && !rec.isClosed() && rec.next()) { String id = rec.getString("id"); try { Object o = null; PreparedStatement ps2 = (PreparedStatement) conn .prepareStatement("select id,parentid,content from " + tablename.toLowerCase() + " where id='" + id + "'"); ResultSet res = ps2.executeQuery(); // check if a record was found if (res != null && res.next()) { String i = res.getString("id"); String p = res.getString("parentid"); o = new FlexContainer(_flexutils.getObject(res.getString("content"), c)); ((FlexContainer) o).setId(i); ((FlexContainer) o).setParentId(p); ps2.close(); } else { ps2.close(); if (searchindex) { // then the values found must be orphans! we delete the index contents removeValues(id, tablename, conn); } } if (o != null) { v.add(o); Enumeration en = v.elements(); while (en.hasMoreElements()) { en.nextElement(); } } } catch (Exception g) { throw g; } } } } catch (Exception f) { throw f; } finally { try { if (conn != null) { _pool.releaseConnection(conn); } } catch (Exception g) { } } return v; }
From source file:sos.settings.SOSSettingsDialog.java
/** * Datensatz entfernen//from w w w. j a v a2 s . co m * * @return boolean Fehlerzustand * @throws Exception */ private boolean recordDeleteKey() throws Exception { this.debug(3, "record_delete_key"); try { this.connection.execute("delete from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.entry)); if (this.range.equals("application")) { try { this.connection.execute("delete from " + this.settings.source + " where \"" + this.settings.entryApplication + "\"=" + this.dbQuoted(this.settings.application)); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } else if (this.range.equals("section")) { try { this.connection.execute("delete from " + this.settings.source + " where \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application)); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } else { if (this.applicationType > 0) { try { Vector results = this.connection.getArrayAsVector("select \"SECTION\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\"= " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" <> '" + this.settings.entrySchemaSection + "' and \"" + this.settings.entryName + "\" = \"" + this.settings.entrySection + "\" and \"" + this.settings.entryName + "\" <> \"" + this.settings.entryApplication + "\""); for (Enumeration el = results.elements(); el.hasMoreElements();) { HashMap result = (HashMap) el.nextElement(); try { this.connection.execute("delete from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(result.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.entry)); } catch (Exception e) { //this.setError(e.getMessage(),SOSClassUtil.getMethodName()); break; } } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } if (this.error()) { this.connection.rollback(); return false; } else { this.connection.commit(); } return true; }
From source file:sos.settings.SOSSettingsDialog.java
/** * Alle Eintrge einer Sektion anzeigen/* ww w . j av a 2s.c o m*/ * * @param entriesTitle * Titel * @param entries * Werte(siehe getDialogEntries) * @return boolean Fehlerzustand * @throws Exception * @see #showDialogEntries(String, Vector) */ private boolean showDialogEntries(String entriesTitle, Vector entries) throws Exception { this.debug(3, "showDialogEntries : entriesTitle = " + entriesTitle + " entries = " + entries); // Fleck fr showDialogValues() this.isShowEntries = true; if (entriesTitle != null) { this.dialogEntriesTitle = entriesTitle; } if (entries != null) { this.dialogEntries = entries; } String imgLink = "<img src=\"" + this.imgDir + this.imgAction + "\" border=\"0\" hspace=\"4\" vspace=\"1\">"; String thisCon = (this.site.indexOf('?') != -1) ? "&" : "?"; String querySession = "?"; if (!this.sessionUseTransSID && !this.sessionVAR.equals("")) { querySession = thisCon + this.sessionVAR + "=" + this.sessionID + "&"; } else { querySession = thisCon; } this.showTableBegin(); int columnCount = this.enableEntryNames ? 3 : 2; try { this.showNavigation(new Integer(columnCount), this.dialogApplicationIndex, this.dialogSectionIndex, null); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } this.aclRange = "section"; try { this.getRights(this.settings.application, this.settings.section, null); } catch (Exception e) { this.setError("ACL : " + e.getMessage(), SOSClassUtil.getMethodName()); } if (this.applicationType == 1) { if (this.hasCreateRight) { this.hasWriteRight = true; this.disabled = ""; } } // JS Code schreiben this.openHelpWin(); if (this.enableEntryValues == true) { this.out.println("<form name=\"" + this.form + "\" action=\"" + this.site + "\" method=\"post\" onSubmit=\"return " + this.form + "_check_onSubmit()\">"); } if (this.dialogSectionIndex.intValue() >= 0 && this.enableEntryManager == true) { boolean showNew = false; if (this.applicationType == 1) { if (this.settings.section.equals(this.settings.entrySchemaSection)) { if (this.hasCreateRight == true) { showNew = true; } } } else { if (this.hasCreateRight == true) { showNew = true; } } if (showNew == true) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); String link = "<a class=\"" + this.styleLinkNavigation + "\" href=\"" + this.site + querySession + "action=new&range=entry&application=" + this.response.encodeURL(this.settings.application) + "§ion=" + this.response.encodeURL(this.settings.section) + "&application_type=" + this.applicationType; if (this.sectionType > 0) { link += "§ion_type=" + this.sectionType; } link += "\">"; this.out.println(" <td class=\"" + this.styleTd + "\">" + link + imgLink + this.dialogEntriesNewTitle + "</a> </td>"); if (this.enableEntryNames == true) { this.out.println(" <td class=\"" + this.styleTd + "\"> </td>"); } this.out.println(" <td class=\"" + this.styleTd + "\"> </td>"); this.out.println(" </tr>"); } } String linkEntry = "<a href=\"" + this.site + querySession + "action=show"; String linkSchema = (this.enableEntryManager == true) ? "<a href=\"" + this.site + querySession + "action=schema" : linkEntry; int cnt = 0; String lastApplication = ""; String lastSection = ""; boolean hasTitle = false; if (this.action.equals("query") || this.action.equals("duplicate")) { hasTitle = true; } HashMap application = new HashMap(); HashMap section = new HashMap(); application.put("entry_type", new Integer(this.applicationType)); section.put("entry_type", new Integer(this.sectionType)); String aclApplication = ""; StringBuffer sql = new StringBuffer(); StringBuffer sqlHelp = new StringBuffer(); StringBuffer sqlBinary = new StringBuffer(); if (this.sectionType > 0 || this.applicationType > 0) { // aus der // Schema sql.append(" select s.\"" + this.settings.entryApplication + "\",s.\"" + this.settings.entrySection + "\", s.\"" + this.settings.entryName + "\" "); sql.append(" from " + this.settings.source + " s "); sql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" = '" + this.settings.entrySchemaSection + "' and "); sql.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" and "); sqlBinary.append(" select s.\"" + this.settings.entryApplication + "\",s.\"" + this.settings.entrySection + "\", s.\"" + this.settings.entryName + "\" "); sqlBinary.append(" from " + this.settings.source + " s "); sqlBinary.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sqlBinary.append(" s.\"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and "); sqlBinary.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" and "); } else { sql.append(" select s.\"" + this.settings.entryApplication + "\",s.\"" + this.settings.entrySection + "\", s.\"" + this.settings.entryName + "\" "); sql.append(" from " + this.settings.source + " s "); sql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" and "); sqlBinary = new StringBuffer(sql.toString()); } sqlBinary.append(" s.\"LONG_VALUE\" is not null"); sqlHelp = sql.append(" s.\"DOCUMENTATION\" is not null"); Hashtable helpTexts = new Hashtable(); try { Vector helpText = this.connection.getArrayAsVector(sqlHelp.toString()); if (helpText.size() > 0) { for (Enumeration el = helpText.elements(); el.hasMoreElements();) { HashMap hm = (HashMap) el.nextElement(); helpTexts.put(hm.get("application").toString() + hm.get("section").toString() + hm.get("name").toString(), "Help"); } this.hasHelps = true; } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } this.hasBinaryValue = new Hashtable(); try { Vector binaryValues = this.connection.getArrayAsVector(sqlBinary.toString()); if (binaryValues.size() > 0) { for (Enumeration el = binaryValues.elements(); el.hasMoreElements();) { HashMap hm = (HashMap) el.nextElement(); this.hasBinaryValue.put(hm.get("application").toString() + hm.get("section").toString() + hm.get("name").toString(), "1"); } } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } Vector checkEntries = new Vector(); int ce = 0; int index = 0; boolean isNotAllDisabled = false; String[] display_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_display_type_entries") .split(";"); if (display_type_entries.length != 5) { this.setError("\"sos.settings.dialog.listbox_display_type_entries\" expected 5 values, given : " + display_type_entries.length, SOSClassUtil.getMethodName()); return false; } String[] input_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_input_type_entries") .split(";"); if (input_type_entries.length != 7) { this.setError("\"sos.settings.dialog.listbox_input_type_entries\" expected 7 values, given : " + input_type_entries.length, SOSClassUtil.getMethodName()); return false; } for (Enumeration el = this.dialogEntries.elements(); el.hasMoreElements();) { HashMap entry = (HashMap) el.nextElement(); this.aclRange = "entry"; try { this.getRights(entry.get("application").toString(), entry.get("section").toString(), entry.get("name").toString()); if (this.hasReadRight == false && this.hasCreateRight == false) { continue; } } catch (Exception e) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\" colspan=\"3\">"); this.out.println(" <table width=\"100%\" border =\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td>"); this.out.println( " " + entry.get(this.settings.entryTitle.toLowerCase()).toString() + " "); this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.showError("ACL : " + e.getMessage()); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); this.out.println(" </tr>"); continue; } // Acls end cnt++; String link = ""; if ((hasTitle == true) && (!entry.get(this.settings.entryApplication.toLowerCase()).toString() .equals(lastApplication))) { try { application = this.connection.getSingle("select \"NAME\",\"TITLE\",\"ENTRY_TYPE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + " and \"" + this.settings.entryApplication + "\"= \"" + this.settings.entrySection + "\" and \"" + this.settings.entrySection + "\"= \"" + this.settings.entryName + "\""); if (application.size() == 0) { continue; } } catch (Exception e) { continue; } try { section = this.connection.getSingle("select \"NAME\",\"TITLE\",\"ENTRY_TYPE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= " + this.dbQuoted(entry.get(this.settings.entrySection.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= \"" + this.settings.entryName + "\""); if (section.size() == 0) { continue; } } catch (Exception e) { continue; } lastApplication = entry.get(this.settings.entryApplication.toLowerCase()).toString(); lastSection = entry.get(this.settings.entrySection.toLowerCase()).toString(); this.out.println(" <tr class=\"" + this.styleTr + "\">"); link = linkEntry + "&range=sections&application=" + this.response.encodeURL(lastApplication) + "\" class=\"" + this.styleLinkNavigation + "\">"; this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\">" + link + imgLink + application.get("title").toString() + "</a></th>"); link = linkEntry + "&range=entries&application=" + this.response.encodeURL(lastApplication) + "§ion=" + this.response.encodeURL(lastSection) + "&application_type=" + application.get("entry_type").toString() + "§ion_type=" + section.get("entry_type").toString() + "\" class=\"" + this.styleLinkNavigation + "\">"; this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\" colspan=\"" + (columnCount - 1) + "\">" + link + imgLink + section.get("title").toString() + "</th>"); this.out.println(" </tr>"); } if ((hasTitle == true) && (!entry.get(this.settings.entrySection.toLowerCase()).toString().equals(lastSection))) { section = this.connection.getSingle("select \"NAME\",\"TITLE\",\"ENTRY_TYPE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= " + this.dbQuoted(entry.get(this.settings.entrySection.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= \"" + this.settings.entryName + "\""); lastSection = entry.get(this.settings.entrySection.toLowerCase()).toString(); this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\"> </th>"); link = linkEntry + "&range=entries&application=" + this.response.encodeURL(lastApplication) + "§ion=" + this.response.encodeURL(lastSection) + "&application_type=" + application.get("entry_type").toString() + "§ion_type=" + section.get("entry_type").toString() + "\" class=\"" + this.styleLinkNavigation + "\">"; this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\" colspan=\"" + (columnCount - 1) + "\">" + link + imgLink + section.get("title").toString() + "</th>"); this.out.println(" </tr>"); } String linkHelp = ""; ///////////// this.out.println(" <tr class=\"" + this.styleTr + "\">"); if (entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection)) { linkHelp = " "; String k = entry.get(this.settings.entryApplication.toLowerCase()).toString() + this.settings.entrySchemaSection + entry.get(this.settings.entryName.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response .encodeURL(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(this.settings.entrySchemaSection) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } String linkQuery = "&range=entry&application=" + this.response.encodeURL( entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type").toString() + "\">"; this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border =\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td>"); this.out.println(" " + linkSchema + linkQuery + imgLink + "</a>"); link = (entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection)) ? linkSchema : linkEntry; this.out.println(" " + link + linkQuery + entry.get(this.settings.entryTitle.toLowerCase()).toString() + "</a> "); this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.out.println(" " + linkHelp); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); } else if (this.sectionType > 0 || this.applicationType > 0) { // schema linkHelp = " "; if (this.hasCreateRight) { // bei Schema reicht CREATE Recht this.hasWriteRight = true; this.disabled = ""; } String k = entry.get(this.settings.entryApplication.toLowerCase()).toString() + this.settings.entrySchemaSection + entry.get(this.settings.entryName.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response .encodeURL(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(this.settings.entrySchemaSection) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } String linkQuery = "&range=entry&application=" + this.response.encodeURL( entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type").toString() + "§ion_type=" + section.get("entry_type").toString() + "\">"; this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border =\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td nowrap>"); if (this.enableEntryValues == true) { this.out.println(" " + linkEntry + linkQuery + imgLink + "</a>" + linkEntry + linkQuery + entry.get(this.settings.entryTitle.toLowerCase()).toString() + "</a> "); } else { this.out.println( " " + entry.get(this.settings.entryTitle.toLowerCase()).toString() + " "); } this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.out.println(" " + linkHelp); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); } else { linkHelp = " "; String k = entry.get(this.settings.entryApplication.toLowerCase()).toString() + entry.get(this.settings.entrySection.toLowerCase()).toString() + entry.get(this.settings.entryName.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response .encodeURL(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL( entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } String linkQuery = "&range=entry&application=" + this.response.encodeURL( entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type").toString() + "\">"; this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\" nowrap>"); this.out.println(" <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td>"); if (this.enableEntryValues == true) { this.out.println(" " + linkSchema + linkQuery + imgLink + "</a>"); link = (entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection)) ? linkSchema : linkEntry; this.out.println(" " + link + linkQuery + entry.get(this.settings.entryTitle.toLowerCase()) + "</a> "); } else { this.out.println(" " + entry.get(this.settings.entryTitle.toLowerCase()) + " "); } this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.out.println(" " + linkHelp); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); } if (this.enableEntryNames == true) { this.out.println(" <td valign=\"top\" class=\"" + this.styleTd + "\">" + entry.get(this.settings.entryName.toLowerCase()) + " </td>"); } if ((this.enableEntryValues == true) && (!entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection))) { if (this.disabled.equals("")) { isNotAllDisabled = true; } this.out.println(" <td valign=\"top\" class=\"" + this.styleTd + "\">"); /* * if (entry.get("input_type").toString().equals("5")) { * this.out.println("[ " + this.rb * .getMessage("sos.settings.dialog.dialog_long_value_title") + " * ]"); } else { this.showDialogValue(entry, 1, index); if * (!entry.get("forced").toString().equals("0") && * !entry.get("forced").toString().equals("") && * entry.get("display_type").toString().equals("0")) { * checkEntries.add(ce, "value_" + index); ce++; } } * this.out.println(" </td> "); */ this.out.println("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); this.out.println(" <tr>"); String hbv = ""; if (this.hasBinaryValue.containsKey(entry.get("application").toString() + entry.get("section").toString() + entry.get("name").toString())) { hbv = this.hasBinaryValue.get(entry.get("application").toString() + entry.get("section").toString() + entry.get("name").toString()).toString(); } if ((hbv != null && hbv.length() > 0 && !hbv.equals("0")) || (entry.get("input_type").toString().equals("5") || entry.get("input_type").toString().equals("6"))) { if (entry.get("input_type").toString().equals("5")) { // Dokument this.out.println(" <td>"); this.out.println("[ " + this.rb.getMessage("sos.settings.dialog.dialog_long_value_title") + " ] "); if (entry.get("display_type").toString().equals("4")) { // versteckt this.out.println(display_type_entries[4] + "</td>"); this.out.println(" <td align=\"right\">"); this.showDialogValue(entry, 1, index); this.out.println(" </td>"); } else { this.out.println(" </td>"); this.out.println(" <td align=\"right\"> </td>"); } } else { // Dokument binr oder wir machen zum Dokument // binr this.out.println(" <td>"); this.out.println("[ " + input_type_entries[6] + " ]"); this.out.println(" </td>"); entry.put("input_type", "6"); entry.put("display_type", "4"); this.out.println(" <td align=\"right\">"); this.showDialogValue(entry, 1, index); this.out.println(" </td>"); } } else { this.out.println(" <td colspan=\"2\">"); this.showDialogValue(entry, 1, index); this.out.println(" </td>"); if (!entry.get("forced").toString().equals("0") && !entry.get("forced").toString().equals("") && entry.get("display_type").toString().equals("0")) { checkEntries.add(ce, "value_" + index); ce++; } } this.out.println("</tr>"); this.out.println("</table>"); this.out.println("</td>"); } else { this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\">" + entry.get(this.settings.entryValue.toLowerCase()).toString() + " </td>"); } this.out.println(" </tr>"); index++; } // foreach this.out.println("<script language=\"JavaScript\" type=\"text/javascript\">"); this.out.println(" function " + this.form + "_check_onSubmit() {"); this.out.println(" "); this.out.print(" var entries = Array("); for (int i = 0; i < checkEntries.size(); i++) { if (i > 0) { this.out.print(","); } this.out.print("\"" + checkEntries.get(i) + "\""); } this.out.println(" );"); this.out.println(" for(var i=0; i<entries.length; i++) {"); this.out.println(" if ( document." + this.form + ".elements[entries[i]].value == null || document." + this.form + ".elements[entries[i]].value == \"\" ) {"); this.out.println( " alert( \"" + this.rb.getMessage("sos.settings.dialog.alert_entry_empty") + "\");"); this.out.println(" document." + this.form + ".elements[entries[i]].focus();"); this.out.println(" return false;"); this.out.println(" }"); this.out.println(" }"); this.out.println(" return true;"); this.out.println(" }"); this.out.println("</script>"); if (this.enableEntryValues == true) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td valign=\"middle\" colspan=\"" + columnCount + "\" class=\"" + this.styleTd + "\"> "); if (isNotAllDisabled) { this.out.println(" <input type=\"image\" name=\"btn_store\" src=\"" + this.imgDir + this.sosLang + "/btn_store.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_store_alt") + "\" onClick=\"document.sos_settings.button.value=\'store\';\"> "); this.out.println(" <input type=\"image\" name=\"btn_cancel\" src=\"" + this.imgDir + this.sosLang + "/btn_cancel.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_cancel_alt") + "\" onClick=\"document.sos_settings.button.value=\'cancel\';\"> "); this.out.println(" <input type=\"image\" name=\"btn_reset\" src=\"" + this.imgDir + this.sosLang + "/btn_reset.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_reset_alt") + "\" onClick=\"document.sos_settings.reset(); return false;\"> "); } else { this.out.println(" <input type=\"image\" name=\"btn_cancel\" src=\"" + this.imgDir + this.sosLang + "/btn_cancel.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_cancel_alt") + "\" onClick=\"document.sos_settings.button.value=\'cancel\';\"> "); } this.out.println("<input type=\"hidden\" name=\"button\">"); this.out.println( "<input type=\"hidden\" name=\"application\" value=\"" + this.settings.application + "\">"); this.out.println( "<input type=\"hidden\" name=\"section\" value=\"" + this.settings.section + "\">"); this.out.println("<input type=\"hidden\" name=\"entry\" value=\"\">"); this.out.println("<input type=\"hidden\" name=\"range\" value=\"list\">"); this.out.println("<input type=\"hidden\" name=\"section_type\" value=\"" + this.sectionType + "\">"); this.out.println( "<input type=\"hidden\" name=\"application_type\" value=\"" + this.applicationType + "\">"); this.out.println("<input type=\"hidden\" name=\"num_of_entries\" value=\"" + cnt + "\">"); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </form>"); } this.showActions(new Integer(columnCount), this.dialogApplicationIndex, this.dialogSectionIndex, null); this.showTableEnd(); return true; }
From source file:sos.settings.SOSSettingsDialog.java
/** * Datensatz einfgen/*from w w w .ja va 2 s . c om*/ * * @return boolean Fehlerzustand * @throws Exception */ private boolean recordInsert() throws Exception { this.debug(3, "record_insert"); // document binary boolean enableUploadFile = false; byte[] backUpLongValue = null; this.createRecord(); Iterator it = this.record.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String param = entry.getKey().toString(); String value = entry.getValue().toString(); if (this.getRequestValue(param) != null) { if (param.equals("application") || param.equals("section") || param.equals("name")) { if (this.getIgnoreCase()) { this.record.put(param, this.getRequestValue(param).trim()); } else { this.record.put(param, this.getRequestValue(param).trim().toLowerCase()); } } else { this.record.put(param, this.getRequestValue(param).trim()); } } } boolean isSaveAs = false; this.record.put("original_name", ""); String origName = this.getRequestValue("original_name"); if (origName != null && origName.trim().length() > 0) { this.record.put("original_name", origName.trim()); isSaveAs = true; } HashMap backupRecord = (HashMap) this.record.clone(); int entryType = 0; try { entryType = Integer.parseInt(this.record.get("entry_type").toString()); } catch (Exception e) { this.record.put("entry_type", "0"); } try { Integer.parseInt(this.record.get("input_type").toString()); } catch (Exception e) { this.record.put("input_type", "0"); } try { if (Integer.parseInt(this.record.get("input_size").toString()) <= 0) { this.record.put("input_size", this.defaultInputSize); } } catch (Exception e) { this.record.put("input_size", this.defaultInputSize); } try { Integer.parseInt(this.record.get("display_type").toString()); } catch (Exception e) { this.record.put("display_type", "0"); } try { if (Integer.parseInt(this.record.get("display_size").toString()) <= 0) { this.record.put("display_size", this.defaultDisplaySize); } } catch (Exception e) { this.record.put("display_size", this.defaultDisplaySize); } StringBuffer sqlStmt = null; if (this.range.equalsIgnoreCase("application")) { this.record.put(this.settings.entryApplication.toLowerCase(), this.record.get("name").toString()); this.record.put(this.settings.entrySection.toLowerCase(), this.record.get("name").toString()); try { int forced = Integer.parseInt(this.record.get("forced").toString()); if (forced != 1 && forced != -1) { this.record.put("forced", "0"); } } catch (Exception e) { this.record.put("forced", "0"); } boolean isInserted = false; /* !!!!!!!!!!!schema ist nicht bercksichtigt try{ String count = this.connection.getSingleValue("select count(\"APPLICATION\") from "+this.settings.source+" where \"APPLICATION\" = "+this.dbQuoted(this.record.get("name").toString())+" and \"SECTION\" = \"APPLICATION\" and \"NAME\" = \"APPLICATION\""); if(!count.equals("0")){ this.setError(this.rb.getMessage("sos.settings.dialog.err_available_application"), SOSClassUtil.getMethodName()); return false; } } catch(Exception e){ this.setError(e.getMessage(), SOSClassUtil.getMethodName()); return false; } */ if (entryType == 1) { sqlStmt = new StringBuffer(" insert into " + this.settings.source + "(\"APPLICATION\", \"SECTION\", \"NAME\", \"VALUE\", \"TITLE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\", \"CREATED\", \"CREATED_BY\", \"MODIFIED\", \"MODIFIED_BY\") ") .append(" values (" + this.dbQuoted(this.record.get("name").toString()) + ",'" + this.settings.entrySchemaSection + "','" + this.settings.entrySchemaSection + "',0,'" + this.dialogSectionsSchemaTitle + "', 1, 0, 0, 10, 0, 0, %now, '" + this.settings.author + "', %now, '" + this.settings.author + "')"); try { this.connection.execute(sqlStmt.toString()); isInserted = true; } catch (Exception e) { //break; this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } if (!this.error()) { if (!this.settings.application.equals("")) { sqlStmt = new StringBuffer( "select \"SECTION\",\"NAME\", \"VALUE\", \"TITLE\", \"DEFAULT_VALUE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\" from " + this.settings.source + " ") .append(" where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application)); try { Vector results = this.connection.getArrayAsVector(sqlStmt.toString()); for (Enumeration el = results.elements(); el.hasMoreElements();) { HashMap result = (HashMap) el.nextElement(); if (isInserted && result.get("section").toString().equals(this.settings.entrySchemaSection) && result.get("name").toString().equals(this.settings.entrySchemaSection)) { continue; } StringBuffer sql = new StringBuffer("insert into " + this.settings.source + " (\"APPLICATION\", \"SECTION\", \"NAME\", \"VALUE\", \"TITLE\", \"DEFAULT_VALUE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\", \"CREATED\", \"CREATED_BY\", \"MODIFIED\", \"MODIFIED_BY\") "); String i_s = ""; String e_v = ""; String d_v = ""; if (result.get("input_size").toString().equals("")) { i_s = "NULL"; } else { i_s = result.get("input_size").toString(); } if (result.get("value").toString().equals("")) { e_v = "NULL"; } else { e_v = this.dbQuoted(result.get("value").toString()); } if (result.get("default_value").toString().equals("")) { d_v = "NULL"; } else { d_v = this.dbQuoted(result.get("default_value").toString()); } sql.append("values (" + this.dbQuoted(this.record.get("name").toString()) + "," + this.dbQuoted(result.get("section").toString()) + ", " + this.dbQuoted(result.get("name").toString()) + ", " + e_v + ", " + this.dbQuoted(result.get("title").toString()) + ", " + d_v + ", " + result.get("input_type").toString() + ", " + i_s + ", ") .append(result.get("display_type").toString() + ", " + result.get("display_size").toString() + ", " + result.get("forced").toString() + ", " + result.get("entry_type").toString() + ", %now, '" + this.settings.author + "', %now, '" + this.settings.author + "')"); try { this.connection.execute(sql.toString()); byte[] longValue = this.connection.getBlob("select \"LONG_VALUE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(result.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString()) + " "); if (longValue != null && longValue.length != 0) { this.connection.updateBlob(this.settings.source, "LONG_VALUE", longValue, " \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.record.get("name").toString()) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(result.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString()) + " "); } byte[] documentation = this.connection.getBlob("select \"DOCUMENTATION\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(result.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString()) + " "); if (documentation != null && documentation.length != 0) { this.connection.updateBlob(this.settings.source, "DOCUMENTATION", documentation, " \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.record.get("name").toString()) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(result.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString()) + " "); } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } // Enumeration String sqlDel = " delete from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.record.get("name").toString()) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.application); try { this.connection.execute(sqlDel); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } } } else if (this.range.equalsIgnoreCase("section")) { this.record.put(this.settings.entryApplication.toLowerCase(), this.settings.application); this.record.put(this.settings.entrySection.toLowerCase(), this.record.get("name").toString()); try { int forced = Integer.parseInt(this.record.get("forced").toString()); if (forced != 1 && forced != -1) { this.record.put("forced", "0"); } } catch (Exception e) { this.record.put("forced", "0"); } if (entryType == 1) { sqlStmt = new StringBuffer(" insert into " + this.settings.source + " (\"APPLICATION\", \"SECTION\", \"NAME\", \"VALUE\", \"TITLE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\", \"CREATED\", \"CREATED_BY\", \"MODIFIED\", \"MODIFIED_BY\") ") .append(" values ('" + this.settings.entryCounterApplication + "','" + this.settings.entryCounterSection + "','" + (this.settings.source + "." + this.record.get("name").toString()) .toLowerCase() + "',0,'" + this.dialogSectionsCounterTitle + " " + this.record.get("name").toString() + "', 1, 0, 0, 10, 0, 0, %now, '" + this.settings.author + "', %now, '" + this.settings.author + "')"); try { this.connection.execute(sqlStmt.toString()); } catch (Exception e) { //break; this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } if (!this.error()) { String entryValue = "value"; boolean ok = (!this.settings.section.equals("")); // .. // Speichern // unter if (!ok) { ok = (this.applicationType > 0); // bernahme aus einer // Schema-Sektion if (ok) { this.settings.section = this.settings.entrySchemaSection; entryValue = "default_value"; } } if (ok) { sqlStmt = new StringBuffer( " select \"NAME\", \"VALUE\", \"TITLE\", \"DEFAULT_VALUE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\" from " + this.settings.source + " ") .append(" where \"" + this.settings.entryApplication + "\"=" + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\"=" + this.dbQuoted(this.settings.section) + " and \"" + this.settings.entrySection + "\"<>\"" + this.settings.entryName + "\""); try { Vector results = this.connection.getArrayAsVector(sqlStmt.toString()); if (results.size() > 0) { for (Enumeration el = results.elements(); el.hasMoreElements();) { HashMap result = (HashMap) el.nextElement(); sqlStmt = new StringBuffer(" insert into " + this.settings.source + " (\"APPLICATION\", \"SECTION\", \"NAME\", \"VALUE\", \"TITLE\", \"DEFAULT_VALUE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\", \"CREATED\", \"CREATED_BY\", \"MODIFIED\", \"MODIFIED_BY\") "); String i_s = ""; String e_v = ""; String d_v = ""; if (result.get("input_size").toString().equals("")) { i_s = "NULL"; } else { i_s = result.get("input_size").toString(); } if (result.get(entryValue).toString().equals("")) { e_v = "NULL"; } else { e_v = this.dbQuoted(result.get(entryValue).toString()); } if (result.get("default_value").toString().equals("")) { d_v = "NULL"; } else { d_v = this.dbQuoted(result.get("default_value").toString()); } String db_application = (this.getIgnoreCase()) ? this.settings.application : this.settings.application.toLowerCase(); String db_name = (this.getIgnoreCase()) ? result.get("name").toString() : result.get("name").toString().toLowerCase(); sqlStmt.append(" values (" + this.dbQuoted(db_application) + "," + this.dbQuoted(this.record.get("name").toString()) + "," + this.dbQuoted(db_name) + ", " + e_v + ", " + this.dbQuoted(result.get("title").toString()) + "," + d_v + "," + result.get("input_type").toString() + "," + i_s + ", ") .append(result.get("display_type").toString() + ", " + result.get("display_size").toString() + ", " + result.get("forced").toString() + ", " + result.get("entry_type").toString() + ", %now, '" + this.settings.author + "', %now, '" + this.settings.author + "')"); try { this.connection.execute(sqlStmt.toString()); byte[] longValue = this.connection.getBlob("select \"LONG_VALUE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString())); if (longValue != null && longValue.length != 0) { this.connection.updateBlob(this.settings.source, "LONG_VALUE", longValue, " \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.record.get("name").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString())); } byte[] documentation = this.connection.getBlob("select \"DOCUMENTATION\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString())); if (documentation != null && documentation.length != 0) { this.connection.updateBlob(this.settings.source, "DOCUMENTATION", documentation, " \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.record.get("name").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(result.get("name").toString())); } } catch (Exception e) { //break; this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } } } catch (Exception e) { //break; this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } } } else { this.record.put(this.settings.entryApplication.toLowerCase(), this.settings.application); this.record.put(this.settings.entrySection.toLowerCase(), this.settings.section); String inputType = this.record.get("input_type").toString(); String displayType = this.record.get("display_type").toString(); if (inputType.equals("5")) {// Dokument if (displayType.equals("4")) {// Vestreckt . Behandlung wie bei case 6 this.record.put("input_size", ""); this.record.put("display_type", "4"); // Hidden this.record.put("value", ""); if (this.item.equals("upload")) { if (this.inputImport != null && this.inputImport.length() > 0 && this.importOriginalFileName != null && this.importOriginalFileName.length() > 0) { backupRecord.put("long_value", this.inputImport); //this.record.put("default_value",this.importOriginalFileName); enableUploadFile = true; } else { return false; } } } else {// Textarea this.record.put("input_size", ""); this.record.put("display_type", "3"); // Textarea if (this.record.get("value").toString().trim().length() > 0) { if (this.record.get("name").toString().trim().length() > 0) { backupRecord.put("long_value", this.record.get("value").toString()); } } this.record.put("value", ""); } } else if (inputType.equals("6")) {// Dokument binr this.record.put("input_size", ""); this.record.put("display_type", "4"); // Hidden this.record.put("value", ""); if (this.item.equals("upload")) { if (this.inputImport != null && this.inputImport.length() > 0 && this.importOriginalFileName != null && this.importOriginalFileName.length() > 0) { backupRecord.put("long_value", this.inputImport); //this.record.put("default_value",this.importOriginalFileName); enableUploadFile = true; } else { return false; } } } if (isSaveAs && !enableUploadFile) { if (inputType.equals("5") || inputType.equals("6")) { backUpLongValue = this.connection.getBlob("select \"LONG_VALUE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.record.get("application").toString()) + " and \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.record.get("section").toString()) + " and \"" + this.settings.entryName + "\" = " + this.dbQuoted(this.record.get("original_name").toString())); if (backUpLongValue != null && backUpLongValue.length > 0) { //backupRecord.put("long_value",backUpLongValue); } else { backupRecord.put("long_value", ""); } } } ////////////////////////// if (this.applicationType > 0) { try { Vector results = this.connection.getArrayAsVector(" select \"SECTION\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.record.get("application").toString()) + " and \"" + this.settings.entrySection + "\" <> '" + this.settings.entrySchemaSection + "' and \"" + this.settings.entryName + "\" = \"" + this.settings.entrySection + "\" and \"" + this.settings.entryName + "\" <> \"" + this.settings.entryApplication + "\""); if (results.size() > 0) { for (Enumeration el = results.elements(); el.hasMoreElements();) { HashMap result = (HashMap) el.nextElement(); String i_s = ""; String d_v = ""; String e_v = ""; if (this.record.get("input_size").toString().equals("")) { i_s = "NULL"; } else { i_s = this.record.get("input_size").toString(); } if (this.record.get("default_value").toString().equals("")) { d_v = "NULL"; } else { d_v = this.dbQuoted(this.record.get("default_value").toString()); } String input_type = this.record.get("input_type").toString(); if (input_type.equals("5") || input_type.equals("6")) { // dokument oder dokument binr e_v = "NULL"; } else { e_v = d_v; } String db_application = (this.getIgnoreCase()) ? this.record.get("application").toString() : this.record.get("application").toString().toLowerCase(); String db_section = (this.getIgnoreCase()) ? result.get("section").toString() : result.get("section").toString().toLowerCase(); String db_name = (this.getIgnoreCase()) ? this.record.get("name").toString() : this.record.get("name").toString().toLowerCase(); sqlStmt = new StringBuffer(" insert into " + this.settings.source + " (\"APPLICATION\", \"SECTION\", \"NAME\", \"VALUE\", \"TITLE\", \"DEFAULT_VALUE\", \"INPUT_TYPE\", \"INPUT_SIZE\", \"DISPLAY_TYPE\", \"DISPLAY_SIZE\", \"FORCED\", \"ENTRY_TYPE\", \"CREATED\", \"CREATED_BY\", \"MODIFIED\", \"MODIFIED_BY\") ") .append(" values ( " + this.dbQuoted(db_application) + "," + this.dbQuoted(db_section) + ", " + this.dbQuoted(db_name) + "," + e_v + ", " + this.dbQuoted(this.record.get("title").toString()) + ", " + d_v + "," + this.record.get("input_type").toString() + ", " + i_s + ", " + this.record.get("display_type").toString() + ", " + this.record.get("display_size").toString() + "," + this.record.get("forced").toString() + ", " + this.record.get("entry_type").toString() + ", %now, '" + this.settings.author + "', %now, '" + this.settings.author + "')"); try { this.connection.execute(sqlStmt.toString()); } catch (Exception e) { //break; this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } } } catch (Exception e) { //break; this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } if (!this.error()) { if (this.sectionType > 0) { try { int sequence = this.settings.getSequence(this.settings.entryCounterApplication, this.settings.entryCounterSection, (this.settings.source + "." + this.settings.section).toLowerCase()); this.record.put(this.settings.entryName.toLowerCase(), new Integer(sequence)); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } this.record.put("forced", "0"); if (this.error()) { return false; } } } } Date date = new Date(); this.record.put("created", this.dateFormat.format(date)); this.record.put("created_by", this.settings.author); this.record.put("modified", this.dateFormat.format(date)); this.record.put("modified_by", this.settings.author); //backupRecord.put("documentation",this.record.get("documentation").toString()); //this.record.put("documentation",""); // insert(); // Kommt aus dem FKC Editor if (this.getRequestValue(this.editorName) != null) { this.record.put("documentation", ""); backupRecord.put("documentation", ""); String editorValue = this.getRequestValue(this.editorName).trim(); if (!editorValue.equals("")) { // \z - endet damit String copy = editorValue.toLowerCase(); //String pattern = "^(<p>( )+[\\s]*</p>[\\s]*)+\\z"; String pattern = "^(<p>( )*((<[a-zA-Z]*>)*(</[a-zA-Z]*>)*)*[\\s]*</p>[\\s]*)+\\z"; Pattern p = Pattern.compile(pattern); Matcher matcher = p.matcher(copy); if (!matcher.find()) { this.record.put("documentation", editorValue); backupRecord.put("documentation", editorValue); } } } if (!this.error()) { String value = ""; String defaultValue = ""; String inputSize = ""; if (this.record.get("value").toString().equals("")) { value = "NULL"; } else { value = this.dbQuoted(this.record.get("value").toString()); } if (this.record.get("default_value").toString().equals("")) { defaultValue = "NULL"; } else { defaultValue = this.dbQuoted(this.record.get("default_value").toString()); } if (this.record.get("input_size").toString().equals("")) { inputSize = "NULL"; } else { inputSize = this.record.get("input_size").toString(); } String db_application = (this.getIgnoreCase()) ? this.record.get("application").toString() : this.record.get("application").toString().toLowerCase(); String db_section = (this.getIgnoreCase()) ? this.record.get("section").toString() : this.record.get("section").toString().toLowerCase(); String db_name = (this.getIgnoreCase()) ? this.record.get("name").toString() : this.record.get("name").toString().toLowerCase(); String created = this.record.get("created").toString(); if (created.length() > 19) { created = created.substring(0, 19); } String modified = this.record.get("modified").toString(); if (modified.length() > 19) { modified = modified.substring(0, 19); } sqlStmt = new StringBuffer("insert into " + this.settings.source + " ") .append("(\"APPLICATION\",\"SECTION\",\"NAME\",\"VALUE\",\"DEFAULT_VALUE\",\"TITLE\",") .append("\"INPUT_TYPE\",\"INPUT_SIZE\",\"DISPLAY_TYPE\",\"DISPLAY_SIZE\",\"FORCED\",") .append("\"ENTRY_TYPE\",\"CREATED\",\"CREATED_BY\",\"MODIFIED\",\"MODIFIED_BY\")") .append(" values(" + this.dbQuoted(db_application) + "," + this.dbQuoted(db_section) + "," + this.dbQuoted(db_name) + "," + value + "," + defaultValue + "," + this.dbQuoted(this.record.get("title").toString()) + ",") .append(this.record.get("input_type").toString() + "," + inputSize + "," + this.record.get("display_type").toString() + "," + this.record.get("display_size").toString() + "," + this.record.get("forced").toString() + ",") .append(this.record.get("entry_type").toString() + ",%timestamp_iso('" + created + "'),'" + this.record.get("created_by").toString() + "',%timestamp_iso('" + modified + "'),'" + this.record.get("modified_by").toString() + "')"); try { this.connection.execute(sqlStmt.toString()); String documentation = backupRecord.get("documentation").toString(); byte[] longValue = null; if (backUpLongValue != null && backUpLongValue.length > 0) { longValue = backUpLongValue; } else { longValue = backupRecord.get("long_value").toString().getBytes(); } if (!documentation.trim().equals("")) { try { this.connection.updateBlob(this.settings.source, "DOCUMENTATION", documentation.getBytes(), "\"APPLICATION\"=" + this.dbQuoted(this.record.get("application").toString()) + " and \"SECTION\" = " + this.dbQuoted(this.record.get("section").toString()) + " and \"NAME\" = " + this.dbQuoted(this.record.get("name").toString())); //this.record.put("documentation",documentation); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } if (longValue != null && longValue.length > 0) { try { if (enableUploadFile) { // document binary //this.connection.update_blob_from_file($this->source,'"LONG_VALUE"',$backup_record['long_value'],'where "'.$this->entry_application.'"=\''.$this->db->str_quoted($this->record['application']).'\' and "'.$this->entry_section.'" = \''.$this->db->str_quoted($this->record['section']).'\' and "'.$this->entry_name.'" = \''.$this->db->str_quoted($this->record['name']).'\''); //update from file this.connection.updateBlob(this.settings.source, "LONG_VALUE", backupRecord.get("long_value").toString(), "\"APPLICATION\"=" + this.dbQuoted(this.record.get("application").toString()) + " and \"SECTION\" = " + this.dbQuoted(this.record.get("section").toString()) + " and \"NAME\" = " + this.dbQuoted(this.record.get("name").toString())); } else { // document this.connection.updateBlob(this.settings.source, "LONG_VALUE", longValue, "\"APPLICATION\"=" + this.dbQuoted(this.record.get("application").toString()) + " and \"SECTION\" = " + this.dbQuoted(this.record.get("section").toString()) + " and \"NAME\" = " + this.dbQuoted(this.record.get("name").toString())); } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } if (this.error()) { this.connection.rollback(); this.record = backupRecord; return false; } else { this.connection.commit(); } } else { return false; } this.msg = this.rb.getMessage("sos.settings.dialog.msg_store"); return true; }
From source file:org.sakaiproject.dav.DavServlet.java
/** * Propfind helper method.//from www. j a va 2 s .com * * @param resources * Resources object associated with this context * @param generatedXML * XML response to the Propfind request * @param path * Path of the current resource * @param type * Propfind type * @param propertiesVector * If the propfind type is find properties by name, then this Vector contains those properties */ private void parseProperties(HttpServletRequest req, DirContextSAKAI resources, XMLWriter generatedXML, String path, int type, Vector<String> propertiesVector) { // Exclude any resource in the /WEB-INF and /META-INF subdirectories // (the "toUpperCase()" avoids problems on Windows systems) if (path.toUpperCase().startsWith("/WEB-INF") || path.toUpperCase().startsWith("/META-INF")) return; ResourceInfoSAKAI resourceInfo = new ResourceInfoSAKAI(path, resources); generatedXML.writeElement("D", "response", XMLWriter.OPENING); String status = new String( "HTTP/1.1 " + SakaidavStatus.SC_OK + " " + SakaidavStatus.getStatusText(SakaidavStatus.SC_OK)); // Generating href element generatedXML.writeElement("D", "href", XMLWriter.OPENING); String href = (String) req.getAttribute("javax.servlet.forward.servlet_path"); if (href == null) { href = (String) req.getAttribute("javax.servlet.include.servlet_path"); } if (href == null) { href = req.getContextPath(); } if ((href.endsWith("/")) && (path.startsWith("/"))) href += path.substring(1); else href += path; if ((resourceInfo.collection) && (!href.endsWith("/"))) href += "/"; if (M_log.isDebugEnabled()) M_log.debug("parserProperties href=" + href); generatedXML.writeText(rewriteUrl(href)); generatedXML.writeElement("D", "href", XMLWriter.CLOSING); String resourceName = justName(path); switch (type) { case FIND_ALL_PROP: generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); generatedXML.writeElement("D", "prop", XMLWriter.OPENING); generatedXML.writeProperty("D", "creationdate", getISOCreationDate(resourceInfo.creationDate)); generatedXML.writeElement("D", "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); generatedXML.writeProperty("D", "getcontentlanguage", Locale.getDefault().toString()); if (!resourceInfo.collection) { generatedXML.writeProperty("D", "getlastmodified", resourceInfo.httpDate); generatedXML.writeProperty("D", "getcontentlength", String.valueOf(resourceInfo.length)); generatedXML.writeProperty("D", "getcontenttype", resourceInfo.MIMEType); // getServletContext().getMimeType(resourceInfo.path)); generatedXML.writeProperty("D", "getetag", resourceInfo.eTag); // getETagValue(resourceInfo, true)); generatedXML.writeElement("D", "resourcetype", XMLWriter.NO_CONTENT); } else { generatedXML.writeElement("D", "resourcetype", XMLWriter.OPENING); generatedXML.writeElement("D", "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "resourcetype", XMLWriter.CLOSING); } generatedXML.writeProperty("D", "source", ""); String supportedLocks = "<D:lockentry>" + "<D:lockscope><D:exclusive/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>" + "<D:lockentry>" + "<D:lockscope><D:shared/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>"; generatedXML.writeElement("D", "supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); generateLockDiscovery(path, generatedXML); generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); generatedXML.writeElement("D", "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement("D", "status", XMLWriter.CLOSING); generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); break; case FIND_PROPERTY_NAMES: generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); generatedXML.writeElement("D", "prop", XMLWriter.OPENING); generatedXML.writeElement("D", "creationdate", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "displayname", XMLWriter.NO_CONTENT); if (!resourceInfo.collection) { generatedXML.writeElement("D", "getcontentlanguage", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "getcontentlength", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "getcontenttype", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "getetag", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "getlastmodified", XMLWriter.NO_CONTENT); } generatedXML.writeElement("D", "resourcetype", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "source", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "lockdiscovery", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); generatedXML.writeElement("D", "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement("D", "status", XMLWriter.CLOSING); generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); break; case FIND_BY_PROPERTY: Vector<String> propertiesNotFound = new Vector<String>(); // Parse the list of properties generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); generatedXML.writeElement("D", "prop", XMLWriter.OPENING); Enumeration<String> properties = propertiesVector.elements(); while (properties.hasMoreElements()) { String property = (String) properties.nextElement(); if (property.equals("creationdate")) { generatedXML.writeProperty("D", "creationdate", getISOCreationDate(resourceInfo.creationDate)); } else if (property.equals("displayname")) { generatedXML.writeElement("D", "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceInfo.displayName); generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); } else if (property.equals("getcontentlanguage")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty("D", "getcontentlanguage", Locale.getDefault().toString()); } } else if (property.equals("getcontentlength")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty("D", "getcontentlength", (String.valueOf(resourceInfo.length))); } } else if (property.equals("getcontenttype")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty("D", "getcontenttype", getServletContext().getMimeType(resourceInfo.path)); } } else if (property.equals("getetag")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty("D", "getetag", resourceInfo.eTag); // getETagValue(resourceInfo, true)); } } else if (property.equals("getlastmodified")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty("D", "getlastmodified", resourceInfo.httpDate); } } else if (property.equals("resourcetype")) { if (resourceInfo.collection) { generatedXML.writeElement("D", "resourcetype", XMLWriter.OPENING); generatedXML.writeElement("D", "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "resourcetype", XMLWriter.CLOSING); } else { generatedXML.writeElement("D", "resourcetype", XMLWriter.NO_CONTENT); } // iscollection is an MS property. Contribute uses it but seems to be // able to get along without it // } else if (property.equals("iscollection")) { // generatedXML.writeProperty // (null, "iscollection", // resourceInfo.collection ? "1" : "0"); } else if (property.equals("source")) { generatedXML.writeProperty("D", "source", ""); } else if (property.equals("supportedlock")) { supportedLocks = "<D:lockentry>" + "<D:lockscope><D:exclusive/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>" + "<D:lockentry>" + "<D:lockscope><D:shared/></D:lockscope>" + "<D:locktype><D:write/></D:locktype>" + "</D:lockentry>"; generatedXML.writeElement("D", "supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); } else if (property.equals("lockdiscovery")) { if (!generateLockDiscovery(path, generatedXML)) propertiesNotFound.addElement(property); } else { propertiesNotFound.addElement(property); } } generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); generatedXML.writeElement("D", "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement("D", "status", XMLWriter.CLOSING); generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); Enumeration<String> propertiesNotFoundList = propertiesNotFound.elements(); if (propertiesNotFoundList.hasMoreElements()) { status = new String("HTTP/1.1 " + SakaidavStatus.SC_NOT_FOUND + " " + SakaidavStatus.getStatusText(SakaidavStatus.SC_NOT_FOUND)); generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); generatedXML.writeElement("D", "prop", XMLWriter.OPENING); while (propertiesNotFoundList.hasMoreElements()) { generatedXML.writeElement("D", (String) propertiesNotFoundList.nextElement(), XMLWriter.NO_CONTENT); } generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); generatedXML.writeElement("D", "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement("D", "status", XMLWriter.CLOSING); generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); } break; } generatedXML.writeElement("D", "response", XMLWriter.CLOSING); }