List of usage examples for org.dom4j Element addAttribute
Element addAttribute(QName qName, String value);
From source file:com.liferay.alloy.tools.xmlbuilder.XMLBuilder.java
License:Open Source License
private void _createXML() { ArrayList<Component> components = getComponents(); Document doc = DocumentFactory.getInstance().createDocument(); Element root = doc.addElement("taglibs"); root.addAttribute("short-name", _DEFAULT_TAGLIB_SHORT_NAME); root.addAttribute("uri", _DEFAULT_TAGLIB_URI); root.addAttribute("tlib-version", _DEFAULT_TAGLIB_VERSION); for (Component component : components) { Element componentNode = root.addElement("component"); componentNode.addAttribute("name", component.getName()); componentNode.addAttribute("module", component.getModule()); componentNode.addAttribute("package", component.getPackage()); componentNode.addAttribute("bodyContent", String.valueOf(component.isBodyContent())); componentNode.addAttribute("alloyComponent", String.valueOf(component.isAlloyComponent())); Element attributesNode = componentNode.addElement("attributes"); Element eventsNode = componentNode.addElement("events"); for (Attribute attribute : component.getAttributes()) { Element attributeNode = attributesNode.addElement("attribute"); Element nameNode = attributeNode.addElement("name"); Element inputTypeNode = attributeNode.addElement("inputType"); Element outputTypeNode = attributeNode.addElement("outputType"); Element defaultValueNode = attributeNode.addElement("defaultValue"); Element descriptionNode = attributeNode.addElement("description"); nameNode.setText(attribute.getName()); inputTypeNode.setText(attribute.getInputType()); outputTypeNode.setText(attribute.getOutputType()); defaultValueNode.setText(attribute.getDefaultValue()); descriptionNode.addCDATA(_getAttributeDescription(attribute)); }/*from ww w. ja va 2s . co m*/ for (Attribute event : component.getEvents()) { Element eventNode = eventsNode.addElement("event"); Element nameNode = eventNode.addElement("name"); Element typeNode = eventNode.addElement("type"); Element descriptionNode = eventNode.addElement("description"); nameNode.setText(event.getName()); typeNode.setText(event.getInputType()); descriptionNode.addCDATA(_getAttributeDescription(event)); } } try { FileOutputStream fos = new FileOutputStream(_componentXML); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(fos, format); writer.write(doc); writer.flush(); System.out.println("Writing " + _componentXML); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.liferay.portal.tools.service.builder.ServiceBuilder.java
License:Open Source License
private void _parseEntity(Element entityElement) throws Exception { String ejbName = entityElement.attributeValue("name"); String humanName = entityElement.attributeValue("human-name"); String table = entityElement.attributeValue("table"); if (Validator.isNull(table)) { table = ejbName;//w ww .j av a2 s .co m if (_badTableNames.contains(ejbName)) { table += StringPool.UNDERLINE; } if (_autoNamespaceTables) { table = _portletShortName + StringPool.UNDERLINE + ejbName; } } boolean uuid = GetterUtil.getBoolean(entityElement.attributeValue("uuid")); boolean uuidAccessor = GetterUtil.getBoolean(entityElement.attributeValue("uuid-accessor")); boolean localService = GetterUtil.getBoolean(entityElement.attributeValue("local-service")); boolean remoteService = GetterUtil.getBoolean(entityElement.attributeValue("remote-service"), true); String persistenceClass = GetterUtil.getString(entityElement.attributeValue("persistence-class"), _packagePath + ".service.persistence.impl." + ejbName + "PersistenceImpl"); String finderClass = ""; File originalFinderImpl = new File(_outputPath + "/service/persistence/" + ejbName + "FinderImpl.java"); File newFinderImpl = new File(_outputPath + "/service/persistence/impl/" + ejbName + "FinderImpl.java"); if (originalFinderImpl.exists()) { FileUtils.moveFile(originalFinderImpl, newFinderImpl); String content = FileUtils.readFileToString(newFinderImpl); StringBundler sb = new StringBundler(); sb.append("package " + _packagePath + ".service.persistence.impl;\n\n"); sb.append("import " + _packagePath + ".service.persistence." + ejbName + "Finder;\n"); sb.append("import " + _packagePath + ".service.persistence." + ejbName + "Util;"); content = StringUtil.replace(content, "package " + _packagePath + ".service.persistence;", sb.toString()); writeFileRaw(newFinderImpl, content, _modifiedFileNames); } if (newFinderImpl.exists()) { finderClass = _packagePath + ".service.persistence.impl." + ejbName + "FinderImpl"; } String dataSource = entityElement.attributeValue("data-source"); String sessionFactory = entityElement.attributeValue("session-factory"); String txManager = entityElement.attributeValue("tx-manager"); boolean cacheEnabled = GetterUtil.getBoolean(entityElement.attributeValue("cache-enabled"), true); boolean jsonEnabled = GetterUtil.getBoolean(entityElement.attributeValue("json-enabled"), remoteService); boolean mvccEnabled = GetterUtil.getBoolean(entityElement.attributeValue("mvcc-enabled"), _mvccEnabled); boolean trashEnabled = GetterUtil.getBoolean(entityElement.attributeValue("trash-enabled")); boolean deprecated = GetterUtil.getBoolean(entityElement.attributeValue("deprecated")); boolean dynamicUpdateEnabled = GetterUtil.getBoolean(entityElement.attributeValue("dynamic-update-enabled"), mvccEnabled); List<EntityColumn> pkList = new ArrayList<>(); List<EntityColumn> regularColList = new ArrayList<>(); List<EntityColumn> blobList = new ArrayList<>(); List<EntityColumn> collectionList = new ArrayList<>(); List<EntityColumn> columnList = new ArrayList<>(); boolean permissionedModel = false; List<Element> columnElements = entityElement.elements("column"); if (uuid) { Element columnElement = DocumentHelper.createElement("column"); columnElement.addAttribute("name", "uuid"); columnElement.addAttribute("type", "String"); columnElements.add(0, columnElement); } if (mvccEnabled && !columnElements.isEmpty()) { Element columnElement = DocumentHelper.createElement("column"); columnElement.addAttribute("name", "mvccVersion"); columnElement.addAttribute("type", "long"); columnElements.add(0, columnElement); } for (Element columnElement : columnElements) { String columnName = columnElement.attributeValue("name"); if (columnName.equals("resourceBlockId") && !ejbName.equals("ResourceBlock")) { permissionedModel = true; } String columnDBName = columnElement.attributeValue("db-name"); if (Validator.isNull(columnDBName)) { columnDBName = columnName; if (_badColumnNames.contains(columnName)) { columnDBName += StringPool.UNDERLINE; } } String columnType = columnElement.attributeValue("type"); boolean primary = GetterUtil.getBoolean(columnElement.attributeValue("primary")); boolean accessor = GetterUtil.getBoolean(columnElement.attributeValue("accessor")); boolean filterPrimary = GetterUtil.getBoolean(columnElement.attributeValue("filter-primary")); String collectionEntity = columnElement.attributeValue("entity"); String mappingTable = columnElement.attributeValue("mapping-table"); if (Validator.isNotNull(mappingTable)) { if (_badTableNames.contains(mappingTable)) { mappingTable += StringPool.UNDERLINE; } if (_autoNamespaceTables) { mappingTable = _portletShortName + StringPool.UNDERLINE + mappingTable; } } String idType = columnElement.attributeValue("id-type"); String idParam = columnElement.attributeValue("id-param"); boolean convertNull = GetterUtil.getBoolean(columnElement.attributeValue("convert-null"), true); boolean lazy = GetterUtil.getBoolean(columnElement.attributeValue("lazy"), true); boolean localized = GetterUtil.getBoolean(columnElement.attributeValue("localized")); boolean colJsonEnabled = GetterUtil.getBoolean(columnElement.attributeValue("json-enabled"), jsonEnabled); boolean containerModel = GetterUtil.getBoolean(columnElement.attributeValue("container-model")); boolean parentContainerModel = GetterUtil .getBoolean(columnElement.attributeValue("parent-container-model")); EntityColumn col = new EntityColumn(columnName, columnDBName, columnType, primary, accessor, filterPrimary, collectionEntity, mappingTable, idType, idParam, convertNull, lazy, localized, colJsonEnabled, containerModel, parentContainerModel); if (primary) { pkList.add(col); } if (columnType.equals("Collection")) { collectionList.add(col); } else { regularColList.add(col); if (columnType.equals("Blob")) { blobList.add(col); } } columnList.add(col); if (Validator.isNotNull(collectionEntity) && Validator.isNotNull(mappingTable)) { EntityMapping entityMapping = new EntityMapping(mappingTable, ejbName, collectionEntity); if (!_entityMappings.containsKey(mappingTable)) { _entityMappings.put(mappingTable, entityMapping); } } } EntityOrder order = null; Element orderElement = entityElement.element("order"); if (orderElement != null) { boolean asc = true; if ((orderElement.attribute("by") != null) && orderElement.attributeValue("by").equals("desc")) { asc = false; } List<EntityColumn> orderColsList = new ArrayList<>(); order = new EntityOrder(asc, orderColsList); List<Element> orderColumnElements = orderElement.elements("order-column"); for (Element orderColElement : orderColumnElements) { String orderColName = orderColElement.attributeValue("name"); boolean orderColCaseSensitive = GetterUtil .getBoolean(orderColElement.attributeValue("case-sensitive"), true); boolean orderColByAscending = asc; String orderColBy = GetterUtil.getString(orderColElement.attributeValue("order-by")); if (orderColBy.equals("asc")) { orderColByAscending = true; } else if (orderColBy.equals("desc")) { orderColByAscending = false; } EntityColumn col = Entity.getColumn(orderColName, columnList); col.setOrderColumn(true); col = (EntityColumn) col.clone(); col.setCaseSensitive(orderColCaseSensitive); col.setOrderByAscending(orderColByAscending); orderColsList.add(col); } } List<EntityFinder> finderList = new ArrayList<>(); List<Element> finderElements = entityElement.elements("finder"); if (uuid) { if (columnList.contains(new EntityColumn("companyId"))) { Element finderElement = DocumentHelper.createElement("finder"); finderElement.addAttribute("name", "Uuid_C"); finderElement.addAttribute("return-type", "Collection"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "uuid"); finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "companyId"); finderElements.add(0, finderElement); } if (columnList.contains(new EntityColumn("groupId"))) { Element finderElement = DocumentHelper.createElement("finder"); if (ejbName.equals("Layout")) { finderElement.addAttribute("name", "UUID_G_P"); } else { finderElement.addAttribute("name", "UUID_G"); } finderElement.addAttribute("return-type", ejbName); finderElement.addAttribute("unique", "true"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "uuid"); finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "groupId"); if (ejbName.equals("Layout")) { finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "privateLayout"); } finderElements.add(0, finderElement); } Element finderElement = DocumentHelper.createElement("finder"); finderElement.addAttribute("name", "Uuid"); finderElement.addAttribute("return-type", "Collection"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "uuid"); finderElements.add(0, finderElement); } if (permissionedModel) { Element finderElement = DocumentHelper.createElement("finder"); finderElement.addAttribute("name", "ResourceBlockId"); finderElement.addAttribute("return-type", "Collection"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "resourceBlockId"); finderElements.add(0, finderElement); } String alias = TextFormatter.format(ejbName, TextFormatter.I); if (_badAliasNames.contains(StringUtil.toLowerCase(alias))) { alias += StringPool.UNDERLINE; } for (Element finderElement : finderElements) { String finderName = finderElement.attributeValue("name"); String finderReturn = finderElement.attributeValue("return-type"); boolean finderUnique = GetterUtil.getBoolean(finderElement.attributeValue("unique")); String finderWhere = finderElement.attributeValue("where"); if (Validator.isNotNull(finderWhere)) { for (EntityColumn column : columnList) { String name = column.getName(); finderWhere = StringUtil.replace(finderWhere, name, alias + "." + name); } } boolean finderDBIndex = GetterUtil.getBoolean(finderElement.attributeValue("db-index"), true); List<EntityColumn> finderColsList = new ArrayList<>(); List<Element> finderColumnElements = finderElement.elements("finder-column"); for (Element finderColumnElement : finderColumnElements) { String finderColName = finderColumnElement.attributeValue("name"); boolean finderColCaseSensitive = GetterUtil .getBoolean(finderColumnElement.attributeValue("case-sensitive"), true); String finderColComparator = GetterUtil.getString(finderColumnElement.attributeValue("comparator"), "="); String finderColArrayableOperator = GetterUtil .getString(finderColumnElement.attributeValue("arrayable-operator")); EntityColumn col = Entity.getColumn(finderColName, columnList); if (!col.isFinderPath()) { col.setFinderPath(true); } col = (EntityColumn) col.clone(); col.setCaseSensitive(finderColCaseSensitive); col.setComparator(finderColComparator); col.setArrayableOperator(finderColArrayableOperator); col.validate(); finderColsList.add(col); } finderList.add(new EntityFinder(finderName, finderReturn, finderUnique, finderWhere, finderDBIndex, finderColsList)); } List<Entity> referenceList = new ArrayList<>(); List<String> unresolvedReferenceList = new ArrayList<>(); if (_build) { List<Element> referenceElements = entityElement.elements("reference"); Set<String> referenceSet = new TreeSet<>(); for (Element referenceElement : referenceElements) { String referencePackage = referenceElement.attributeValue("package-path"); String referenceEntity = referenceElement.attributeValue("entity"); referenceSet.add(referencePackage + "." + referenceEntity); } if (!_packagePath.equals("com.liferay.counter")) { referenceSet.add("com.liferay.counter.Counter"); } if (_autoImportDefaultReferences) { referenceSet.add("com.liferay.portal.ClassName"); referenceSet.add("com.liferay.portal.Resource"); referenceSet.add("com.liferay.portal.User"); } for (String referenceName : referenceSet) { try { referenceList.add(getEntity(referenceName)); } catch (RuntimeException re) { unresolvedReferenceList.add(referenceName); } } } List<String> txRequiredList = new ArrayList<>(); List<Element> txRequiredElements = entityElement.elements("tx-required"); for (Element txRequiredEl : txRequiredElements) { String txRequired = txRequiredEl.getText(); txRequiredList.add(txRequired); } boolean resourceActionModel = _resourceActionModels.contains(_packagePath + ".model." + ejbName); _ejbList.add(new Entity(_packagePath, _portletName, _portletShortName, ejbName, humanName, table, alias, uuid, uuidAccessor, localService, remoteService, persistenceClass, finderClass, dataSource, sessionFactory, txManager, cacheEnabled, dynamicUpdateEnabled, jsonEnabled, mvccEnabled, trashEnabled, deprecated, pkList, regularColList, blobList, collectionList, columnList, order, finderList, referenceList, unresolvedReferenceList, txRequiredList, resourceActionModel)); }
From source file:com.litt.core.security.license.gui.ProductPanel.java
public ProductPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; setLayout(gridBagLayout);//from ww w . j ava2s. c o m JLabel lblProductCode = new JLabel("\u4EA7\u54C1\u7F16\u53F7\uFF1A"); GridBagConstraints gbc_lblProductCode = new GridBagConstraints(); gbc_lblProductCode.anchor = GridBagConstraints.EAST; gbc_lblProductCode.insets = new Insets(0, 0, 5, 5); gbc_lblProductCode.gridx = 0; gbc_lblProductCode.gridy = 0; add(lblProductCode, gbc_lblProductCode); textFieldProductCode = new JTextField(); GridBagConstraints gbc_textFieldProductCode = new GridBagConstraints(); gbc_textFieldProductCode.insets = new Insets(0, 0, 5, 0); gbc_textFieldProductCode.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldProductCode.gridx = 1; gbc_textFieldProductCode.gridy = 0; add(textFieldProductCode, gbc_textFieldProductCode); textFieldProductCode.setColumns(10); JLabel lblProductName = new JLabel("\u4EA7\u54C1\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblProductName = new GridBagConstraints(); gbc_lblProductName.insets = new Insets(0, 0, 5, 5); gbc_lblProductName.anchor = GridBagConstraints.EAST; gbc_lblProductName.gridx = 0; gbc_lblProductName.gridy = 1; add(lblProductName, gbc_lblProductName); textFieldProductName = new JTextField(); GridBagConstraints gbc_textFieldProductName = new GridBagConstraints(); gbc_textFieldProductName.insets = new Insets(0, 0, 5, 0); gbc_textFieldProductName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldProductName.gridx = 1; gbc_textFieldProductName.gridy = 1; add(textFieldProductName, gbc_textFieldProductName); textFieldProductName.setColumns(10); JLabel lblSecuritykey = new JLabel("\u5BC6\u94A5\uFF1A"); GridBagConstraints gbc_lblSecuritykey = new GridBagConstraints(); gbc_lblSecuritykey.anchor = GridBagConstraints.EAST; gbc_lblSecuritykey.insets = new Insets(0, 0, 5, 5); gbc_lblSecuritykey.gridx = 0; gbc_lblSecuritykey.gridy = 2; add(lblSecuritykey, gbc_lblSecuritykey); textFieldSecurityKey = new JTextField(); GridBagConstraints gbc_textFieldSecurityKey = new GridBagConstraints(); gbc_textFieldSecurityKey.insets = new Insets(0, 0, 5, 0); gbc_textFieldSecurityKey.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldSecurityKey.gridx = 1; gbc_textFieldSecurityKey.gridy = 2; add(textFieldSecurityKey, gbc_textFieldSecurityKey); textFieldSecurityKey.setColumns(10); JButton btnSave = new JButton("Save"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String productCode = textFieldProductCode.getText(); String productName = textFieldProductName.getText(); String securityKey = textFieldSecurityKey.getText(); File productDir = new File(Gui.HOME_PATH, productCode); if (productDir.exists() && productDir.isDirectory()) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "????"); } else { productDir.mkdirs(); //?? File configFile = new File(Gui.HOME_PATH, "config.xml"); try { Document document = XmlUtils.readXml(configFile); Element rootE = document.getRootElement(); Element productE = rootE.addElement("product"); productE.addAttribute("code", productCode); productE.addAttribute("name", productName); productE.addAttribute("securityKey", securityKey); XmlUtils.writeXml(configFile, document); //? File priKeyFilePath = new File(productDir, "private.key"); File pubKeyFilePath = new File(productDir, "license.key"); DSATool utils = new DSATool(Algorithm.DSA, securityKey); utils.saveKeys(priKeyFilePath.getPath(), pubKeyFilePath.getPath()); } catch (Exception e1) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), e1.getMessage()); } // for(int i=0;i<productList.size();i++) // { // Element productE = (Element)productList.get(i); // String productCode = productE.attributeValue("code"); // // List customerList = productE.elements(); // for(int j=0;j<customerList.size();j++) // { // Element customerE = (Element)customerList.get(j); // // LicenseConfig licenseConfig = new LicenseConfig(); // licenseConfig.setProductCode(productCode); // licenseConfig.setCustomerCode(customerE.attributeValue("code")); // licenseConfig.setPriKeyFilePath(customerE.elementText("priKeyFilePath")); // licenseConfig.setPubKeyFilePath(customerE.elementText("pubKeyFilePath")); // licenseConfig.setLicenseId(customerE.elementText("licenseId")); // licenseConfig.setLicenseFilePath(customerE.elementText("licenseFilePath")); // licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense")); // licenseConfig.setRootFilePath(Gui.HOME_PATH); // comboBox_config.addItem(licenseConfig); // if(i==0&&j==0) // { // File licenseFile = new File(Gui.HOME_PATH+licenseConfig.getLicenseFilePath()); // currentLicenseConfig = licenseConfig; // loadLicense(licenseFile); // gui.setCurrentLicenseConfig(currentLicenseConfig); // } // } // } JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); } } }); GridBagConstraints gbc_btnSave = new GridBagConstraints(); gbc_btnSave.insets = new Insets(0, 0, 5, 0); gbc_btnSave.gridx = 1; gbc_btnSave.gridy = 3; add(btnSave, gbc_btnSave); }
From source file:com.litt.core.security.license.LicenseService.java
/** * ?License// w w w .j ava 2s.co m * @param homePath * @param license * @param priKeyFile * @param licenseFile * @throws Exception */ public void save(String homePath, String productCode, String customerCode, License license, File priKeyFile, File licenseFile) throws Exception { //???? DigitalSignatureTool utils = new DigitalSignatureTool("DSA"); utils.readPriKey(priKeyFile.getAbsolutePath()); //?? String signedData = utils.sign(license.toString()); //?????? license.setSignature(signedData); LicenseManager.writeLicense(license, licenseFile); String licenseContent = XmlUtils.readXml(licenseFile).asXML(); //DES ISecurity security = new DESTool(license.getLicenseId(), Algorithm.BLOWFISH); licenseContent = security.encrypt(licenseContent); //config.xml File configFile = ResourceUtils.getFile(homePath + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element rootE = document.getRootElement(); Element produceNode = (Element) document.selectSingleNode("//product[@code='" + productCode + "']"); Element customerElement = produceNode.addElement("customer"); customerElement.addAttribute("code", customerCode); customerElement.addElement("licenseId").setText(license.getLicenseId()); customerElement.addElement("encryptedLicense").setText(licenseContent); XmlUtils.writeXml(configFile, document); XmlUtils.formatXml(configFile, XmlUtils.FORMAT_PREETY); }
From source file:com.liveneo.plat.web.action.MakeLicfile.java
public static Document initLicFile(LicForm licForm) { Document doc = DocumentHelper.createDocument(); Element corporationEle = doc.addElement("Liveneo"); corporationEle.addAttribute("platformType", licForm.getPlatformType()); corporationEle.addAttribute("sid", licForm.getSid()); corporationEle.addAttribute("version", licForm.getF_version()); Element licElement = corporationEle.addElement("License"); licElement.addAttribute("genDate", licForm.getGenDate()); licElement.addAttribute("genTime", licForm.getGenTime()); licElement.addAttribute("type", licForm.getType()); licElement.addAttribute("version", licForm.getLic_version()); Element hostidEle = licElement.addElement("HostID"); hostidEle.setText(licForm.getHostID()); Element notesEle = licElement.addElement("Notes"); notesEle.setText(licForm.getNotes()); Element productEle = licElement.addElement("Product"); Element pdNameEle = productEle.addElement("Name"); Element pdDispEle = productEle.addElement("DisplayName"); Element pdVersion = productEle.addElement("Version"); pdNameEle.setText(licForm.getProductName()); pdDispEle.setText(licForm.getProductDisplayName()); pdVersion.setText(licForm.getProductVersion()); Element featuresEle = licElement.addElement("Features"); if (null != licForm.getFeatureList()) { for (FeatureForm ff : licForm.getFeatureList()) { Element feaEle = featuresEle.addElement("Feature"); feaEle.addAttribute("name", ff.getFeatureName()); Element disnameEle = feaEle.addElement("DisplayName"); disnameEle.setText(ff.getFeatureDisplayName()); Element fvalueEle = feaEle.addElement("Value"); fvalueEle.setText(ff.getFeatureValue()); Element fexpEle = feaEle.addElement("ExpirationDate"); fexpEle.setText(ff.getFeatureExpDate()); }//from w w w .j a v a 2 s. c o m } Element signElement = corporationEle.addElement("Signature"); signElement.setText(licForm.getSignature()); return doc; }
From source file:com.love320.templateparser.label.impl.LabelBeanDaoImpl.java
License:Apache License
private boolean upSeting(LabelBean labelBean, Element labelElement) { //? labelBean? String name = labelBean.getName(); String parameters = labelBean.getParameters(); String template = labelBean.getTemplate(); String bean = labelBean.getBean(); String note = labelBean.getNote(); //Element?//from w ww . ja va 2s. c om labelElement.addAttribute("name", name); labelElement.addElement("parameters").addCDATA(parameters); labelElement.addElement("template").addCDATA(template); labelElement.addElement("bean").setText(bean); labelElement.addElement("note").setText(note); return true; }
From source file:com.love320.templateparser.templateprocess.impl.SeparationImpl.java
License:Apache License
private void addContent(String str, int type, Element contentElement) { switch (type) { case 1://from w ww . j ava2 s . c om Element singStringElement = contentElement.addElement("item"); singStringElement.addAttribute("type", "string"); singStringElement.addCDATA(str); break; case 2: Element singLalbelElement = contentElement.addElement("item"); singLalbelElement.addAttribute("type", "label"); singLalbelElement.setText(str); break; case 3: Element singSymbolsElement = contentElement.addElement("item"); singSymbolsElement.addAttribute("type", "symbols"); singSymbolsElement.setText(str); break; default: break; } }
From source file:com.ltmonitor.jt809.app.GlobalConfig.java
public static void setModel(ParameterModel pm) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("config"); doc.setRootElement(root);/*from ww w .j a va 2s . c o m*/ Element pe = root.addElement("parameter"); pe.addAttribute("platip", pm.getPlatformIP()); pe.addAttribute("idletime", String.valueOf(pm.getIdleTime())); pe.addAttribute("localport", String.valueOf(pm.getLocalPort())); pe.addAttribute("platid", String.valueOf(pm.getPlatformCenterId())); pe.addAttribute("platport", String.valueOf(pm.getPlatformPort())); pe.addAttribute("platuserid", String.valueOf(pm.getPlatformUserName())); pe.addAttribute("platpassword", String.valueOf(pm.getPlatformPass())); pe.addAttribute("miyaom", String.valueOf(pm.getMiyaoM())); pe.addAttribute("miyaoa", String.valueOf(pm.getMiyaoA())); pe.addAttribute("miyaoc", String.valueOf(pm.getMiyaoC())); pe.addAttribute("protocolver", pm.getProtocolVer()); pe.addAttribute("localip", pm.getLocalIp()); pe.addAttribute("licenseno", pm.getLicenseNo()); pe.addAttribute("username", pm.getUsername()); try { FileWriter out = new FileWriter(CONFIG_PATH + "database.xml"); XmlUtils.printXml(doc, out); } catch (Exception ex) { //this.logger.warn("" + ex.getMessage()); } }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.bot.BotRegistrationImpl.java
License:Apache License
protected static IQ buildAckIQ(String fromJID, String toJID, String incomingMessageId) { IQ ackIQ = new IQ(IQ.Type.set); Element mmxElement = ackIQ.setChildElement(Constants.MMX, Constants.MMX_NS_MSG_ACK); mmxElement.addAttribute(Constants.MMX_ATTR_COMMAND, Constants.MessageCommand.ack.toString()); mmxElement.addAttribute(Constants.MMX_ATTR_CTYPE, GsonData.CONTENT_TYPE_JSON); MsgAck msgAck = new MsgAck(fromJID, toJID, incomingMessageId); Gson gson = GsonData.getGson();/* www . ja va2 s . co m*/ String ackJSON = gson.toJson(msgAck); mmxElement.setText(ackJSON); return ackIQ; }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.bot.RPSLSPlayerBotProcessor.java
License:Apache License
/** * Build the acceptance message./*from w w w .j a v a 2 s .c o m*/ * @param sourceFrom * @param sourceTo * @param gameInfo * @return */ protected Message buildAcceptanceMessage(JID sourceFrom, JID sourceTo, RPSLSGameInfo gameInfo) { JID fromJID = sourceTo; JID toJID = sourceFrom; String appId = JIDUtil.getAppId(toJID); Message message = new Message(); message.setTo(toJID); message.setFrom(fromJID); MessageIdGenerator generator = new MessageIdGeneratorImpl(); String id = generator.generate(toJID.getNode(), appId, null); message.setID(id); message.setType(Message.Type.chat); Element mmx = message.addChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD); Element internalMeta = mmx.addElement(Constants.MMX_MMXMETA); String userId = JIDUtil.getUserId(toJID); String devId = fromJID.getResource(); //mmx meta String mmxMetaJSON = MMXMetaBuilder.build(userId, devId); internalMeta.setText(mmxMetaJSON); Element meta = mmx.addElement(Constants.MMX_META); AcceptanceRPSLSGameInfo acceptance = new AcceptanceRPSLSGameInfo(); acceptance.setGameId(gameInfo.gameId); acceptance.setLosses(0); acceptance.setWins(0); acceptance.setTies(0); Date current = new Date(); acceptance.setTimestamp(current.getTime()); acceptance.setType(RPSLSMessageType.ACCEPTANCE); String myUserId = JIDUtil.getUserId(sourceTo); acceptance.setUsername(myUserId); // user id of the bot user. String acceptanceJSON = acceptance.toJson(); meta.setText(acceptanceJSON); Element payloadElement = mmx.addElement(Constants.MMX_PAYLOAD); DateFormat fmt = Utils.buildISO8601DateFormat(); String formattedDateTime = fmt.format(new Date()); payloadElement.addAttribute(Constants.MMX_ATTR_STAMP, formattedDateTime); String text = INVITE_REPLY_MESSAGE; payloadElement.setText(text); payloadElement.addAttribute(Constants.MMX_ATTR_CHUNK, MessageBuilder.buildChunkAttributeValue(text)); return message; }