Class JaloConnection


  • public class JaloConnection
    extends java.lang.Object
    The JaloConnection represents a connection to the system.

    • Field Detail

      • DEFAULT_SESSION_CLASS

        public static final java.lang.String DEFAULT_SESSION_CLASS
        See Also:
        Constant Field Values
      • LOGHMCCHANGES

        public static final java.lang.String LOGHMCCHANGES
      • ANONYMOUS_LOGIN_PROPERTIES

        public static final java.util.Properties ANONYMOUS_LOGIN_PROPERTIES
    • Constructor Detail

      • JaloConnection

        @Deprecated
        public JaloConnection()
        Deprecated.
        since ages
        do not call directly
    • Method Detail

      • setTenant

        @Deprecated
        public void setTenant​(Tenant tenant)
        Deprecated.
        since 5.0 , You should not mutate the JaloConnection's tenant.
        do not call directly
      • getTenant

        public Tenant getTenant()
      • registerJaloSessionListener

        public void registerJaloSessionListener​(JaloSessionListener jaloSessionListener)
        register a JaloSessionListener
      • unregisterJaloSessionListener

        public void unregisterJaloSessionListener​(JaloSessionListener jaloSessionListener)
        unregister a JaloSessionListener
      • getJaloSessionListeners

        public java.util.List<JaloSessionListener> getJaloSessionListeners()
      • cleanExpiredSessions

        @Deprecated
        public int cleanExpiredSessions()
        Deprecated.
        since 5.5.1 session management was changed and this method has no effect
        cleans old expired sessions from the session cache the cleaning will only occur every 'session.timeout.checkinterval' setting
        Returns:
        -1 if force was false and test did not run
      • cleanExpiredSessions

        @Deprecated
        public int cleanExpiredSessions​(boolean force)
        Deprecated.
        since 5.5.1 session management was changed and this method always returns -1
        cleans old expired sessions from the session cache
        Parameters:
        force - if true cleanup will happen immediately. each method call of cleanExpiredSessions will go through the complete session list to identify old sessions, this can take some time. if set to false, the cleaning will only occur every 'session.timeout.checkinterval' setting
        Returns:
        -1 if force was false and test did not run
      • guessSessionClass

        protected java.lang.Class guessSessionClass​(java.util.Map props)
      • createAnonymousCustomerSession

        public JaloSession createAnonymousCustomerSession()
                                                   throws JaloSecurityException
        Creates a session to the hybris platform system using a anonymous account.

        If the system does not allow anonymous login, a JaloSecurityException is thrown.

        Returns:
        a new JaloSession object
        Throws:
        JaloSecurityException - if there was a security problem creating the session (e.g. there is no anonymous user allowed to login)
      • createAnonymousCustomerSession

        public JaloSession createAnonymousCustomerSession​(java.lang.Class sessionClass)
                                                   throws JaloSecurityException
        Creates a session to the hybris platform system using a anonymous account.

        If the system does not allow anonymous login, a JaloSecurityException is thrown.

        Parameters:
        sessionClass - the jalo class of the new session, if null JaloSession will be taken
        Returns:
        a new JaloSession object
        Throws:
        JaloSecurityException - if there was a security problem creating the session (e.g. there is no anonymous user allowed to login)
      • createSession

        public JaloSession createSession​(java.util.Map loginProperties)
                                  throws JaloSecurityException,
                                         JaloInvalidParameterException
        Creates a session with the given login information.

        The login properties are given as a Map with the following key mappings:

        • user.principal: contains the principal, the Login of the user. This key is required, there is no default.
        • user.credentials: contains the password of the user. this field is required, there is no default. null as a password is not permitted.
        • session.type: the 'type' of the session. Valid types are: customer or employee. The user principal must be a user of the type provided in session.type. This key is required, there is no default.
        An example for a correct filled property map can be:
         Properties prop = new Properties();
         prop.setProperty(JaloSession.LoginProperties.LOGIN, "frank");
         prop.setProperty(JaloSession.LoginProperties.PASSWORD, "blurb");
         prop.setProperty(JaloSession.LoginProperties.SESSION_TYPE, JaloSession.LoginProperties.SessionTypes.CUSTOMER);
         

        if the provided login properties are wrong, a JaloSecurityException is thrown.
        if keys or values are missing in the provided map, a JaloInvalidParameterException is thrown.

        Parameters:
        loginProperties -
        Returns:
        a new JaloSession for the given user.
        Throws:
        JaloInvalidParameterException
        JaloSecurityException
        See Also:
        JaloSession.transfer(Map)
      • createSession

        public JaloSession createSession​(java.util.Map loginProperties,
                                         java.lang.Class sessionClass)
                                  throws JaloSecurityException,
                                         JaloInvalidParameterException
        Creates a session with the given login information.

        The login properties are given as a Map with the following key mappings:

        • user.principal: contains the principal, the Login of the user. This key is required, there is no default.
        • user.credentials: contains the password of the user. this field is required, there is no default. null as a password is not permitted.
        • session.type: the 'type' of the session. Valid types are: customer or employee. The user principal must be a user of the type provided in session.type. This key is required, there is no default.
        An example for a correct filled property map can be:
         Properties prop = new Properties();
         prop.setProperty(JaloSession.LoginProperties.LOGIN, "frank");
         prop.setProperty(JaloSession.LoginProperties.PASSWORD, "blurb");
         prop.setProperty(JaloSession.LoginProperties.SESSION_TYPE, JaloSession.LoginProperties.SessionTypes.CUSTOMER);
         

        if the provided login properties are wrong, a JaloSecurityException is thrown.
        if keys or values are missing in the provided map, a JaloInvalidParameterException is thrown.

        Parameters:
        loginProperties -
        sessionClass - the jalo class of the new session, if null JaloSession is taken
        Returns:
        a new JaloSession for the given user.
        Throws:
        JaloInvalidParameterException - in case login, password or session type is missing
        JaloSecurityException - in case of a login failure or the system is not initialized
        See Also:
        JaloSession.transfer(Map)
      • createSession

        public JaloSession createSession​(java.util.Map loginProperties,
                                         java.lang.Class sessionClass,
                                         java.util.Map initialAttributes)
                                  throws JaloSecurityException,
                                         JaloInvalidParameterException
        Creates a session with the given login information.

        The login properties are given as a Map with the following key mappings:

        • user.principal: contains the principal, the Login of the user. This key is required, there is no default.
        • user.credentials: contains the password of the user. this field is required, there is no default. null as a password is not permitted.
        • session.type: the 'type' of the session. Valid types are: customer or employee. The user principal must be a user of the type provided in session.type. This key is required, there is no default.
        An example for a correct filled property map can be:
         Properties prop = new Properties();
         prop.setProperty(JaloSession.LoginProperties.LOGIN, "frank");
         prop.setProperty(JaloSession.LoginProperties.PASSWORD, "blurb");
         prop.setProperty(JaloSession.LoginProperties.SESSION_TYPE, JaloSession.LoginProperties.SessionTypes.CUSTOMER);
         

        if the provided login properties are wrong, a JaloSecurityException is thrown.
        if keys or values are missing in the provided map, a JaloInvalidParameterException is thrown.

        Parameters:
        loginProperties -
        sessionClass - the jalo class of the new session, if null JaloSession is taken
        initialAttributes - initial attributes for the session
        Returns:
        a new JaloSession for the given user.
        Throws:
        JaloInvalidParameterException - in case login, password or session type is missing
        JaloSecurityException - in case of a login failure or the system is not initialized
        See Also:
        JaloSession.transfer(Map)
      • createSession

        public JaloSession createSession​(java.lang.String user,
                                         java.lang.String pwd)
                                  throws JaloSecurityException
        creates a session with the given username/pwd
        Parameters:
        user - the username
        pwd - the password
        Returns:
        the JaloSession
        Throws:
        JaloSecurityException - if the given combination was wrong
      • createSession

        public JaloSession createSession​(User user)
                                  throws JaloSecurityException
        Creates a new session using a already known user. Please note that there is no password check done here!
        Parameters:
        user - the user to create a new session for
        Returns:
        the new session
        Throws:
        JaloSecurityException
      • getAllSessions

        @Deprecated
        public java.util.Collection<JaloSession> getAllSessions()
        Deprecated.
        since 5.5.1 session management was changed and this method always returns empty collection
        returns all session that were made using this collection from this virtual machine.

        Attention: It will NOT return all sessions made to the server this connection is connected to.

      • getSession

        @Deprecated
        public JaloSession getSession​(java.lang.String sessionID)
        Deprecated.
        since 5.5.1 session management was changed and this method always returns current session or null
        Returns session with the given sessionID.

        When advanced property "hybris.improvedsessionhandling" is set to true JaloSession is not added to cache on creation. Extensions that use getSession(String) should manually add session to cache after creation using checkAndAddToSessionCache(JaloSession). It really means that if before mentioned property is set to true, the method getSession(String) will only return session, which have been manually registered.

        Parameters:
        sessionID - session ID of the session to be found
        Returns:
        session with the given ID, or null if no session with such ID exists
        Since:
        2.20SP5
      • getExpiredSessions

        @Deprecated
        public java.util.Collection<JaloSession> getExpiredSessions()
        Deprecated.
        since 5.5.1 session management was changed and this method always returns empty collection
        Returns all session that are expired and have not yet been closed.

        Since:
        2.20SP5
      • checkAndAddToSessionCache

        @Deprecated
        public void checkAndAddToSessionCache​(JaloSession session)
        Deprecated.
        since 5.5.1 session management was changed and this method has no effect
        Checks if JaloSession passed as parameter already exists in sessionCache. If not adds this JaloSession to the sessionCache. JaloSession that is not in sessionCache will never timeout. The purpose of this method is to add (or replace when already exists) JaloSession to sessionCache. PLA-8390
        Parameters:
        session - jaloSession
      • getSystemName

        public java.lang.String getSystemName()
        Returns the SystemName.

        The System name is just a description of the system.

        Returns:
        the system name
      • isSystemInitialized

        public boolean isSystemInitialized()
        this method tells if you may open a connection.
        Returns:
        true if the system was initialized correctly
      • toString

        public java.lang.String toString()
        Returns a String representation of this Connection.

        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)
        Test for equality.

        Because JaloConnection is a singleton, this will return true compared with itself, false otherwise

        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - the object to compare
      • hashCode

        public int hashCode()
        Object is singleton, so default hash code can be used.
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        equals(Object)
      • getUserManager

        public UserManager getUserManager()
        Returns the UserManager and sets it into instance property userManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via UserManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the UserManager object
      • getProductManager

        public ProductManager getProductManager()
        Returns the ProductManager and sets it into instance property productManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via ProductManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the ProductManager object
      • getNumberSeriesManager

        public NumberSeriesManager getNumberSeriesManager()
        Returns the NumberSeriesManager and sets it into instance property numberSeriesManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via NumberSeriesManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the NumberSeriesManager object
      • getFlexibleSearch

        public FlexibleSearch getFlexibleSearch()
        Returns the FlexibleSearch and sets it into instance property flexibleSearch, preventing it from mutation while creating via BeanFactory.getBean(String) or via FlexibleSearch constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the FlexibleSearch object
      • getC2LManager

        public C2LManager getC2LManager()
        Returns the C2LManager and sets it into instance property c2lManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via C2LManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the C2LManager object
      • getMetaInformationManager

        public MetaInformationManager getMetaInformationManager()
        Returns the MetaInformationManager and sets it into instance property metaInformationManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via MetaInformationManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the MetaInformationManager object
      • getMediaManager

        public MediaManager getMediaManager()
        Returns the MediaManager and sets it into instance property mediaManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via MediaManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the MediaManager object
      • getOrderManager

        public OrderManager getOrderManager()
        Returns the OrderManager and sets it into instance property orderManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via OrderManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the OrderManager object
      • getLinkManager

        public LinkManager getLinkManager()
        Returns the LinkManager and sets it into instance property linkManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via LinkManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the LinkManager object
      • getExtensionManager

        public ExtensionManager getExtensionManager()
        Returns the ExtensionManager and sets it into instance property extensionManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via ExtensionManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the ExtensionManager object
      • getTypeManager

        public TypeManager getTypeManager()
        Returns the TypeManager and sets it into instance property typeManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via TypeManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the TypeManager object
      • getEnumerationManager

        public EnumerationManager getEnumerationManager()
        Returns the EnumerationManager and sets it into instance property enumerationManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via EnumerationManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the EnumerationManager object
      • getAccessManager

        public AccessManager getAccessManager()
        Returns the AccessManager and sets it into instance property accessManager, preventing it from mutation while creating via BeanFactory.getBean(String) or via AccessManager constructor. Assures that returned instance hasn't been changed (or even set to null) in meantime - therefore access is thread safe.
        Returns:
        the AccessManager object
      • getJaloSessionListenersIncludingManagers

        public java.util.Collection<JaloSessionListener> getJaloSessionListenersIncludingManagers()
      • getManagers

        public java.util.List<Manager> getManagers()
      • logItemRemoval

        public SavedValues logItemRemoval​(PK itemPk,
                                          boolean saveAttributes)
        Creates a new SavedValues marking a item removal.
        Parameters:
        itemPk - the removed item
        saveAttributes - TODO
        Since:
        2.20
      • logItemRemoval

        @Deprecated
        public SavedValues logItemRemoval​(Item item,
                                          boolean saveAttributes)
        Deprecated.
        since ages - uselogItemRemoval(PK, boolean) instead
        Creates a new SavedValues marking a item removal.
        Parameters:
        item - the removed item
        saveAttributes - TODO
        Since:
        2.20
      • getModifiedItemAttributes

        protected java.util.Collection<ChangedItemAttributes> getModifiedItemAttributes​(Item item,
                                                                                        java.util.Map<java.lang.String,​java.lang.Object> previousValues,
                                                                                        java.util.Map<java.lang.String,​java.lang.Object> newValues)
      • isLoggingEnabled

        protected boolean isLoggingEnabled​(Item toLog)
      • logItemModification

        public SavedValues logItemModification​(PK itemPk,
                                               java.util.Map<java.lang.String,​java.lang.Object> values,
                                               java.util.Map<java.lang.String,​java.lang.Object> previousValues,
                                               boolean detectRemovedValues)
        Creates a new SavedValues marking a item modification.
        Parameters:
        itemPk - the created item
        values - its modified values
        previousValues - its previous values
        detectRemovedValues - TODO
      • logItemModification

        @Deprecated
        public SavedValues logItemModification​(Item item,
                                               java.util.Map<java.lang.String,​java.lang.Object> values,
                                               java.util.Map<java.lang.String,​java.lang.Object> previousValues,
                                               boolean detectRemovedValues)
        Deprecated.
        Creates a new SavedValues marking a item modification.
        Parameters:
        item - the created item
        values - its modified values
        previousValues - its previous values
        detectRemovedValues - TODO
      • filterRemovedItems

        protected java.util.Collection filterRemovedItems​(java.lang.Object attributeValue)
        Parameters:
        attributeValue -
        Returns:
        a Collection with the removed items TODO: correct?
        Since:
        2.20
      • logItemCreation

        @Deprecated
        public SavedValues logItemCreation​(Item item,
                                           java.util.Map values)
        Deprecated.
        since ages - uselogItemCreation(PK, Map)
        Creates a new SavedValues marking a item creation.
        Parameters:
        item - the created item
        values - its creation values
      • logItemCreation

        public SavedValues logItemCreation​(PK itemPk,
                                           java.util.Map values)
        Creates a new SavedValues marking a item creation.
        Parameters:
        itemPk - the created item PK
        values - its creation values
      • getCreatedItemAttributes

        protected java.util.Collection<ChangedItemAttributes> getCreatedItemAttributes​(Item item,
                                                                                       java.util.Map<java.lang.String,​java.lang.Object> values)