List of usage examples for javax.xml.namespace QName getLocalPart
public String getLocalPart()
Get the local part of this QName
.
From source file:com.evolveum.midpoint.web.page.admin.reports.component.AuditLogViewerPanel.java
protected List<IColumn<AuditEventRecordType, String>> initColumns() { List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<>(); IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>( createStringResource("AuditEventRecordType.timestamp"), "timestamp") { private static final long serialVersionUID = 1L; @Override/*from w w w.j ava 2 s. c o m*/ protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) { return new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { XMLGregorianCalendar time = rowModel.getObject().getTimestamp(); return WebComponentUtil.formatDate(time); } }; } @Override public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) { AuditEventRecordType record = rowModel.getObject(); try { AuditEventRecord.adopt(record, getPageBase().getPrismContext()); } catch (SchemaException e) { throw new SystemException("Couldn't adopt event record: " + e, e); } getPageBase().navigateToNext(new PageAuditLogDetails(record)); } }; columns.add(linkColumn); PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>( createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) { AuditEventRecordType auditEventRecordType = rowModel.getObject(); createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId); } }; columns.add(initiatorRefColumn); if (!isHistory) { IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<>( createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage"); columns.add(eventStageColumn); } IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<>( createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType"); columns.add(eventTypeColumn); if (!isHistory) { PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>( createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) { AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject(); createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId); } }; columns.add(targetRefColumn); } if (!isHistory) { PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>( createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) { AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject(); createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId); } }; columns.add(targetOwnerRefColumn); } IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>( createStringResource("AuditEventRecordType.channel"), "channel") { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) { AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject(); String channel = auditEventRecordType.getChannel(); if (channel != null) { QName channelQName = QNameUtil.uriToQName(channel); String return_ = channelQName.getLocalPart(); item.add(new Label(componentId, return_)); } else { item.add(new Label(componentId, "")); } item.add(new AttributeModifier("style", new Model<>("width: 10%;"))); } }; columns.add(channelColumn); IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<>( createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome"); columns.add(outcomeColumn); return columns; }
From source file:com.evolveum.midpoint.prism.marshaller.ItemPathHolder.java
public ItemPathHolder(List<PathHolderSegment> segments, boolean absolute) { this.segments = new ArrayList<>(); for (PathHolderSegment segment : segments) { if (segment.getQName() != null && StringUtils.isEmpty(segment.getQName().getPrefix())) { QName qname = segment.getQName(); this.segments.add(new PathHolderSegment(new QName(qname.getNamespaceURI(), qname.getLocalPart()))); } else {/*from ww w .ja v a 2 s. c o m*/ this.segments.add(segment); } } // this.segments = segments; this.absolute = absolute; }
From source file:com.evolveum.midpoint.web.page.admin.configuration.PageRepositoryQuery.java
private void initLayout() { Form mainForm = new com.evolveum.midpoint.web.component.form.Form(ID_MAIN_FORM); add(mainForm);/* www . ja v a2 s . c om*/ List<QName> objectTypeList = WebComponentUtil.createObjectTypeList(); Collections.sort(objectTypeList, new Comparator<QName>() { @Override public int compare(QName o1, QName o2) { return String.CASE_INSENSITIVE_ORDER.compare(o1.getLocalPart(), o2.getLocalPart()); } }); DropDownChoice<QName> objectTypeChoice = new DropDownChoice<>(ID_OBJECT_TYPE, new PropertyModel<>(model, RepoQueryDto.F_OBJECT_TYPE), new ListModel<>(objectTypeList), new QNameChoiceRenderer()); objectTypeChoice.setOutputMarkupId(true); objectTypeChoice.setNullValid(true); objectTypeChoice.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(get(ID_MAIN_FORM).get(ID_MIDPOINT_QUERY_BUTTON_BAR)); } }); mainForm.add(objectTypeChoice); AceEditor editorMidPoint = new AceEditor(ID_EDITOR_MIDPOINT, new PropertyModel<>(model, RepoQueryDto.F_MIDPOINT_QUERY)); editorMidPoint.setHeight(400); editorMidPoint.setResizeToMaxHeight(false); mainForm.add(editorMidPoint); AceEditor editorHibernate = new AceEditor(ID_EDITOR_HIBERNATE, new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_QUERY)); editorHibernate.setHeight(300); editorHibernate.setResizeToMaxHeight(false); editorHibernate.setReadonly(!isAdmin); editorHibernate.setMode(null); mainForm.add(editorHibernate); AceEditor hibernateParameters = new AceEditor(ID_HIBERNATE_PARAMETERS, new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_PARAMETERS)); hibernateParameters.setReadonly(true); hibernateParameters.setHeight(100); hibernateParameters.setResizeToMaxHeight(false); hibernateParameters.setMode(null); mainForm.add(hibernateParameters); WebMarkupContainer hibernateParametersNote = new WebMarkupContainer(ID_HIBERNATE_PARAMETERS_NOTE); hibernateParametersNote.setVisible(isAdmin); mainForm.add(hibernateParametersNote); WebMarkupContainer midPointQueryButtonBar = new WebMarkupContainer(ID_MIDPOINT_QUERY_BUTTON_BAR); midPointQueryButtonBar.setOutputMarkupId(true); mainForm.add(midPointQueryButtonBar); AjaxSubmitButton executeMidPoint = new AjaxSubmitButton(ID_EXECUTE_MIDPOINT, createStringResource("PageRepositoryQuery.button.translateAndExecute")) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { queryPerformed(Action.EXECUTE_MIDPOINT, target); } }; midPointQueryButtonBar.add(executeMidPoint); AjaxSubmitButton compileMidPoint = new AjaxSubmitButton(ID_COMPILE_MIDPOINT, createStringResource("PageRepositoryQuery.button.translate")) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { queryPerformed(Action.TRANSLATE_ONLY, target); } }; midPointQueryButtonBar.add(compileMidPoint); AjaxSubmitButton useInObjectList = new AjaxSubmitButton(ID_USE_IN_OBJECT_LIST, createStringResource("PageRepositoryQuery.button.useInObjectList")) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { useInObjectListPerformed(target); } }; useInObjectList.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return USE_IN_OBJECT_LIST_AVAILABLE_FOR.contains(model.getObject().getObjectType()); } }); midPointQueryButtonBar.add(useInObjectList); final DropDownChoice<String> sampleChoice = new DropDownChoice<>(ID_QUERY_SAMPLE, Model.of(""), new AbstractReadOnlyModel<List<String>>() { @Override public List<String> getObject() { return SAMPLES; } }, new StringResourceChoiceRenderer("PageRepositoryQuery.sample")); sampleChoice.setNullValid(true); sampleChoice.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { String sampleName = sampleChoice.getModelObject(); if (StringUtils.isEmpty(sampleName)) { return; } String resourceName = SAMPLES_DIR + "/" + sampleName + ".xml.data"; InputStream is = PageRepositoryQuery.class.getResourceAsStream(resourceName); if (is != null) { try { String localTypeName = StringUtils.substringBefore(sampleName, "_"); model.getObject().setObjectType(new QName(SchemaConstants.NS_C, localTypeName)); model.getObject().setMidPointQuery(IOUtils.toString(is, "UTF-8")); model.getObject().setHibernateQuery(""); model.getObject().setHibernateParameters(""); model.getObject().setQueryResultObject(null); model.getObject().resetQueryResultText(); target.add(PageRepositoryQuery.this); } catch (IOException e) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't read sample from resource {}", e, resourceName); } } else { LOGGER.warn("Resource {} containing sample couldn't be found", resourceName); } } }); mainForm.add(sampleChoice); AjaxSubmitButton executeHibernate = new AjaxSubmitButton(ID_EXECUTE_HIBERNATE, createStringResource("PageRepositoryQuery.button.execute")) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { queryPerformed(Action.EXECUTE_HIBERNATE, target); } }; executeHibernate.setVisible(isAdmin); mainForm.add(executeHibernate); Label resultLabel = new Label(ID_RESULT_LABEL, new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (model.getObject().getQueryResultText() == null) { return ""; } Object queryResult = model.getObject().getQueryResultObject(); if (queryResult instanceof List) { return getString("PageRepositoryQuery.resultObjects", ((List) queryResult).size()); } else if (queryResult instanceof Throwable) { return getString("PageRepositoryQuery.resultException", queryResult.getClass().getName()); } else { // including null return getString("PageRepositoryQuery.result"); } } }); mainForm.add(resultLabel); WebMarkupContainer incompleteResultsNote = new WebMarkupContainer(ID_INCOMPLETE_RESULTS_NOTE); incompleteResultsNote.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !isAdmin && model.getObject().getQueryResultText() != null; } }); mainForm.add(incompleteResultsNote); AceEditor resultText = new AceEditor(ID_RESULT_TEXT, new PropertyModel<>(model, RepoQueryDto.F_QUERY_RESULT_TEXT)); resultText.setReadonly(true); resultText.setHeight(300); resultText.setResizeToMaxHeight(false); resultText.setMode(null); resultText.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return model.getObject().getQueryResultText() != null; } }); mainForm.add(resultText); }
From source file:com.evolveum.midpoint.prism.parser.XPathHolder.java
private void addPureXpath(StringBuilder sb) { if (!absolute && segments.isEmpty()) { // Empty segment list gives a "local node" XPath sb.append("."); return;/* ww w .j a v a 2 s . com*/ } if (absolute) { sb.append("/"); } boolean first = true; for (XPathSegment seg : segments) { if (seg.isIdValueFilter()) { sb.append("["); sb.append(seg.getValue()); sb.append("]"); } else { if (!first) { sb.append("/"); } else { first = false; } if (seg.isVariable()) { sb.append("$"); } QName qname = seg.getQName(); if (!StringUtils.isEmpty(qname.getPrefix())) { sb.append(qname.getPrefix() + ":" + qname.getLocalPart()); } else { if (StringUtils.isNotEmpty(qname.getNamespaceURI())) { String prefix = GlobalDynamicNamespacePrefixMapper .getPreferredPrefix(qname.getNamespaceURI()); seg.setQNamePrefix(prefix); // hack - we modify the path segment here (only the form, not the meaning), but nevertheless it's ugly sb.append(seg.getQName().getPrefix() + ":" + seg.getQName().getLocalPart()); } else { // no namespace, no prefix sb.append(qname.getLocalPart()); } } } } }
From source file:com.evolveum.midpoint.util.DOMUtil.java
private static void setQNameAttribute(Element element, Attr attr, QName attributeQnameValue, Element definitionElement) { String attributeStringValue;// ww w . ja v a2 s . c o m if (attributeQnameValue == null) { attributeStringValue = ""; } else if (XMLConstants.NULL_NS_URI.equals(attributeQnameValue.getNamespaceURI())) { if (QNameUtil.isPrefixUndeclared(attributeQnameValue.getPrefix())) { attributeStringValue = attributeQnameValue.getPrefix() + ":" + attributeQnameValue.getLocalPart(); // to give user a chance to see and fix this } else { attributeStringValue = attributeQnameValue.getLocalPart(); } } else { String valuePrefix = lookupOrCreateNamespaceDeclaration(element, attributeQnameValue.getNamespaceURI(), attributeQnameValue.getPrefix(), definitionElement, false); assert StringUtils.isNotBlank(valuePrefix); attributeStringValue = valuePrefix + ":" + attributeQnameValue.getLocalPart(); } NamedNodeMap attributes = element.getAttributes(); checkValidXmlChars(attributeStringValue); attr.setValue(attributeStringValue); attributes.setNamedItem(attr); }
From source file:com.evolveum.midpoint.prism.marshaller.XPathHolder.java
public XPathHolder(List<XPathSegment> segments, boolean absolute) { this.segments = new ArrayList<XPathSegment>(); for (XPathSegment segment : segments) { if (segment.getQName() != null && StringUtils.isEmpty(segment.getQName().getPrefix())) { QName qname = segment.getQName(); this.segments.add(new XPathSegment(new QName(qname.getNamespaceURI(), qname.getLocalPart()))); } else {// w w w . j av a2 s.c o m this.segments.add(segment); } } // this.segments = segments; this.absolute = absolute; }
From source file:org.bedework.notifier.outbound.email.EmailAdaptor.java
@Override public boolean process(final Action action) throws NoteException { final Note note = action.getNote(); final NotificationType nt = note.getNotification(); final EmailSubscription sub = EmailSubscription.rewrap(action.getSub()); final ProcessorType pt = getProcessorStatus(note, processorType); if (debug) {//from w w w . ja va2s . c o m trace("EmailAdaptor: processing notifications for " + sub.getPrincipalHref()); } if (processed(pt)) { return true; } final EmailMessage email = new EmailMessage(conf.getFrom(), null); // if (note.isRegisteredRecipient()) { // do one thing // ? else { ... } final QName elementName = nt.getNotification().getElementName(); String prefix = nt.getParsed().getDocumentElement().getPrefix(); if (prefix == null) { prefix = "default"; } String subject = getConfig().getSubject(prefix + "-" + elementName.getLocalPart()); if (subject == null) { subject = getConfig().getDefaultSubject(); } email.setSubject(subject); List<TemplateResult> results = applyTemplates(action); for (TemplateResult result : results) { String from = result.getStringVariable("from"); if (from != null) { email.setFrom(from); } for (final String to : result.getListVariable("to")) { email.addTo(to); } for (final String cc : result.getListVariable("cc")) { email.addCc(cc); } for (final String bcc : result.getListVariable("bcc")) { email.addBcc(bcc); } subject = result.getStringVariable("subject"); if (subject != null) { email.setSubject(subject); } String contentType = result.getStringVariable("contentType"); if (contentType == null) { contentType = EmailMessage.CONTENT_TYPE_PLAIN; } email.addBody(contentType, result.getValue()); } if (email.getTos().size() == 0) { /* The subscription will define one or more recipients */ for (final String emailAddress : sub.getEmails()) { email.addTo(stripMailTo(emailAddress)); } } try { if (email.getBodies().keySet().size() > 0) { getMailer().send(email); pt.setDtstamp(getDtstamp()); pt.setStatus(HttpUtil.makeOKHttpStatus()); } else { // No template results returned, don't email but still return success. if (debug) { trace("EmailAdaptor: no emails to be sent for " + sub.getPrincipalHref()); } } return true; } catch (final NoteException ne) { if (debug) { error(ne); } } return false; }
From source file:com.evolveum.midpoint.model.impl.controller.ModelDiagController.java
private <O extends ObjectType, T> void checkObjectProperty(PrismObject<O> object, QName propQName, OperationResult parentResult, T... expectedValues) { String propName = propQName.getLocalPart(); OperationResult result = parentResult .createSubresult(parentResult.getOperation() + ".checkObjectProperty." + propName); PrismProperty<T> prop = object.findProperty(propQName); Collection<T> actualValues = prop.getRealValues(); result.addArbitraryObjectCollectionAsParam("actualValues", actualValues); assertMultivalue("User, property '" + propName + "'", expectedValues, actualValues, result); result.recordSuccessIfUnknown();//from w ww . ja va2 s .com }
From source file:org.apache.juddi.v3.client.mapping.wadl.WADL2UDDI.java
protected BindingTemplate createWADLBinding(QName serviceQName, String portName, URL serviceUrl, Resources res) {/*w w w . j a va 2 s .c o m*/ BindingTemplate bindingTemplate = new BindingTemplate(); // Set BusinessService Key bindingTemplate.setServiceKey(UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart())); if (serviceUrl != null) { // Set AccessPoint AccessPoint accessPoint = new AccessPoint(); accessPoint.setUseType(AccessPointType.END_POINT.toString()); accessPoint.setValue(urlLocalizer.rewrite(serviceUrl)); bindingTemplate.setAccessPoint(accessPoint); // Set Binding Key String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceQName, portName, serviceUrl); bindingTemplate.setBindingKey(bindingKey); bindingTemplate.getDescription().addAll(Common2UDDI.mapDescription(getDescription(res.getDoc()), lang)); // reference wsdl:binding tModel TModelInstanceInfo tModelInstanceInfoBinding = new TModelInstanceInfo(); tModelInstanceInfoBinding.setTModelKey(keyDomainURI + "binding"); InstanceDetails instanceDetails = new InstanceDetails(); instanceDetails.setInstanceParms(portName); tModelInstanceInfoBinding.setInstanceDetails(instanceDetails); tModelInstanceInfoBinding.getDescription() .addAll(Common2UDDI.mapDescription("The binding that this endpoint implements. " + bindingTemplate.getDescription().get(0).getValue() + " The instanceParms specifies the \" port local name.", lang)); TModelInstanceDetails tModelInstanceDetails = new TModelInstanceDetails(); tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoBinding); // reference wsdl:portType tModel TModelInstanceInfo tModelInstanceInfoPortType = new TModelInstanceInfo(); tModelInstanceInfoPortType.setTModelKey(keyDomainURI + "rest"); //String portTypeDescription = ""; Description descriptionPT = new Description(); descriptionPT.setLang(lang); descriptionPT.setValue("The wadl:Resource:base implements."); tModelInstanceInfoPortType.getDescription().add(descriptionPT); tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoPortType); bindingTemplate.setTModelInstanceDetails(tModelInstanceDetails); } return bindingTemplate; }
From source file:com.evolveum.midpoint.model.impl.controller.ModelDiagController.java
private <O extends ObjectType> void checkObjectPropertyPolyString(PrismObject<O> object, QName propQName, OperationResult parentResult, String... expectedValues) { String propName = propQName.getLocalPart(); OperationResult result = parentResult.createSubresult(parentResult.getOperation() + "." + propName); PrismProperty<PolyString> prop = object.findProperty(propQName); Collection<PolyString> actualValues = prop.getRealValues(); result.addArbitraryObjectCollectionAsParam("actualValues", actualValues); assertMultivaluePolyString("User, property '" + propName + "'", expectedValues, actualValues, result); result.recordSuccessIfUnknown();//ww w .j av a 2s.c o m }