use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class SmsCollectionProvider method updateInstance.
/**
* Updates a child instance of config. The parent config referenced by the request path is found, and
* the config is updated using the resourceId.
* {@inheritDoc}
*/
@Override
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request) {
JsonValue content = request.getContent();
String realm = realmFor(context);
try {
Map<String, Set<String>> attrs = converter.fromJson(realm, content);
ServiceConfigManager scm = getServiceConfigManager(context);
ServiceConfig config = parentSubConfigFor(context, scm);
ServiceConfig node = checkedInstanceSubConfig(context, resourceId, config);
node.setAttributes(attrs);
JsonValue result = getJsonValue(realm, node);
return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
} catch (ServiceNotFoundException e) {
debug.warning("::SmsCollectionProvider:: ServiceNotFoundException on update", e);
return new NotFoundException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SMSException e) {
debug.warning("::SmsCollectionProvider:: SMSException on update", e);
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
debug.warning("::SmsCollectionProvider:: SSOException on update", e);
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (ResourceException e) {
return e.asPromise();
}
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class UpgradeOAuth2ProviderStep method initialize.
@Override
public void initialize() throws UpgradeException {
final SSOToken token = getAdminToken();
try {
scm = new ServiceConfigManager(OAUTH2_PROVIDER, token);
ssm = new ServiceSchemaManager(OAUTH2_PROVIDER, token);
findUpgradableProviders();
} catch (ServiceNotFoundException e) {
//When upgrading from 10.0.x and before there is no OAuth2 service, so we expect this exception in this case
DEBUG.message("OAuth2Provider service not found. Nothing to upgrade", e);
} catch (Exception e) {
DEBUG.error("An error occurred while trying to create Service Config and Schema Managers.", e);
throw new UpgradeException("Unable to create Service Config and Schema Managers.", e);
}
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class UpgradeOAuth2AuthModulesStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
ServiceConfigManager scm = new ServiceConfigManager(SERVICE_NAME, getAdminToken());
for (String realm : getRealmNames()) {
ServiceConfig realmConfig = scm.getOrganizationConfig(realm, null);
for (String moduleName : (Set<String>) realmConfig.getSubConfigNames()) {
ServiceConfig moduleConfig = realmConfig.getSubConfig(moduleName);
Map<String, Set<?>> attributes = getAttributes(moduleConfig);
check(attributes, ACCOUNT_MAPPER_PROPERTY, DEFAULT_ACCOUNT_MAPPER, realm, moduleName);
check(attributes, ATTRIBUTE_MAPPER_PROPERTY, DEFAULT_ATTRIBUTE_MAPPER, realm, moduleName);
}
}
} catch (ServiceNotFoundException e) {
// When upgrading from 9.5.x and before there is no OAuth2 auth modules, so we expect this exception in this case
DEBUG.message("OAuth2 auth modules not found. Nothing to upgrade", e);
} catch (Exception ex) {
DEBUG.error("An error occurred while trying to look for upgradable OAuth2 auth modules", ex);
throw new UpgradeException("Unable to retrieve OAuth2 auth modules", ex);
}
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class AMOrgTemplateImpl method delete.
/**
* Deletes this tempate.
*
* @param recursive
* is not used.
* @throws AMException
* if there is an internal problem with AM Store.
* @throws SSOException
* if the sign-on is no longer valid.
*/
public void delete(boolean recursive) throws AMException, SSOException {
modAttributes = new HashMap();
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, token);
scm.removeOrganizationConfiguration(orgDN, null, false);
} catch (ServiceNotFoundException ex) {
Object[] args = { serviceName };
throw new AMException(AMSDKBundle.getString("481", args), "481", args);
} catch (SMSException ex) {
Object[] args = { serviceName };
throw new AMException(AMSDKBundle.getString("913", args), "913", args);
}
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class SMSEnhancedFlatFileObject method getSubEntries.
/**
* Real routine to get sub entries, used by subEntries() and
* schemaSubEntries().
*
* @throws ServiceNotFoundException if the configuration object is
* not found.
* @throws SchemaException if a sub directory name is not in the
* expected "ou=..." format.
*/
protected Set getSubEntries(String objName, String filter, String sidFilter, boolean isSubConfig, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SMSException {
String objKey = objName.toLowerCase();
Set subentries = null;
// wait indefinitely for the read lock.
mRWLock.readRequest();
try {
SMSFlatFileTreeNode node = root.getChild(objKey);
if (node == null) {
String errmsg = "SMSEnhancedFlatFileObject.getSubEntries: " + objName + " : not found in objects map.";
mDebug.warning(errmsg);
throw new ServiceNotFoundException(errmsg);
}
// Create file filter for filter and sid filter.
NodeNameFilter subEntNodeFilter = new NodeNameFilter(filter);
NodeNameFilter sidNameFilter = getSidNodeFilter(sidFilter, isSubConfig);
// Create set for return, use sorted set if sortResults is true.
if (sortResults) {
subentries = new CaseInsensitiveTreeSet(ascendingOrder);
} else {
subentries = new CaseInsensitiveHashSet();
}
// Set all entries that match filter, and that match
// sunserviceid/sunxmlkeyvalye if sidFilter was not null.
Set subEntries = node.searchChildren(subEntNodeFilter, false);
int numEntriesAdded = 0;
int sz = subEntries.size();
boolean done = false;
for (Iterator i = subEntries.iterator(); i.hasNext() && !done; ) {
SMSFlatFileTreeNode n = (SMSFlatFileTreeNode) i.next();
String nodeDN = n.getName();
boolean accept = (sidNameFilter == null);
if (!accept) {
Set sids = n.searchChildren(sidNameFilter, false);
accept = (sids != null) && !sids.isEmpty();
}
if (accept) {
int idx = nodeDN.indexOf('=');
if ((idx == -1) || (idx == (nodeDN.length() - 1))) {
String errmsg = "SMSEnhancedFlatFileObject.getSubEntries: " + "Invalid sub entry name found: " + nodeDN;
mDebug.error(errmsg);
throw new SchemaException(errmsg);
}
String subentryname = FileNameDecoder.decode(nodeDN.substring(idx + 1));
subentries.add(subentryname);
numEntriesAdded++;
// stop if number of entries requested has been reached.
// if sort results, need to get the whole list first.
done = !sortResults && (numOfEntries > 0) && (numEntriesAdded == numOfEntries);
}
}
if (sortResults && (numOfEntries > 0)) {
while ((numEntriesAdded - numOfEntries) > 0) {
Object l = ((CaseInsensitiveTreeSet) subentries).last();
subentries.remove(l);
numEntriesAdded--;
}
}
} finally {
mRWLock.readDone();
}
return subentries;
}
Aggregations