List of usage examples for org.dom4j QName QName
public QName(String name)
From source file:com.arc.xml.Element.java
License:Open Source License
@Override public void setName(String name) { setQName(new QName(name)); }
From source file:com.cladonia.xml.XAttribute.java
License:Open Source License
/** * Constructs a default element with an initial name. * * @param name the unmutable name.//w w w . ja v a 2 s . co m */ public XAttribute(String name) { this(new QName(name), null); }
From source file:com.cladonia.xml.XAttribute.java
License:Open Source License
/** * Constructs a default element with an initial name. * * @param name the unmutable name./*from www .j a va2s .com*/ */ public XAttribute(String name, String value) { this(new QName(name), value); }
From source file:com.cladonia.xml.XElement.java
License:Open Source License
/** * Constructs a default element with an initial name. * * @param name the unmutable name./* ww w. j av a 2 s. c o m*/ */ public XElement(String name) { this(new QName(name), true); }
From source file:com.heliosapm.aa4h.parser.XMLQueryParser.java
License:Apache License
/** * End Document SAX ContentHandler Method. * Fired at the end of the document parsing event. * At this point the query has been fully parsed and the named or criteria query is complete. * This method executes the query and sets the result field, handling any errors. * @see org.xml.sax.ContentHandler#endDocument() * @throws SAXException//from ww w .jav a 2 s .com * TODO Clean up the timeout handling. The current one is Oracle specific. We need the timeout handling to differentiate between standard DB Errors and timeouts as a result of a user requested timeout. */ @SuppressWarnings("unchecked") public void endDocument() throws SAXException { parseTime = System.currentTimeMillis() - parseTime; try { if (isNamedQuery) { result = query.list(); } else { Criteria finalCriteria = (Criteria) criteriaStack.pop(); Projection p = ((CriteriaImpl) finalCriteria).getProjection(); if (p != null) { aliases = p.getAliases(); } result = finalCriteria.list(); } } catch (Exception ex) { try { if (ex.getCause().getMessage().startsWith("ORA-01013")) { toe = new TimeoutException("Query " + queryName + " Timed Out"); QName q = new QName("Error"); DefaultElement de = new DefaultElement(q); de.addAttribute("reason", "Query Time Out"); result = new ArrayList<DefaultElement>(); result.add(de); endTime = System.currentTimeMillis(); } else { throw new SAXException("Unknown Exception At List Time for Query:" + queryName, ex); } } catch (Exception e) { log.error("Unknown Exception At List Time for Query:" + queryName, ex); throw new SAXException("Unknown Exception At List Time for Query:" + queryName, ex); } } endTime = System.currentTimeMillis(); if (log.isDebugEnabled()) { log.info(new StringBuffer("CATSQuery[").append(queryName).append("] Returned ").append(result.size()) .append(" elements in ").append((endTime - startTime)).append(" ms.").toString()); log.info("Elapsed Time For [" + queryName + "]:" + (endTime - startTime) + " ms."); } }
From source file:com.ibm.cognos.API.java
License:Open Source License
public Vector getColumnTitles() { Vector columnTitles = new Vector(); // Check for column titles based on dataItemLabel List columnTitleList = (List) oDocument .selectNodes("/report/layouts/layout/reportPages/page/pageBody/contents/" + "list/listColumns/listColumn/listColumnTitle/" + "contents/textItem/dataSource/dataItemLabel"); for (int i = 0; i < columnTitleList.size(); i++) { Element e = (Element) columnTitleList.get(i); String sColumnTitle = null; sColumnTitle = e.attributeValue(new QName("refDataItem")); columnTitles.add(sColumnTitle);/*from w w w . ja v a2 s .c o m*/ } // Check for columnTitles base on staticValue List columnStaticTitleList = (List) oDocument .selectNodes("/report/layouts/layout/reportPages/page/pageBody/contents/" + "list/listColumns/listColumn/listColumnTitle/" + "contents/textItem/dataSource/staticValue"); for (int i = 0; i < columnStaticTitleList.size(); i++) { Element e = (Element) columnStaticTitleList.get(i); String sColumnTitle = null; sColumnTitle = e.getText(); columnTitles.add(sColumnTitle); } return columnTitles; }
From source file:com.zimbra.common.soap.Element.java
License:Open Source License
public static QName getQName(String qualifiedName) { String[] parts = qualifiedName.split("\\."); return new QName(parts[parts.length - 1]); }
From source file:net.sf.jguard.ext.authorization.manager.XmlAuthorizationManager.java
License:Open Source License
private void insertPermissionsAndInheritance(Element principalElement, RolePrincipal ppal) { Element permsRefElement = principalElement.addElement(PERMISSIONS_REF); Set perms = ppal.getPermissions(); for (Object orphanedPerm : perms) { Permission perm = (Permission) orphanedPerm; Element permRef = permsRefElement.addElement(PERMISSION_REF); //add the name attribute Attribute idAttribute = new UserDataAttribute(new QName(ID)); idAttribute.setValue("" + perm.getId()); permRef.add(idAttribute);/*from w ww . j a v a 2 s .co m*/ } //role inheritance is only supported by RolePrincipal if (ppal.getDescendants().size() > 0) { Element descendants = principalElement.addElement(DESCENDANTS); //add the descendants of this role for (RolePrincipal o : ppal.getDescendants()) { Element principalRef = descendants.addElement(PRINCIPAL_REF); Attribute idAttribute = new UserDataAttribute(new QName(ID)); idAttribute.setValue("" + o.getId()); principalRef.add(idAttribute); } } }
From source file:net.unicon.academus.apps.briefcase.migrate.BriefcaseMigrator.java
License:Open Source License
public static void main(String[] args) { System.out.println("Starting Briefcase portlet migration of data from Academus 1.5 " + " to Academus 1.6"); if (args.length == 2) { try {/* w w w . j a v a 2 s . c om*/ DataSource ds = new SimpleDataSource(); SAXReader reader = new SAXReader(); // replace the old urls with the new classpaths System.out.println("Updating the resource urls."); updateUrl(ds); updateSharedResourceUrls(ds); // replace the OWNER access type. System.out.println("Updating the accessTypes."); updateAccessType(ds); // set the uni_sequence table for the RdbmsAccessBroker Counter // and the FSA_Kernel_Sequencer updateSequencers(ds); // read the old config file // and correct the classpaths for all the access brokers. Document oldDoc = reader.read(args[0]); DOMDocumentFactory dFac = new DOMDocumentFactory(); // Get all access brokers List brokers = oldDoc.selectNodes("//access-broker"); Element broker = null; // Change access brokers to point to alchemist instead of academus for (int i = 0; i < brokers.size(); i++) { broker = (Element) brokers.get(i); String implValue = broker.attributeValue("impl").replaceFirst("academus", "alchemist"); broker.addAttribute("impl", implValue); } // Get the Access Broker under the personal Drive, and make sure it's a JIT broker Element targetsJitAccessBroker = (Element) ((Element) oldDoc.selectNodes( "/briefcase/drive[@handle='personal']/access-broker[@impl='net.unicon.alchemist.access.jit.JitAccessBroker']") .get(0)).detach(); // Only enter this code if the personal drive section was successful selected if (targetsJitAccessBroker != null) { // Create new permissions element, mirroring targets element Element permissionsJitAccessBroker = (Element) targetsJitAccessBroker.clone(); // Change handles targetsJitAccessBroker.addAttribute("handle", "personal-resourses-t"); permissionsJitAccessBroker.addAttribute("handle", "personal-resourses-p"); // Create new permissions access-broker Element permAccessBroker = dFac.createElement(new QName("access-broker"), 2); permAccessBroker.addAttribute("handle", "personal-jit"); permAccessBroker.addAttribute("impl", PermissionsAccessBroker.class.getName()); // Create new access element and add it to permAccessBroker Element permAccess = dFac.createElement(new QName("access"), 1); permAccess.addAttribute("impl", BriefcaseAccessType.class.getName()); permAccessBroker.add(permAccess); // Create targets and permissions elements and add to the new permissions access-broker Element targets = permAccessBroker.addElement("targets"); targets.add(targetsJitAccessBroker); Element permissions = permAccessBroker.addElement("permissions"); permissions.add(permissionsJitAccessBroker); // Add new permissions access broker to the drive Element curDrive = (Element) oldDoc.selectNodes("/briefcase/drive[@handle='personal']").get(0); curDrive.add(permAccessBroker); // // Change targets internals // List targetsAccess = targets.selectNodes("access-broker/jit-rule/behavior/access"); for (int i = 0; i < targetsAccess.size(); i++) { // Add impl attribute with value of fully-qualified class name ((Element) targetsAccess.get(i)).addAttribute("impl", DummyAccessType.class.getName()); // Get all child type elements and remove them List types = ((Element) targetsAccess.get(i)).elements(); for (int j = 0; j < types.size(); j++) { ((Element) types.get(j)).detach(); } // Add a single dummy element Element eType = dFac.createElement(new QName("type"), 2); eType.addAttribute("value", "GRANT"); eType.addAttribute("handle", "DUMMY"); ((Element) targetsAccess.get(i)).add(eType); } // Add internal access broker's access element Element targetsIAccessBroker = (Element) (targets.selectNodes("access-broker/access-broker") .get(0)); Element targetsIAccess = dFac.createElement(new QName("access"), 1); targetsIAccess.addAttribute("impl", DummyAccessType.class.getName()); targetsIAccessBroker.add(targetsIAccess); // // Change permissions internals // List permissionsAccess = permissions.selectNodes("access-broker/jit-rule/behavior/access"); for (int i = 0; i < permissionsAccess.size(); i++) { // Add impl attribute with value of fully-qualified class name ((Element) permissionsAccess.get(i)).addAttribute("impl", BriefcaseAccessType.class.getName()); // Get all child type elements and replace them List types = ((Element) permissionsAccess.get(i)).elements(); for (int j = 0; j < types.size(); j++) { Attribute value = ((Element) types.get(j)).attribute("value"); String text = value.getValue(); value.setValue("GRANT"); if (text.equals("0")) { BriefcaseAccessType[] aTypes = BriefcaseAccessType.getInstances(); ((Element) types.get(j)).addAttribute("handle", aTypes[0].getName()); for (int k = 1; k < aTypes.length; k++) { Element eType = dFac.createElement(new QName("type"), 2); eType.addAttribute("value", "GRANT"); eType.addAttribute("handle", aTypes[k].getName()); ((Element) permissionsAccess.get(i)).add(eType); } } else { ((Element) types.get(j)).addAttribute("handle", BriefcaseAccessType.getAccessType(Integer.parseInt(text)).getName()); } } } // Change other elements in the permissions section List permissionsBehavior = permissions.selectNodes("access-broker/jit-rule/behavior"); for (int i = 0; i < permissionsBehavior.size(); i++) { Element trigger = (Element) ((Element) permissionsBehavior.get(i)).elements("trigger") .get(0); Element target = (Element) ((Element) permissionsBehavior.get(i)).elements("target").get(0); Element creator = (Element) ((Element) permissionsBehavior.get(i)).elements("creator") .get(0); // Insert trigger text into target target.addAttribute("type", "GROUP"); target.addText(trigger.getText()); // Remove current creator element creator.detach(); // Add new current creator element Element eCreator = dFac.createElement(new QName("creator"), 1); eCreator.addAttribute("impl", DummyCreator.class.getName()); ((Element) permissionsBehavior.get(i)).add(eCreator); } // Change internal access broker's name Element permissionsIAccessBroker = (Element) (permissions .selectNodes("access-broker/access-broker").get(0)); permissionsIAccessBroker.addAttribute("handle", "personal-resources-p-i"); // Add internal access broker's access element Element permissionsIAccess = dFac.createElement(new QName("access"), 1); permissionsIAccess.addAttribute("impl", BriefcaseAccessType.class.getName()); permissionsIAccessBroker.add(permissionsIAccess); } List access = oldDoc.selectNodes("/briefcase/drive[@handle!='personal']//access"); for (int i = 0; i < access.size(); i++) { // Add impl attribute with value of fully-qualified class name ((Element) access.get(i)).addAttribute("impl", BriefcaseAccessType.class.getName()); List types = ((Element) access.get(i)).elements(); for (int j = 0; j < types.size(); j++) { Attribute value = ((Element) types.get(j)).attribute("value"); String text = value.getValue(); value.setValue("GRANT"); if (text.equals("0")) { BriefcaseAccessType[] aTypes = BriefcaseAccessType.getInstances(); ((Element) types.get(j)).addAttribute("handle", aTypes[0].getName()); for (int k = 1; k < aTypes.length; k++) { Element eType = dFac.createElement(new QName("type"), 2); eType.addAttribute("value", "GRANT"); eType.addAttribute("handle", aTypes[k].getName()); ((Element) access.get(i)).add(eType); } } else { ((Element) types.get(j)).addAttribute("handle", BriefcaseAccessType.getAccessType(Integer.parseInt(text)).getName()); } } } // add impl attribute to specify the UserDirectory impl to user-attribute element List userAttr = oldDoc.selectNodes("//user-attribute"); for (int i = 0; i < userAttr.size(); i++) { ((Element) userAttr.get(i)).addAttribute("impl", "net.unicon.academus.apps.briefcase.UserAttributeDirectory"); } //replace the resource factory urls List entries = oldDoc .selectNodes("/briefcase/drive[@handle!='personal']//access-broker/entry[@target!='']"); for (int i = 0; i < entries.size(); i++) { ((Element) entries.get(i)).addAttribute("target", ((Element) entries.get(i)) .attributeValue("target").replaceAll("academus.resource.factory", "demetrius.fac")); } // add access element to specify the AccessType to the RdbmsAccessBroker brokers = oldDoc.selectNodes("/briefcase/drive[@handle!='personal']//access-broker[@impl='" + RdbmsAccessBroker.class.getName() + "']"); for (int i = 0; i < brokers.size(); i++) { broker = (Element) brokers.get(i); Element eType = dFac.createElement(new QName("access"), 1); eType.addAttribute("impl", BriefcaseAccessType.class.getName()); broker.add(eType); } // add the civis address book information. Element drive = (Element) oldDoc.selectSingleNode("briefcase"); drive.addComment("Civis implementation to be used to resolve usernames and group paths" + " to academus users and groups. This should not require" + " modification, as it utilized the Academus framework for gathering this" + " information."); Element civis = dFac.createElement("civis"); civis.addAttribute("id", "addressBook"); civis.addAttribute("impl", "net.unicon.civis.fac.academus.AcademusCivisFactory"); Element restrictor = dFac.createElement("restrictor"); restrictor.addAttribute("impl", "net.unicon.civis.grouprestrictor.AcademusGroupRestrictor"); civis.add(restrictor); drive.add(civis); File f = new File(args[1]); PrintWriter pw = new PrintWriter(new FileOutputStream(f)); pw.write(oldDoc.asXML()); pw.flush(); pw.close(); System.out.println( "Done. Enjoy !! \n Remember to the use the migrated config file with the 1.6 deploy."); } catch (Exception e) { e.printStackTrace(); } } else { usage(); } }
From source file:org.apereo.portal.groups.pags.dao.jpa.PersonAttributesGroupDefinitionImpl.java
License:Apache License
@Override public void toElement(org.dom4j.Element parent) { if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }/* w w w. j ava 2 s. c o m*/ parent.addElement("name").addText(this.getName()); parent.addElement("description").addText(this.getDescription()); if (!members.isEmpty()) { org.dom4j.Element elementMembers = DocumentHelper.createElement(new QName("members")); for (IPersonAttributesGroupDefinition member : members) { elementMembers.addElement("member-name").addText(member.getName()); } parent.add(elementMembers); } if (!testGroups.isEmpty()) { org.dom4j.Element elementSelectionTest = DocumentHelper.createElement(new QName("selection-test")); for (IPersonAttributesGroupTestGroupDefinition testGroup : testGroups) { testGroup.toElement(elementSelectionTest); } parent.add(elementSelectionTest); } }