use of org.w3._2007.rif.If in project airavata by apache.
the class StorageCreator method createStorage.
// The target site must have storage factory deployed with bes factory
public StorageClient createStorage() throws Exception {
if (factoryUrl == null) {
throw new Exception("Cannot create Storage Factory Url");
}
EndpointReferenceType sfEpr = WSUtilities.makeServiceEPR(factoryUrl, StorageFactory.SMF_PORT);
String dn = findServerName(factoryUrl, sfEpr);
WSUtilities.addServerIdentity(sfEpr, dn);
secProps.getETDSettings().setReceiver(new X500Principal(dn));
secProps.getETDSettings().setIssuerCertificateChain(secProps.getCredential().getCertificateChain());
// TODO: remove it afterwards
if (userName != null) {
secProps.getETDSettings().getRequestedUserAttributes2().put("xlogin", new String[] { userName });
}
StorageFactoryClient sfc = new StorageFactoryClient(sfEpr, secProps);
if (log.isDebugEnabled()) {
log.debug("Using storage factory at <" + sfc.getUrl() + ">");
}
StorageClient sc = null;
try {
sc = sfc.createSMS(getCreateSMSDocument());
String addr = sc.getEPR().getAddress().getStringValue();
log.info(addr);
} catch (Exception ex) {
log.error("Could not create storage", ex);
throw new Exception(ex);
}
return sc;
}
use of org.w3._2007.rif.If in project airavata by apache.
the class StorageCreator method findServerName.
protected String findServerName(String besUrl, EndpointReferenceType smsEpr) throws Exception {
int besIndex = besUrl.indexOf("StorageFactory?res");
String ss = besUrl.substring(0, besIndex);
ss = ss + "Registry";
EndpointReferenceType eprt = WSUtilities.makeServiceEPR(ss, "default_registry", Registry.REGISTRY_PORT);
RegistryClient registry = new RegistryClient(eprt, secProps);
// first, check if server name is already in the EPR...
String dn = WSUtilities.extractServerIDFromEPR(smsEpr);
if (dn != null) {
return dn;
}
// otherwise find a matching service in the registry
String url = smsEpr.getAddress().getStringValue();
if (url.contains("/services/"))
url = url.substring(0, url.indexOf("/services"));
if (log.isDebugEnabled())
log.debug("Checking for services at " + url);
for (EntryType entry : registry.listEntries()) {
if (entry.getMemberServiceEPR().getAddress().getStringValue().startsWith(url)) {
dn = WSUtilities.extractServerIDFromEPR(entry.getMemberServiceEPR());
if (dn != null) {
return dn;
}
}
}
return null;
}
use of org.w3._2007.rif.If in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method addVerticalDatum.
private void addVerticalDatum(MonitoringPointType mpt, List<Referenceable<VerticalDatum>> verticalDatums) throws EncodingException {
for (Referenceable<VerticalDatum> verticalDatum : verticalDatums) {
VerticalDatumPropertyType vdpt = mpt.addNewVerticalDatum();
if (verticalDatum.isReference()) {
Reference reference = verticalDatum.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(vdpt::setActuate);
reference.getArcrole().ifPresent(vdpt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(vdpt::setHref);
reference.getRole().ifPresent(vdpt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(vdpt::setShow);
reference.getTitle().ifPresent(vdpt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(vdpt::setType);
} else {
if (verticalDatum.isInstance()) {
Nillable<VerticalDatum> nillable = verticalDatum.getInstance();
if (nillable.isPresent()) {
XmlObject xml = encodeGML(nillable.get());
if (xml != null && xml instanceof VerticalDatumType) {
vdpt.setVerticalDatum((VerticalDatumType) xml);
} else {
vdpt.setNil();
vdpt.setNilReason(Nillable.missing().get());
}
} else {
vdpt.setNil();
if (nillable.hasReason()) {
vdpt.setNilReason(nillable.getNilReason().get());
} else {
vdpt.setNilReason(Nillable.missing().get());
}
}
}
}
}
}
use of org.w3._2007.rif.If in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method addRelatedParty.
private void addRelatedParty(MonitoringPointType mpt, List<Referenceable<CiResponsibleParty>> relatedParties) throws EncodingException {
for (Referenceable<CiResponsibleParty> relatedParty : relatedParties) {
CIResponsiblePartyPropertyType citppt = mpt.addNewRelatedParty();
if (relatedParty.isReference()) {
Reference reference = relatedParty.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(citppt::setActuate);
reference.getArcrole().ifPresent(citppt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(citppt::setHref);
reference.getRole().ifPresent(citppt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(citppt::setShow);
reference.getTitle().ifPresent(citppt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(citppt::setType);
} else {
if (relatedParty.isInstance()) {
Nillable<CiResponsibleParty> nillable = relatedParty.getInstance();
if (nillable.isPresent()) {
XmlObject xml = encodeObjectToXml(nillable.get().getDefaultElementEncoding(), nillable.get());
if (xml != null && xml instanceof CIResponsiblePartyType) {
citppt.setCIResponsibleParty((CIResponsiblePartyType) xml);
} else {
citppt.setNil();
citppt.setNilReason(Nillable.missing().get());
}
} else {
citppt.setNil();
if (nillable.hasReason()) {
citppt.setNilReason(nillable.getNilReason().get());
} else {
citppt.setNilReason(Nillable.missing().get());
}
}
}
}
}
}
use of org.w3._2007.rif.If in project arctic-sea by 52North.
the class Iso19139GmdEncoder method encodePhone.
private void encodePhone(CITelephonePropertyType citpt, Referenceable<CiTelephone> referenceable) {
if (referenceable.isReference()) {
Reference reference = referenceable.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(citpt::setActuate);
reference.getArcrole().ifPresent(citpt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(citpt::setHref);
reference.getRole().ifPresent(citpt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(citpt::setShow);
reference.getTitle().ifPresent(citpt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(citpt::setType);
} else {
if (referenceable.isInstance()) {
Nillable<CiTelephone> nillable = referenceable.getInstance();
if (nillable.isPresent()) {
CiTelephone ciTelephone = referenceable.getInstance().get();
CITelephoneType citt = citpt.addNewCITelephone();
if (ciTelephone.isSetVoice()) {
citt.setVoiceArray(listToCharacterStringPropertyTypeArray(ciTelephone.getVoice()));
}
if (ciTelephone.isSetFacsimile()) {
citt.setFacsimileArray(listToCharacterStringPropertyTypeArray(ciTelephone.getFacsimile()));
}
if (ciTelephone.isSetId()) {
citt.setId(ciTelephone.getId());
}
if (ciTelephone.isSetUuid()) {
citt.setUuid(ciTelephone.getUuid());
}
} else {
if (nillable.hasReason()) {
citpt.setNilReason(nillable.getNilReason().get());
}
}
}
}
}
Aggregations