use of com.google.cloud.servicedirectory.v1.Namespace in project qpp-conversion-tool by CMSgov.
the class QrdaUpdater method updateQrdaMeasureData.
static Document updateQrdaMeasureData(Path path) {
try {
SAXBuilder saxBuilder = new SAXBuilder();
InputStream inputStream = Files.newInputStream(path);
Document document = saxBuilder.build(inputStream);
Element rootElement = document.getDocument().getRootElement();
rootElement.detach();
Namespace rootNamespace = rootElement.getNamespace();
List<Element> measureComponents = rootElement.getChild("component", rootNamespace).getChild("structuredBody", rootNamespace).getChildren("component", rootNamespace);
Element measureComponent = measureComponents.stream().filter(component -> component.getChild("section", rootNamespace).getChildren("templateId", rootNamespace).stream().anyMatch(templateIdElement -> TemplateId.MEASURE_SECTION_V3.getRoot().equals(templateIdElement.getAttribute("root").getValue()))).findFirst().orElse(null);
List<Element> measureEntries = measureComponent.getChild("section", rootNamespace).getChildren("entry", rootNamespace);
for (Element measureEntry : measureEntries) {
Element measureEntryOrganizer = measureEntry.getChild("organizer", rootNamespace);
if (measureEntryOrganizer != null) {
Element measureRnrTemplateId = measureEntryOrganizer.getChildren("templateId", rootNamespace).stream().filter(childElement -> TemplateId.MEASURE_REFERENCE_RESULTS_CMS_V4.getRoot().equals(childElement.getAttribute("root").getValue())).findAny().orElse(null);
if (measureRnrTemplateId != null) {
String currentMeasureUuid = measureEntryOrganizer.getChild("reference", rootNamespace).getChild("externalDocument", rootNamespace).getChild("id", rootNamespace).getAttribute("extension").getValue();
MeasureConfig previousYearMeasureConfig = (MeasureConfig) previousYearMeasureConfigMap.get(currentMeasureUuid);
if ("CMS166v6".equals(previousYearMeasureConfig.getElectronicMeasureId()))
break;
String updatedElectronicMeasureId = updateElectronicMeasureId(previousYearMeasureConfig.getElectronicMeasureId());
MeasureConfig currentYearMeasureConfig = (MeasureConfig) currentYearMeasureConfigMap.get(updatedElectronicMeasureId);
updateMeasureUuid(rootNamespace, currentYearMeasureConfig, measureEntryOrganizer);
List<Element> subpopulationComponents = measureEntryOrganizer.getChildren("component", rootNamespace);
Long numberOfPerformanceRates = subpopulationComponents.stream().filter(subpopulationElement -> subpopulationElement.getChild("observation", rootNamespace).getChildren("templateId", rootNamespace).stream().anyMatch(templateElements -> TemplateId.PERFORMANCE_RATE_PROPORTION_MEASURE.getRoot().equals(templateElements.getAttribute("root").getValue()))).count();
if (numberOfPerformanceRates == 1L) {
subpopulationComponents.forEach(component -> {
Element componentObservation = component.getChild("observation", rootNamespace);
Attribute subpopulationGuidAttribute = componentObservation.getChild("reference", rootNamespace).getChild("externalObservation", rootNamespace).getChild("id", rootNamespace).getAttribute("root");
if (isPerformanceRate(componentObservation, rootNamespace)) {
subpopulationGuidAttribute.setValue(currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids().getNumeratorUuid());
} else {
String currentSubpopulationType = componentObservation.getChild("value", rootNamespace).getAttribute("code").getValue();
SubPopulation subPopulationUuids = currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids();
if ("IPOP".equals(currentSubpopulationType) || "IPP".equals(currentSubpopulationType) && currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids().getInitialPopulationUuid() != null) {
subpopulationGuidAttribute.setValue(subPopulationUuids.getInitialPopulationUuid());
} else if ("DENOM".equals(currentSubpopulationType) && currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids().getDenominatorUuid() != null) {
subpopulationGuidAttribute.setValue(subPopulationUuids.getDenominatorUuid());
} else if ("NUMER".equals(currentSubpopulationType) && currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids().getNumeratorUuid() != null) {
subpopulationGuidAttribute.setValue(subPopulationUuids.getNumeratorUuid());
} else if ("DENEXCEP".equals(currentSubpopulationType) && currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids().getDenominatorExceptionsUuid() != null) {
subpopulationGuidAttribute.setValue(subPopulationUuids.getDenominatorExceptionsUuid());
} else if ("DENEX".equals(currentSubpopulationType) && currentYearMeasureConfig.getStrata().get(0).getElectronicMeasureUuids().getDenominatorExclusionsUuid() != null) {
subpopulationGuidAttribute.setValue(subPopulationUuids.getDenominatorExclusionsUuid());
}
}
});
}
}
}
}
document.addContent(rootElement);
return document;
} catch (Exception exc) {
exc.printStackTrace();
}
return null;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project jspwiki by apache.
the class WebContainerAuthorizer method isConstrained.
/**
* <p>
* Protected method that identifies whether a particular webapp URL is
* constrained to a particular Role. The resource is considered constrained
* if:
* </p>
* <ul>
* <li>the web application deployment descriptor contains a
* <code>security-constraint</code> with a child
* <code>web-resource-collection/url-pattern</code> element matching the
* URL, <em>and</em>:</li>
* <li>this constraint also contains an
* <code>auth-constraint/role-name</code> element equal to the supplied
* Role's <code>getName()</code> method. If the supplied Role is Role.ALL,
* it matches all roles</li>
* </ul>
* @param url the web resource
* @param role the role
* @return <code>true</code> if the resource is constrained to the role,
* <code>false</code> otherwise
*/
public boolean isConstrained(final String url, final Role role) {
final Element root = m_webxml.getRootElement();
final Namespace jeeNs = Namespace.getNamespace("j", J2EE_SCHEMA_25_NAMESPACE);
// Get all constraints that have our URL pattern
// (Note the crazy j: prefix to denote the jee schema)
final String constrainsSelector = "//j:web-app/j:security-constraint[j:web-resource-collection/j:url-pattern=\"" + url + "\"]";
final List<Element> constraints = XPathFactory.instance().compile(constrainsSelector, Filters.element(), null, jeeNs).evaluate(root);
// Get all constraints that match our Role pattern
final String rolesSelector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" + role.getName() + "\"]";
final List<Element> roles = XPathFactory.instance().compile(rolesSelector, Filters.element(), null, jeeNs).evaluate(root);
// If we can't find either one, we must not be constrained
if (constraints.size() == 0) {
return false;
}
// Shortcut: if the role is ALL, we are constrained
if (role.equals(Role.ALL)) {
return true;
}
// If no roles, we must not be constrained
if (roles.size() == 0) {
return false;
}
// If a constraint is contained in both lists, we must be constrained
for (final Element constraint : constraints) {
for (final Element roleConstraint : roles) {
if (constraint.equals(roleConstraint)) {
return true;
}
}
}
return false;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project android_packages_apps_GmsCore by microg.
the class CastDeviceControllerImpl method createMetadataFromApplication.
protected ApplicationMetadata createMetadataFromApplication(Application app) {
if (app == null) {
return null;
}
ApplicationMetadata metadata = new ApplicationMetadata();
metadata.applicationId = app.id;
metadata.name = app.name;
Log.d(TAG, "unimplemented: ApplicationMetadata.images");
Log.d(TAG, "unimplemented: ApplicationMetadata.senderAppLaunchUri");
metadata.images = new ArrayList<WebImage>();
metadata.namespaces = new ArrayList<String>();
for (Namespace namespace : app.namespaces) {
metadata.namespaces.add(namespace.name);
}
metadata.senderAppIdentifier = this.context.getPackageName();
return metadata;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class EmailActionExecutor method validateAndMail.
@SuppressWarnings("unchecked")
protected void validateAndMail(Context context, Element element) throws ActionExecutorException {
// The XSD does the min/max occurrence validation for us.
Namespace ns = element.getNamespace();
String[] tos = new String[0];
String[] ccs = new String[0];
String[] bccs;
String subject = "";
String body = "";
String[] attachments = new String[0];
String contentType;
Element child = null;
// <to> - One ought to exist.
String text = element.getChildTextTrim(TO, ns);
if (text.isEmpty()) {
throw new ActionExecutorException(ErrorType.ERROR, "EM001", "No recipients were specified in the to-address field.");
}
tos = text.split(COMMA);
// <cc> - Optional, but only one ought to exist.
try {
ccs = element.getChildTextTrim(CC, ns).split(COMMA);
} catch (Exception e) {
// It is alright for cc to be given empty or not be present.
ccs = new String[0];
}
// <bcc> - Optional, but only one ought to exist.
try {
bccs = element.getChildTextTrim(BCC, ns).split(COMMA);
} catch (Exception e) {
// It is alright for bcc to be given empty or not be present.
bccs = new String[0];
}
// <subject> - One ought to exist.
subject = element.getChildTextTrim(SUB, ns);
// <body> - One ought to exist.
body = element.getChildTextTrim(BOD, ns);
// <attachment> - Optional
String attachment = element.getChildTextTrim(ATTACHMENT, ns);
if (attachment != null) {
attachments = attachment.split(COMMA);
}
contentType = element.getChildTextTrim(CONTENT_TYPE, ns);
if (contentType == null || contentType.isEmpty()) {
contentType = DEFAULT_CONTENT_TYPE;
}
// All good - lets try to mail!
email(tos, ccs, bccs, subject, body, attachments, contentType, context.getWorkflow().getUser());
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class JavaActionExecutor method getCaptureOutput.
protected boolean getCaptureOutput(WorkflowAction action) throws JDOMException {
Element eConf = XmlUtils.parseXml(action.getConf());
Namespace ns = eConf.getNamespace();
Element captureOutput = eConf.getChild("capture-output", ns);
return captureOutput != null;
}
Aggregations