/* (non-Javadoc)
@see com.ibm.ws.sib.processor.impl.interfaces.DestinationHandler#getLocalisation(com.ibm.ws.sib.utils.SIBUuid8)
345642
public PtoPMessageItemStream getLocalisation(SIBUuid8 meUuid)
  {
    throw new InvalidOperationException(
      nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0005",
          new Object[] {
            "com.ibm.ws.sib.processor.proxyhandler.BusGroup",
            "1:591:1.54",
            getName() },
          null));
  }
689976
@Override
    public String getScopeToLocalQP() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getScopeToLocalQP");

        String scopeToLocalQP = (String) properties.get(SCOPE_TO_LOCAL_QP);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getScopeToLocalQP", scopeToLocalQP);
        return scopeToLocalQP;
    }
1052700
@Override
    public Enumeration<Locale> getLocales() {
        if (super.getSession(false) == null) {
            return super.getLocales();
        }

        final IUserInstance userInstance =
                this.userInstanceManager.getUserInstance(this.getWrappedRequest());
        final LocaleManager localeManager = userInstance.getLocaleManager();
        final List<Locale> locales = localeManager.getLocales();
        return Collections.enumeration(locales);
    }
924960
public static Locale getLocale() {
        final Locale ret = LOCALE.get();
        if (null == ret) {
            return Latkes.getLocale();
        }

        return ret;
    }
452173
Locale getWorkplaceLocale() {

        if (m_wpLocale == null) {
            m_wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(getCmsObject());
        }
        return m_wpLocale;
    }
1067872
public Enumeration getLocales() {
        // 321485
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.logp(Level.FINE, CLASS_NAME,"getLocales", "this->"+this+": ");
        }
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        processLocales();
        return new Enumeration() {
            java.util.Iterator iter = _srtRequestHelper._locales.iterator();
            public boolean hasMoreElements() {
                return iter.hasNext();
            }

            public Object nextElement() {
                return iter.next();
            }
        };

    }
170532
private Instance getExistingLocale(final long _propertyid,
                                       final String _language)
    {
        Instance ret = null;
        try {
            final QueryBuilder queryBldr = new QueryBuilder(Type.get(DBPropertiesUpdate.TYPE_PROPERTIES_LOCAL));
            queryBldr.addWhereAttrEqValue("PropertyID", _propertyid);
            queryBldr.addWhereAttrEqValue("LanguageID", getLanguageId(_language));
            final InstanceQuery query = queryBldr.getQuery();
            query.executeWithoutAccessCheck();
            if (query.next()) {
                ret = query.getCurrentValue();
            }
        } catch (final EFapsException e) {
            DBPropertiesUpdate.LOG.error("getExistingLocale(String)", e);
        }
        return ret;
    }
823445
private void createDestinationLocalization(
                                               DestinationDefinition destinationDefinition,
                                               LocalizationDefinition destinationLocalizationDefinition,
                                               Set<String> destinationLocalizingMEs,
                                               boolean isTemporary,
                                               LocalTransaction transaction) throws SIResourceException, SIMPDestinationAlreadyExistsException
    {
//    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
//      SibTr.entry(
//        tc,
//        "createDestinationLocalization",
//        new Object[] {
//          destinationDefinition.getName(),
//          destinationDefinition.getUUID().toString(),
//          destinationDefinition,
//          destinationLocalizationDefinition,
//          destinationLocalizingMEs,
//          new Boolean(isTemporary),
//          transaction });

        boolean destinationHandlerCreated = false;
        BaseDestinationHandler destinationHandler = null;

        //The destination is being created on the local messaging engine.
        SIBUuid8 messagingEngineUuid = messageProcessor.getMessagingEngineUuid();

        checkValidLocalizationConfig(destinationDefinition,
                                     messagingEngineUuid,
                                     destinationLocalizationDefinition,
                                     destinationLocalizingMEs);

        //The lock on the destinationManager is taken to stop 2 threads creating the same
        //destination and also to synchronize dynamic deletes with the
        //creation of aliases.  This stops an alias destination being created that targets a
        //destination in the process of being deleted.
        synchronized (this)
        {
            //check if there are ANY with the same uuid
            DestinationTypeFilter filter = new DestinationTypeFilter();
            //Venu UUID temp
            DestinationHandler dh = destinationIndex.findByName(destinationDefinition.getName(), messageProcessor.getMessagingEngineBus(), filter);

            // If someone does a delete and add then it is possible the delete
            // might not have happened yet, so wait up to 5 seconds for the
            // deletion thread to finish. Then get the DH again and proceed. If
            // deletion takes more than 5 seconds this still won't work, but
            // deletion should not take 5 seconds.
            if (dh != null && dh.isToBeDeleted()) {
                synchronized (deletionThreadLock) {
                  try {
                      if (asynchDeletionThread != null && asynchDeletionThread.isRunning()) {
                          deletionThreadLock.wait(5000);
                      }
                  } catch (InterruptedException ie) {
                    // Just ignore this, someone told us to wake up so just bail.
                    Thread.currentThread().interrupt();
                    SibTr.debug(tc, "Wait for deletion thread to complete interrupted. Continuing without further waiting");
                  }
                }
                dh = destinationIndex.findByName(destinationDefinition.getName(), messageProcessor.getMessagingEngineBus(), filter);
            }

            if (dh == null)
            {
                // Create a new DestinationHandler, which is created locked
                // 174199.2.3
                destinationHandler =
                                new BaseDestinationHandler(
                                                destinationDefinition,
                                                messageProcessor,
                                                this,
                                                transaction,
                                                durableSubscriptions,
                                                messageProcessor.getMessagingEngineBus());

                destinationHandlerCreated = true;
                DestinationIndex.Type type = new DestinationIndex.Type();
                type.alias = new Boolean(destinationHandler.isAlias());
                type.foreignDestination = new Boolean(destinationHandler.isForeign());
                type.local = new Boolean(destinationHandler.hasLocal());
                type.queue = new Boolean(!destinationHandler.isPubSub());
                type.remote = new Boolean(destinationHandler.hasRemote());
                type.state = State.CREATE_IN_PROGRESS;
                //Venu temp UUID. setting UUID freshly
                destinationDefinition.setUUID(new SIBUuid12());
                destinationLocalizationDefinition.setUUID(new SIBUuid8());
                destinationIndex.put(destinationHandler, type);

            }
            else
            {
                if (dh instanceof BaseDestinationHandler) {
                    destinationHandler = (BaseDestinationHandler) dh;
                    //Venu temp UUID. setting Destination UUID from MessageStore dh
                    // LocalisationDefitnion UUID is alwasy set freshly
                    destinationDefinition.setUUID(dh.getDefinition().getUUID());
                    destinationLocalizationDefinition.setUUID(new SIBUuid8());
                }
                else
                {
                    //A destination exists with this name - perhaps an alias or a
                    //foreign destination.
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.exit(
                                   tc,
                                   "createDestinationLocalization",
                                   nls_cwsik.getFormattedMessage(
                                                                 "DELIVERY_ERROR_SIRC_31", // DESTINATION_ALREADY_EXISTS_ERROR_CWSIP0045
                                                                 new Object[] { destinationDefinition.getName() },
                                                                 null));

                    SIMPDestinationAlreadyExistsException e = new SIMPDestinationAlreadyExistsException(
                                    nls_cwsik.getFormattedMessage(
                                                                  "DELIVERY_ERROR_SIRC_31", // DESTINATION_ALREADY_EXISTS_ERROR_CWSIP0045
                                                                  new Object[] { destinationDefinition.getName() },
                                                                  null));

                    e.setExceptionReason(SIRCConstants.SIRC0031_DESTINATION_ALREADY_EXISTS_ERROR);
                    e.setExceptionInserts(new String[] { destinationDefinition.getName() });
                    throw e;
                }
            }
        }

        synchronized (destinationHandler)
        {
            //      // If we are corrupt, we don't want to attempt to create any points
            //      // whatsoever.
            //      if (destinationHandler.isCorrupt())
            //      {
            //        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            //          SibTr.debug(tc, "createDestinationLocalization",
            //            "Point " + destinationLocalizationDefinition.getIdentifier()
            //            + " not created since destination " + destinationHandler.getName()
            //            + " is corrupt.");
            //
            //        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            //          SibTr.exit(tc, "createDestinationLocalization");
            //
            //        return;
            //      }

            //If we didnt just create the destinationHandler, it is valid for this
            //create call to be made at startup or to create a local queue point
            if (!destinationHandlerCreated)
            {
                //---199538--------------------------------------------------------------
                //This USED to test whether the destination was reconciling
                //and, if not, would throw an exception. This is no longer the case, as
                //dynamic updates might cause this method to be called for a destination
                //that already exists i.e. when localising a qPt on a previously
                //remote destination.
                //-----------------------------------------------------------------------

                if (destinationHandler.isReconciled() && (destinationHandler.hasLocal() || destinationLocalizationDefinition == null))
                {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.exit(
                                   tc,
                                   "createDestinationLocalization",
                                   nls_cwsik.getFormattedMessage(
                                                                 "DELIVERY_ERROR_SIRC_31", // DESTINATION_ALREADY_EXISTS_ERROR_CWSIP0045
                                                                 new Object[] { destinationDefinition.getName() },
                                                                 null));

                    SIMPDestinationAlreadyExistsException e = new SIMPDestinationAlreadyExistsException(
                                    nls_cwsik.getFormattedMessage(
                                                                  "DELIVERY_ERROR_SIRC_31", // DESTINATION_ALREADY_EXISTS_ERROR_CWSIP0045
                                                                  new Object[] { destinationDefinition.getName() },
                                                                  null));

                    e.setExceptionReason(SIRCConstants.SIRC0031_DESTINATION_ALREADY_EXISTS_ERROR);
                    e.setExceptionInserts(new String[] { destinationDefinition.getName() });
                    throw e;
                }

                // Only update destination handler objects with WCCM information if
                // we have not already detected them as corrupt.
                if (!destinationHandler.isCorruptOrIndoubt())
                {
                    // Destination already exists.  In the new WCCM world, the
                    // create should complete succesfully, with the new destination
                    // definition replacing the existing one.
                    // We update the localization definitions before we update the
                    // actual destination definition.

                    if (isQueue(destinationHandler.getDestinationType()))
                    {
                        if (destinationLocalizationDefinition != null)
                        {
                            // Update the localisation definition too.
                            destinationHandler.updateLocalizationDefinition(destinationLocalizationDefinition, transaction);
                        }
                    } // eof is q
                    else if (destinationHandler.getDestinationType() == DestinationType.TOPICSPACE)
                    {
                        destinationHandler.updateLocalizationDefinition(destinationLocalizationDefinition, transaction);
                    } // eof is topicspace

                    destinationHandler.updateDefinition(destinationDefinition);

                    // Update the set of localising messaging engines for the destinationHandler
                    // Dont create remote localisations up front.  This can be done
                    // if WLM picks one of them
                    destinationHandler.updateLocalizationSet(
                                    destinationLocalizingMEs);

                    // Alert the lookups object to handle the re-definition
                    DestinationIndex.Type type = new DestinationIndex.Type();
                    type.alias = new Boolean(destinationHandler.isAlias());
                    type.foreignDestination = new Boolean(destinationHandler.isForeign());
                    type.local = new Boolean(destinationHandler.hasLocal());
                    type.queue = new Boolean(!destinationHandler.isPubSub());
                    type.remote = new Boolean(destinationHandler.hasRemote());
                    type.state = destinationIndex.getState(destinationHandler);
                    destinationIndex.setType(destinationHandler, type);
                    destinationIndex.create(destinationHandler);

                    //Show that the destination is now reconciled
                    destinationHandler.setReconciled();

                    if (destinationHandler.getHasReconciledStreamsToBeDeleted())
                    {
                        //defect 259817
                        //there was some unfinished cleanup from before the ME previously shutdown
                        //that we now need to take care of.
                        destinationIndex.cleanup(destinationHandler);
                    }
                }
            }
            else // we did just create the destinationHandler.
            {
                if (isQueue(destinationHandler.getDestinationType()))
                {
                    if (destinationLocalizationDefinition != null)
                    {
                        // Create a new point to point localisation
                        destinationHandler.addNewPtoPLocalization(
                                                                  false,
                                                                  transaction,
                                                                  messagingEngineUuid,
                                                                  destinationLocalizationDefinition,
                                                                  true);
                    }
                } // eof is q
                else if (destinationHandler.getDestinationType() == DestinationType.TOPICSPACE)
                {
                    destinationHandler.addPubSubLocalisation(destinationLocalizationDefinition);
                } // eof is topicspace

                // Update the set of localising messaging engines for the destinationHandler
                // Dont create remote localisations up front.  This can be done
                // if WLM picks one of them
                destinationHandler.updateLocalizationSet(
                                destinationLocalizingMEs);

                // Put the newly created destination handler into the indexes
                destinationIndex.setLocalizationFlags(destinationHandler);

            } // eof we did just create the DH
        } // end of synchronization

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createDestinationLocalization");
    }
431264
public static Locale getCurrentLocale() {
        final UI currentUI = UI.getCurrent();
        return currentUI == null ? Locale.getDefault() : currentUI.getLocale();
    }
974296
public static LocalizationContext getLocalizationContext(PageContext pc) {
        LocalizationContext locCtxt = null;

        Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT);
        if (obj == null) {
            return null;
        }

        if (obj instanceof LocalizationContext) {
            locCtxt = (LocalizationContext) obj;
        } else {
            // localization context is a bundle basename
            locCtxt = getLocalizationContext(pc, (String) obj);
        }

        return locCtxt;
    }
719516
protected Locale getLocale(String destination, List<CmsProperty> properties) {

        String localeName = CmsProperty.get(CmsPropertyDefinition.PROPERTY_LOCALE, properties).getValue();

        if (localeName != null) {
            // locale was already set on the files properties
            return OpenCms.getLocaleManager().getAvailableLocales(localeName).get(0);
        }
        // locale not set in properties, read default locales
        return OpenCms.getLocaleManager().getDefaultLocales(m_cms, CmsResource.getParentFolder(destination)).get(0);
    }
454101
@Override
    public Locale getLocale() {
        if (super.getSession(false) == null) {
            return super.getLocale();
        }

        final IUserInstance userInstance =
                this.userInstanceManager.getUserInstance(this.getWrappedRequest());
        final LocaleManager localeManager = userInstance.getLocaleManager();
        final List<Locale> locales = localeManager.getLocales();
        return locales.get(0);
    }
767970
private void deleteDestLocalizations(JsBus bus) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, "deleteDestLocalizations", this);
        }

        Iterator i = alterDestinations.iterator();

        while (i.hasNext()) {

            String key = (String) i.next();

            try {
                // Get it from the old cache as it is no longer in the new cache.
                DestinationDefinition dd = (DestinationDefinition) _me.getSIBDestination(bus.getName(), key);
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    SibTr.debug(tc, "deleteDestLocalizations: deleting DestinationLocalization, name =" + key + " Name=");
                }
                if (!isInZOSServentRegion() && _mpAdmin != null) {
                	LocalizationEntry dldEntry = (LocalizationEntry) lpMap.get(dd.getName()+"@"+_me.getName());
                	LocalizationDefinition dld=(LocalizationDefinition) dldEntry.getLocalizationDefinition();
                	
                    //Venu Liberty change: passing Destination UUID as String.
                    //Destination Definition is passed as NULL as entire destination has to be deleted
                    _mpAdmin.deleteDestinationLocalization(dd.getUUID().toString(), null);  
                }
               
            } catch (Exception e) {
                com.ibm.ws.ffdc.FFDCFilter.processException(e, CLASS_NAME + ".deleteDestLocalizations", "1", this);
                SibTr.exception(tc, e);
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, "deleteDestLocalizations");
        }
    }
688326
@Override
    public void localQueuePointRemoved(boolean isDeleted,
                                       boolean isSystem,
                                       boolean isTemporary,
                                       SIBUuid8 messagingEngineUuid)
                    throws SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "localQueuePointRemoved",
                        new Object[] {
                                      Boolean.valueOf(isDeleted),
                                      Boolean.valueOf(isSystem),
                                      Boolean.valueOf(isTemporary),
                                      messagingEngineUuid,
                                      this });

        if (_pToPLocalMsgsItemStream != null)
        {
            // Remove the queuePoint from our queue points guess set, which we use to
            // guess where to send messages if WLM isnt working
            // and update TRM if necessary
            _localisationManager.localQueuePointRemoved(messagingEngineUuid);

            // Add the localisation into the set of those requiring clean-up
            _postMediatedItemStreamsRequiringCleanup.put(messagingEngineUuid, _pToPLocalMsgsItemStream);

            _pToPLocalMsgsItemStream.markAsToBeDeleted(
                            _baseDestinationHandler.getTransactionManager().createAutoCommitTransaction());

            // Close any locally attached consumers - producers are ok as there are
            // other localisations of the destination available.
            if (!_localisationManager.hasLocal())
                _remoteSupport.closeConsumers();

            // Dereference the localisation from the destinationHandler so that
            // if the localisation is re-created in WCCM, a new instance of the
            // localisation can be added back into the destinationHandler.
            dereferenceLocalisation(_pToPLocalMsgsItemStream);

            //Get the background clean-up thread to reallocate the messages and
            //clean up the localisation if possible.
            _destinationManager.markDestinationAsCleanUpPending(_baseDestinationHandler);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "localQueuePointRemoved");

    }
1157425
public LocalisationManager getLocalisationManager()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getLocalisationManager", this);
        // Instantiate LocalisationManager to manage localisations and interface to WLM

        if (_localisationManager == null)
        {
            _localisationManager =
                            new LocalisationManager(this);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getLocalisationManager", _localisationManager);

        return _localisationManager;
    }
1042576
PtoPXmitMsgsItemStream getXmitQueuePoint(SIBUuid8 meUuid)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getXmitQueuePoint", meUuid);

        PtoPXmitMsgsItemStream stream = getLocalisationManager().getXmitQueuePoint(meUuid);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getXmitQueuePoint", stream);

        return stream;
    }
258083
public Locale getLocale() {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        processLocales();
        // 321485
        Locale locale = (Locale) (_srtRequestHelper._locales.size() > 0 ? _srtRequestHelper._locales.get(0) : null);
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.logp(Level.FINE, CLASS_NAME,"getLocale", "this->"+this+": "+" locale --> " + (locale!=null?locale.toString():""));
        }
        return locale;
    }