public String registerDatastreamLocation(String dsLocation,
			String dsControlGroupType, String beServiceCallbackRole,
			String methodName) throws ServerException {

		String tempID = null;
		Timestamp timeStamp = null;
		if (counter > 999999) {
			counter = 0;
		}
		long currentTime = new Timestamp(new Date().getTime()).getTime();
		long expireLimit = currentTime - (long) datastreamExpirationLimit
				* 1000;

		try {

			// Remove any datastream registrations that have expired.
			// The expiration limit can be adjusted using the Fedora config
			// parameter
			// named "datastreamExpirationLimit" which is in seconds.
			for (Enumeration<String> e = dsRegistry.keys(); e.hasMoreElements();) {
				String key = e.nextElement();
				timeStamp = Timestamp.valueOf(extractTimestamp(key));
				if (expireLimit > timeStamp.getTime()) {
					dsRegistry.remove(key);
					logger.debug("DatastreamMediationKey removed from Hash: {}",
							key);
				}
			}

			// Register datastream.
			if (tempID == null) {
				timeStamp = new Timestamp(new Date().getTime());
				tempID = timeStamp.toString() + ":" + counter++;
				DatastreamMediation dm = new DatastreamMediation();
				dm.mediatedDatastreamID = tempID;
				dm.dsLocation = dsLocation;
				dm.dsControlGroupType = dsControlGroupType;
				dm.methodName = methodName;

				// See if datastream reference is to fedora server itself or an
				// external location.
				// M and X type datastreams always reference fedora server. With
				// E type datastreams
				// we must examine URL to see if this is referencing a remote
				// datastream or is
				// simply a callback to the fedora server. If the reference is
				// remote, then use
				// the role of the backend service that will make a callback for
				// this datastream.
				// If the referenc s to the fedora server, use the special role
				// of "fedoraInternalCall-1" to
				// denote that the callback will come from the fedora server
				// itself.
				String beServiceRole = null;
				if (ServerUtility.isURLFedoraServer(dsLocation)
						|| dsControlGroupType.equals("M")
						|| dsControlGroupType.equals("X")) {
					beServiceRole = BackendPolicies.FEDORA_INTERNAL_CALL;
				} else {
					beServiceRole = beServiceCallbackRole;
				}

				// Store beSecurity info in hash
				Hashtable<String, String> beHash = m_beSS.getSecuritySpec(
						beServiceRole, methodName);
				boolean beServiceCallbackBasicAuth = Boolean.parseBoolean(
						beHash.get("callbackBasicAuth"));
				boolean beServiceCallBasicAuth = Boolean.parseBoolean(
						beHash.get("callBasicAuth"));
				boolean beServiceCallbackSSL = Boolean.parseBoolean(
						beHash.get("callbackSSL"));
				boolean beServiceCallSSL = Boolean.parseBoolean(
				        beHash.get("callSSL"));
				String beServiceCallUsername = beHash.get("callUsername");
				String beServiceCallPassword = beHash.get("callPassword");
				if (logger.isDebugEnabled()) {
					logger.debug(
							"******************Registering datastream dsLocation: {}",
							dsLocation);
					logger.debug(
							"******************Registering datastream dsControlGroupType: {}",
							dsControlGroupType);
					logger.debug(
							"******************Registering datastream beServiceRole: {}",
							beServiceRole);
					logger.debug(
							"******************Registering datastream beServiceCallbackBasicAuth: {}",
							beServiceCallbackBasicAuth);
					logger.debug(
							"******************Registering datastream beServiceCallBasicAuth: {}",
							beServiceCallBasicAuth);
					logger.debug(
							"******************Registering datastream beServiceCallbackSSL: {}",
							beServiceCallbackSSL);
					logger.debug(
							"******************Registering datastream beServiceCallSSL: {}",
							beServiceCallSSL);
					logger.debug(
							"******************Registering datastream beServiceCallUsername: {}",
							beServiceCallUsername);
					logger.debug(
							"******************Registering datastream beServiceCallPassword: {}",
							beServiceCallPassword);
				}
				dm.callbackRole = beServiceRole;
				dm.callUsername = beServiceCallUsername;
				dm.callPassword = beServiceCallPassword;
				dm.callbackBasicAuth = beServiceCallbackBasicAuth;
				dm.callBasicAuth = beServiceCallBasicAuth;
				dm.callbackSSL = beServiceCallbackSSL;
				dm.callSSL = beServiceCallSSL;
				dsRegistry.put(tempID, dm);
				logger.debug("DatastreammediationKey added to Hash: " + tempID);
			}

		} catch (Throwable th) {
			throw new DisseminationException("[DisseminationService] register"
					+ "DatastreamLocation: "
					+ "returned an error. The underlying error was a "
					+ th.getClass().getName() + " The message " + "was \""
					+ th.getMessage() + "\" .");
		}

		// Replace the blank between date and time with the character "T".
		return tempID.replace(' ', 'T');
	}
public String registerDatastreamLocation ( String dsLocation , String dsControlGroupType , String beServiceCallbackRole , String methodName ) throws ServerException { String tempID = null ; Timestamp timeStamp = null ; if ( counter > 999999 ) { counter = 0 ; } long currentTime = new Timestamp ( new Date ( ) . getTime ( ) ) . getTime ( ) ; long expireLimit = currentTime - ( long ) datastreamExpirationLimit * 1000 ; try { for ( Enumeration < String > e = dsRegistry . keys ( ) ; e . hasMoreElements ( ) ; ) { String key = e . nextElement ( ) ; timeStamp = Timestamp . valueOf ( extractTimestamp ( key ) ) ; if ( expireLimit > timeStamp . getTime ( ) ) { dsRegistry . remove ( key ) ; logger . debug ( "DatastreamMediationKey removed from Hash: {}" , key ) ; } } if ( tempID == null ) { timeStamp = new Timestamp ( new Date ( ) . getTime ( ) ) ; tempID = timeStamp . toString ( ) + ":" + counter ++ ; DatastreamMediation dm = new DatastreamMediation ( ) ; dm . mediatedDatastreamID = tempID ; dm . dsLocation = dsLocation ; dm . dsControlGroupType = dsControlGroupType ; dm . methodName = methodName ; String beServiceRole = null ; if ( ServerUtility . isURLFedoraServer ( dsLocation ) || dsControlGroupType . equals ( "M" ) || dsControlGroupType . equals ( "X" ) ) { beServiceRole = BackendPolicies . FEDORA_INTERNAL_CALL ; } else { beServiceRole = beServiceCallbackRole ; } Hashtable < String , String > beHash = m_beSS . getSecuritySpec ( beServiceRole , methodName ) ; boolean beServiceCallbackBasicAuth = Boolean . parseBoolean ( beHash . get ( "callbackBasicAuth" ) ) ; boolean beServiceCallBasicAuth = Boolean . parseBoolean ( beHash . get ( "callBasicAuth" ) ) ; boolean beServiceCallbackSSL = Boolean . parseBoolean ( beHash . get ( "callbackSSL" ) ) ; boolean beServiceCallSSL = Boolean . parseBoolean ( beHash . get ( "callSSL" ) ) ; String beServiceCallUsername = beHash . get ( "callUsername" ) ; String beServiceCallPassword = beHash . get ( "callPassword" ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "******************Registering datastream dsLocation: {}" , dsLocation ) ; logger . debug ( "******************Registering datastream dsControlGroupType: {}" , dsControlGroupType ) ; logger . debug ( "******************Registering datastream beServiceRole: {}" , beServiceRole ) ; logger . debug ( "******************Registering datastream beServiceCallbackBasicAuth: {}" , beServiceCallbackBasicAuth ) ; logger . debug ( "******************Registering datastream beServiceCallBasicAuth: {}" , beServiceCallBasicAuth ) ; logger . debug ( "******************Registering datastream beServiceCallbackSSL: {}" , beServiceCallbackSSL ) ; logger . debug ( "******************Registering datastream beServiceCallSSL: {}" , beServiceCallSSL ) ; logger . debug ( "******************Registering datastream beServiceCallUsername: {}" , beServiceCallUsername ) ; logger . debug ( "******************Registering datastream beServiceCallPassword: {}" , beServiceCallPassword ) ; } dm . callbackRole = beServiceRole ; dm . callUsername = beServiceCallUsername ; dm . callPassword = beServiceCallPassword ; dm . callbackBasicAuth = beServiceCallbackBasicAuth ; dm . callBasicAuth = beServiceCallBasicAuth ; dm . callbackSSL = beServiceCallbackSSL ; dm . callSSL = beServiceCallSSL ; dsRegistry . put ( tempID , dm ) ; logger . debug ( "DatastreammediationKey added to Hash: " + tempID ) ; } } catch ( Throwable th ) { throw new DisseminationException ( "[DisseminationService] register" + "DatastreamLocation: " + "returned an error. The underlying error was a " + th . getClass ( ) . getName ( ) + " The message " + "was \"" + th . getMessage ( ) + "\" ." ) ; } return tempID . replace ( ' ' , 'T' ) ; }
<p>
Datastream locations are considered privileged information by the Fedora
repository. To prevent disclosing physical datastream locations to
external mechanism services, a proxy is used to disguise the datastream
locations. This method generates a temporary ID that maps to the physical
datastream location and registers this information in a memory resident
hashtable for subsequent resolution of the physical datastream location.
The servlet <code>DatastreamResolverServlet</code> provides the proxy
resolution service for datastreams.
</p>
<p>
</p>
<p>
The format of the tempID is derived from <code>java.sql.Timestamp</code>
with an arbitrary counter appended to the end to insure uniqueness. The
syntax is of the form:
<p>
YYYY-MM-DD HH:mm:ss.mmm:dddddd where
</p>
<ul>
<li>YYYY - year (1900-8099)</li>
<li>MM - month (01-12)</li>
<li>DD - day (01-31)</li>
<li>hh - hours (0-23)</li>
<li>mm - minutes (0-59)</li>
<li>ss - seconds (0-59)</li>
<li>mmm - milliseconds (0-999)</li>
<li>dddddd - incremental counter (0-999999)</li>
</ul>

@param dsLocation
The physical location of the datastream.
@param dsControlGroupType
The type of the datastream.
@return A temporary ID used to reference the physical location of the
specified datastream
@throws ServerException
If an error occurs in registering a datastream location.