/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ServiceSchemaManagerImpl.java,v 1.8 2008/08/28 18:36:30 arviranga Exp $
*
* Portions Copyrighted 2012-2016 ForgeRock AS.
*/
/**
* The class <code>ServiceSchemaManagerImpl</code> provides the internal
* implemation for <code>ServiceSchemaManager</code>. There should be only
* one instance of <code>ServiceSchemaManagerImpl
* </code> per service name and
* version. This class implements all the "read" methods and would receive
* notification when schema changes.
*/
public class ServiceSchemaManagerImpl implements SMSObjectListener, CachedSMSEntry.SMSEntryUpdateListener {
// Instance variables
private int instanceID;
private int revisionNumber;
// Pointer to Service Manager
// Pointer to Schema's SMS entry. This contains the schema attributes
// Pointer to schema changes listeners
// XML schema in String and Node formats (both can be null).
// service sub-schemas & plugin interfaces
// Private constructor, an instance can obtained only via getInstance
// Copy instance variables
this.serviceName = serviceName;
subSchemas = new HashMap();
pluginInterfaces = new HashMap();
// Construct the Schema's SMS entry and validate it
if (isValid()) {
update();
} else {
// only SSOException gets masked, throw SMSException with SSO
"sms-INVALID_SSO_TOKEN"), "sms-INVALID_SSO_TOKEN"));
}
}
/**
* Returns if the object is still valid
* @return validity of this object
*/
// if cache is not valid, don't bother checking the rest
}
// Check if entry exists i.e service name with version exists
if (smsEntry.isNewEntry()) {
}
}
}
/**
* Returns the Service name
*/
return (serviceName);
}
/**
* Returns the Service's version
*/
return (version);
}
/**
* Retuns I18N key for the service
*/
return (i18nKey);
}
/**
* Sets I18N key for the service
*/
}
/**
* Retuns revision number for the service
*/
int getRevisionNumber() {
return (revisionNumber);
}
/**
* Sets the revision number for the service
*/
this.revisionNumber = revisionNumber;
}
/**
* Returns the I18N properties file name for the service.
*/
return (i18nFileName);
}
i18nFileName = fn;
}
/**
* Returns the URL of the JAR file that contains the I18N properties file.
*/
return (i18nJarURL);
}
i18nJarURL = url;
}
/**
* Returns the service's hiearchy
*/
return (serviceHierarchy);
}
}
/**
* Returns URL of the view bean for the service
*/
return (viewBeanURL);
}
}
/**
* The name to use in CREST representation.
*/
return resourceName;
}
resourceName = name;
}
/**
* Returns the SchemaTypes available with this service
*/
}
return (answer);
}
/**
* Returns the service schema in XML for this service.
*/
}
return (smsEntry);
}
// @Override
public int hashCode() {
int hash = 7;
return hash;
}
if (o instanceof ServiceSchemaManagerImpl) {
return (true);
}
}
return (false);
}
}
}
}
}
}
}
/**
* Register for changes to service's schema. The object will be called when
* schema for this service and version is changed.
*/
}
if (listenerObjects == null) {
}
// Check for empty since elememts could have been removed from
// listenerObjects objects.
if (listenerObjects.isEmpty()) {
.registerCallbackHandler(this);
}
}
return (id);
}
/**
* Unregisters the listener from the service for the given listener ID. The
* ID was issued when the listener was registered.
*/
if (listenerObjects != null) {
if (listenerObjects.isEmpty()) {
}
}
}
// SMSObjectListener abstract method. Send notifications to clients
// registered via addListener
// Sends notifications to listener objects
if (debug.messageEnabled()) {
}
}
}
// SMSObjectListener abstract method. Send notifications to clients
// registered via addListener
public void allObjectsChanged() {
synchronized (listenerObjects) {
}
while (l.hasNext()) {
if (debug.messageEnabled()) {
"Sending change notification to: " +
}
try {
} catch (Throwable t) {
"allObjectsChanged. Listeners Exception sending " +
"notification to class: " +
}
}
}
}
// -----------------------------------------------------------
// Plugin Methods
// -----------------------------------------------------------
}
}
// -----------------------------------------------------------
// Internal protected methods
// -----------------------------------------------------------
}
return (document);
}
}
}
smsEntry.removeServiceListener(this);
}
// Called by CachedSMSEntry to refresh the cache due to local changes
// and called via CachedSMSEntry's refresh when cache gets dirty.
// Method is synchronized since calls from CachedSMSEntry.refresh
// can happen at the same time.
public synchronized void update() {
// Clear the references and return
clear();
return;
}
// This could mean the service schema has been deleted
if (debug.warningEnabled()) {
}
return;
}
// Construct the XML document from the schema
try {
.getServiceSchemaInputStream(xmlSchema), false);
} catch (Exception e) {
// This should not happpen
return;
}
if (schemaRoot == null) {
+ "no schema found");
return;
}
// Update instance variables
try {
} else {
}
} catch (Exception e) {
// could be no revision number or number format exception
if (debug.warningEnabled()) {
+ ": Invalid revision revision number: " + revNum, e);
}
}
// Update sub-schema caches, if any
// Update plugin intefaces, if any
}
}
continue;
}
} else {
}
}
}
} else {
} else {
}
}
}
private void clear() {
clear(false);
}
// Clear the local variable
// and mark the entry to be invalid and to be GCed.
// Remove itself from CachedSMSEntry listener list
smsEntry.removeServiceListener(this);
}
// Deregister for external notifications if there are no listeners
}
// Clear local cache
schemaRoot = null;
try {
}
} catch (SMSException smse) {
"Exception getting schema types. " , smse);
}
}
subSchemas.clear();
return listenerObjects;
}
// Static method to get an instance of this class
while (true) {
}
} else {
break;
}
}
// Check if the entry needs to be updated
if (!SMSEntry.cacheSMSEntries) {
// Read the entry, since it should not be cached
}
return ssmi;
}
// Instantiate and add to cache
//Utilizing SSMI_LOCK here to ensure that listeners are only added to one new ssmi instance
synchronized (SSMI_LOCK) {
//listeners that were registered to old ServiceSchemaManagerImpl
//should be added back
//sundidentityrepositoryservice will add back new instance of
//SpecialRepo itself so not adding old ones here.
}
}
} else {
}
}
return ssmi;
}
// Debug & I18n
// Pointers to ServiceSchemaManager instances
throws SMSException {
return SMSSchema.nodeToString(
}
}
}
}