}
IRegistry ireg = (IRegistry) registry.getRegistry();
ConnectionImpl connection = registry.getConnection();
AuthToken token = getAuthToken(connection, ireg);
if (token == null) {
throw new IllegalStateException("No auth token returned");
}
Object regobj;
if(op.equalsIgnoreCase("SAVE_ASSOCIATION"))
{
try {
regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[]) dataarray);
}
}
else if (op.equalsIgnoreCase("SAVE_SERVICE")) {
try {
regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
}
}
else if (op.equalsIgnoreCase("SAVE_SERVICE_BINDING")) {
try {
regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
}
}
else if (op.equalsIgnoreCase("SAVE_ORG")) {
try {
regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
}
}
else if (op.equalsIgnoreCase("SAVE_TMODEL")) {
try {
regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
}
}
else if (op.equalsIgnoreCase("DELETE_ORG")) {
try {
clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
}
}
else if (op.equalsIgnoreCase("DELETE_SERVICE")) {
try {
regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
//clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
}
}
else if (op.equalsIgnoreCase("DELETE_SERVICEBINDING")) {
try {
regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
//clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
}
}
else if (op.equalsIgnoreCase("DELETE_CONCEPT")) {
try {
regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
}
}
else if (op.equalsIgnoreCase("DELETE_ASSOCIATION")) {
int len = ((String[]) dataarray).length;
PublisherAssertion[] paarr = new PublisherAssertion[len];
for(int i=0;i<len;i++)
{
String keystr = ((String[])dataarray)[i];
paarr[i] = ScoutJaxrUddiHelper.getPubAssertionFromJAXRAssociationKey(keystr);
}
try {
regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
}
}
else if (op.equalsIgnoreCase("DELETE_CLASSIFICATIONSCHEME")) {
try {
regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
} catch (RegistryException rve) {
String username = getUsernameFromCredentials(connection.getCredentials());
if (AuthTokenSingleton.getToken(username) != null) {
AuthTokenSingleton.deleteAuthToken(username);
}
token = getAuthToken(connection, ireg);
clearPublisherAssertions(token.getAuthInfo(), ireg);
regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
}
}
else {
throw new JAXRException("Unsupported operation:" + op);
}