getBadColumnNames();
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-api/src/main/java/com/mw/totp_2fa/key/service/persistence/SecretKeyUtil.java b/modules/totp-2fa-key-api/src/main/java/com/mw/totp_2fa/key/service/persistence/SecretKeyUtil.java
index eb44dba..9353442 100644
--- a/modules/totp-2fa-key-api/src/main/java/com/mw/totp_2fa/key/service/persistence/SecretKeyUtil.java
+++ b/modules/totp-2fa-key-api/src/main/java/com/mw/totp_2fa/key/service/persistence/SecretKeyUtil.java
@@ -14,22 +14,24 @@
package com.mw.totp_2fa.key.service.persistence;
-import aQute.bnd.annotation.ProviderType;
-
-import com.liferay.osgi.util.ServiceTrackerFactory;
-
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.mw.totp_2fa.key.model.SecretKey;
-import org.osgi.util.tracker.ServiceTracker;
+import java.io.Serializable;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.util.tracker.ServiceTracker;
/**
- * The persistence utility for the secret key service. This utility wraps {@link com.mw.totp_2fa.key.service.persistence.impl.SecretKeyPersistenceImpl} and provides direct access to the database for CRUD operations. This utility should only be used by the service layer, as it must operate within a transaction. Never access this utility in a JSP, controller, model, or other front-end class.
+ * The persistence utility for the secret key service. This utility wraps com.mw.totp_2fa.key.service.persistence.impl.SecretKeyPersistenceImpl and provides direct access to the database for CRUD operations. This utility should only be used by the service layer, as it must operate within a transaction. Never access this utility in a JSP, controller, model, or other front-end class.
*
*
* Caching information and settings can be found in portal.properties
@@ -37,11 +39,10 @@
*
* @author Brian Wing Shun Chan
* @see SecretKeyPersistence
- * @see com.mw.totp_2fa.key.service.persistence.impl.SecretKeyPersistenceImpl
* @generated
*/
-@ProviderType
public class SecretKeyUtil {
+
/*
* NOTE FOR DEVELOPERS:
*
@@ -69,11 +70,21 @@ public static long countWithDynamicQuery(DynamicQuery dynamicQuery) {
return getPersistence().countWithDynamicQuery(dynamicQuery);
}
+ /**
+ * @see com.liferay.portal.kernel.service.persistence.BasePersistence#fetchByPrimaryKeys(Set)
+ */
+ public static Map fetchByPrimaryKeys(
+ Set primaryKeys) {
+
+ return getPersistence().fetchByPrimaryKeys(primaryKeys);
+ }
+
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery)
*/
public static List findWithDynamicQuery(
DynamicQuery dynamicQuery) {
+
return getPersistence().findWithDynamicQuery(dynamicQuery);
}
@@ -82,6 +93,7 @@ public static List findWithDynamicQuery(
*/
public static List findWithDynamicQuery(
DynamicQuery dynamicQuery, int start, int end) {
+
return getPersistence().findWithDynamicQuery(dynamicQuery, start, end);
}
@@ -91,9 +103,9 @@ public static List findWithDynamicQuery(
public static List findWithDynamicQuery(
DynamicQuery dynamicQuery, int start, int end,
OrderByComparator orderByComparator) {
- return getPersistence()
- .findWithDynamicQuery(dynamicQuery, start, end,
- orderByComparator);
+
+ return getPersistence().findWithDynamicQuery(
+ dynamicQuery, start, end, orderByComparator);
}
/**
@@ -106,437 +118,459 @@ public static SecretKey update(SecretKey secretKey) {
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#update(com.liferay.portal.kernel.model.BaseModel, ServiceContext)
*/
- public static SecretKey update(SecretKey secretKey,
- ServiceContext serviceContext) {
+ public static SecretKey update(
+ SecretKey secretKey, ServiceContext serviceContext) {
+
return getPersistence().update(secretKey, serviceContext);
}
/**
- * Returns all the secret keies where uuid = ?.
- *
- * @param uuid the uuid
- * @return the matching secret keies
- */
- public static List findByUuid(java.lang.String uuid) {
+ * Returns all the secret keys where uuid = ?.
+ *
+ * @param uuid the uuid
+ * @return the matching secret keys
+ */
+ public static List findByUuid(String uuid) {
return getPersistence().findByUuid(uuid);
}
/**
- * Returns a range of all the secret keies where uuid = ?.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param uuid the uuid
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of matching secret keies
- */
- public static List findByUuid(java.lang.String uuid, int start,
- int end) {
+ * Returns a range of all the secret keys where uuid = ?.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param uuid the uuid
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of matching secret keys
+ */
+ public static List findByUuid(String uuid, int start, int end) {
return getPersistence().findByUuid(uuid, start, end);
}
/**
- * Returns an ordered range of all the secret keies where uuid = ?.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param uuid the uuid
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @param orderByComparator the comparator to order the results by (optionally null)
- * @return the ordered range of matching secret keies
- */
- public static List findByUuid(java.lang.String uuid, int start,
- int end, OrderByComparator orderByComparator) {
+ * Returns an ordered range of all the secret keys where uuid = ?.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param uuid the uuid
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally null)
+ * @return the ordered range of matching secret keys
+ */
+ public static List findByUuid(
+ String uuid, int start, int end,
+ OrderByComparator orderByComparator) {
+
return getPersistence().findByUuid(uuid, start, end, orderByComparator);
}
/**
- * Returns an ordered range of all the secret keies where uuid = ?.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param uuid the uuid
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @param orderByComparator the comparator to order the results by (optionally null)
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the ordered range of matching secret keies
- */
- public static List findByUuid(java.lang.String uuid, int start,
- int end, OrderByComparator orderByComparator,
- boolean retrieveFromCache) {
- return getPersistence()
- .findByUuid(uuid, start, end, orderByComparator,
- retrieveFromCache);
- }
-
- /**
- * Returns the first secret key in the ordered set where uuid = ?.
- *
- * @param uuid the uuid
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the first matching secret key
- * @throws NoSuchSecretKeyException if a matching secret key could not be found
- */
- public static SecretKey findByUuid_First(java.lang.String uuid,
- OrderByComparator orderByComparator)
+ * Returns an ordered range of all the secret keys where uuid = ?.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param uuid the uuid
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally null)
+ * @param useFinderCache whether to use the finder cache
+ * @return the ordered range of matching secret keys
+ */
+ public static List findByUuid(
+ String uuid, int start, int end,
+ OrderByComparator orderByComparator,
+ boolean useFinderCache) {
+
+ return getPersistence().findByUuid(
+ uuid, start, end, orderByComparator, useFinderCache);
+ }
+
+ /**
+ * Returns the first secret key in the ordered set where uuid = ?.
+ *
+ * @param uuid the uuid
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the first matching secret key
+ * @throws NoSuchSecretKeyException if a matching secret key could not be found
+ */
+ public static SecretKey findByUuid_First(
+ String uuid, OrderByComparator orderByComparator)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
+
return getPersistence().findByUuid_First(uuid, orderByComparator);
}
/**
- * Returns the first secret key in the ordered set where uuid = ?.
- *
- * @param uuid the uuid
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the first matching secret key, or null if a matching secret key could not be found
- */
- public static SecretKey fetchByUuid_First(java.lang.String uuid,
- OrderByComparator orderByComparator) {
+ * Returns the first secret key in the ordered set where uuid = ?.
+ *
+ * @param uuid the uuid
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the first matching secret key, or null if a matching secret key could not be found
+ */
+ public static SecretKey fetchByUuid_First(
+ String uuid, OrderByComparator orderByComparator) {
+
return getPersistence().fetchByUuid_First(uuid, orderByComparator);
}
/**
- * Returns the last secret key in the ordered set where uuid = ?.
- *
- * @param uuid the uuid
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the last matching secret key
- * @throws NoSuchSecretKeyException if a matching secret key could not be found
- */
- public static SecretKey findByUuid_Last(java.lang.String uuid,
- OrderByComparator orderByComparator)
+ * Returns the last secret key in the ordered set where uuid = ?.
+ *
+ * @param uuid the uuid
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the last matching secret key
+ * @throws NoSuchSecretKeyException if a matching secret key could not be found
+ */
+ public static SecretKey findByUuid_Last(
+ String uuid, OrderByComparator orderByComparator)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
+
return getPersistence().findByUuid_Last(uuid, orderByComparator);
}
/**
- * Returns the last secret key in the ordered set where uuid = ?.
- *
- * @param uuid the uuid
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the last matching secret key, or null if a matching secret key could not be found
- */
- public static SecretKey fetchByUuid_Last(java.lang.String uuid,
- OrderByComparator orderByComparator) {
+ * Returns the last secret key in the ordered set where uuid = ?.
+ *
+ * @param uuid the uuid
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the last matching secret key, or null if a matching secret key could not be found
+ */
+ public static SecretKey fetchByUuid_Last(
+ String uuid, OrderByComparator orderByComparator) {
+
return getPersistence().fetchByUuid_Last(uuid, orderByComparator);
}
/**
- * Returns the secret keies before and after the current secret key in the ordered set where uuid = ?.
- *
- * @param secretKeyId the primary key of the current secret key
- * @param uuid the uuid
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the previous, current, and next secret key
- * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
- */
- public static SecretKey[] findByUuid_PrevAndNext(long secretKeyId,
- java.lang.String uuid, OrderByComparator orderByComparator)
+ * Returns the secret keys before and after the current secret key in the ordered set where uuid = ?.
+ *
+ * @param secretKeyId the primary key of the current secret key
+ * @param uuid the uuid
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the previous, current, and next secret key
+ * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
+ */
+ public static SecretKey[] findByUuid_PrevAndNext(
+ long secretKeyId, String uuid,
+ OrderByComparator orderByComparator)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
- return getPersistence()
- .findByUuid_PrevAndNext(secretKeyId, uuid, orderByComparator);
+
+ return getPersistence().findByUuid_PrevAndNext(
+ secretKeyId, uuid, orderByComparator);
}
/**
- * Removes all the secret keies where uuid = ? from the database.
- *
- * @param uuid the uuid
- */
- public static void removeByUuid(java.lang.String uuid) {
+ * Removes all the secret keys where uuid = ? from the database.
+ *
+ * @param uuid the uuid
+ */
+ public static void removeByUuid(String uuid) {
getPersistence().removeByUuid(uuid);
}
/**
- * Returns the number of secret keies where uuid = ?.
- *
- * @param uuid the uuid
- * @return the number of matching secret keies
- */
- public static int countByUuid(java.lang.String uuid) {
+ * Returns the number of secret keys where uuid = ?.
+ *
+ * @param uuid the uuid
+ * @return the number of matching secret keys
+ */
+ public static int countByUuid(String uuid) {
return getPersistence().countByUuid(uuid);
}
/**
- * Returns all the secret keies where uuid = ? and companyId = ?.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @return the matching secret keies
- */
- public static List findByUuid_C(java.lang.String uuid,
- long companyId) {
+ * Returns all the secret keys where uuid = ? and companyId = ?.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @return the matching secret keys
+ */
+ public static List findByUuid_C(String uuid, long companyId) {
return getPersistence().findByUuid_C(uuid, companyId);
}
/**
- * Returns a range of all the secret keies where uuid = ? and companyId = ?.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of matching secret keies
- */
- public static List findByUuid_C(java.lang.String uuid,
- long companyId, int start, int end) {
+ * Returns a range of all the secret keys where uuid = ? and companyId = ?.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of matching secret keys
+ */
+ public static List findByUuid_C(
+ String uuid, long companyId, int start, int end) {
+
return getPersistence().findByUuid_C(uuid, companyId, start, end);
}
/**
- * Returns an ordered range of all the secret keies where uuid = ? and companyId = ?.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @param orderByComparator the comparator to order the results by (optionally null)
- * @return the ordered range of matching secret keies
- */
- public static List findByUuid_C(java.lang.String uuid,
- long companyId, int start, int end,
+ * Returns an ordered range of all the secret keys where uuid = ? and companyId = ?.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally null)
+ * @return the ordered range of matching secret keys
+ */
+ public static List findByUuid_C(
+ String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
- return getPersistence()
- .findByUuid_C(uuid, companyId, start, end, orderByComparator);
- }
-
- /**
- * Returns an ordered range of all the secret keies where uuid = ? and companyId = ?.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @param orderByComparator the comparator to order the results by (optionally null)
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the ordered range of matching secret keies
- */
- public static List findByUuid_C(java.lang.String uuid,
- long companyId, int start, int end,
+
+ return getPersistence().findByUuid_C(
+ uuid, companyId, start, end, orderByComparator);
+ }
+
+ /**
+ * Returns an ordered range of all the secret keys where uuid = ? and companyId = ?.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally null)
+ * @param useFinderCache whether to use the finder cache
+ * @return the ordered range of matching secret keys
+ */
+ public static List findByUuid_C(
+ String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator,
- boolean retrieveFromCache) {
- return getPersistence()
- .findByUuid_C(uuid, companyId, start, end,
- orderByComparator, retrieveFromCache);
- }
-
- /**
- * Returns the first secret key in the ordered set where uuid = ? and companyId = ?.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the first matching secret key
- * @throws NoSuchSecretKeyException if a matching secret key could not be found
- */
- public static SecretKey findByUuid_C_First(java.lang.String uuid,
- long companyId, OrderByComparator orderByComparator)
+ boolean useFinderCache) {
+
+ return getPersistence().findByUuid_C(
+ uuid, companyId, start, end, orderByComparator, useFinderCache);
+ }
+
+ /**
+ * Returns the first secret key in the ordered set where uuid = ? and companyId = ?.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the first matching secret key
+ * @throws NoSuchSecretKeyException if a matching secret key could not be found
+ */
+ public static SecretKey findByUuid_C_First(
+ String uuid, long companyId,
+ OrderByComparator orderByComparator)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
- return getPersistence()
- .findByUuid_C_First(uuid, companyId, orderByComparator);
- }
-
- /**
- * Returns the first secret key in the ordered set where uuid = ? and companyId = ?.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the first matching secret key, or null if a matching secret key could not be found
- */
- public static SecretKey fetchByUuid_C_First(java.lang.String uuid,
- long companyId, OrderByComparator orderByComparator) {
- return getPersistence()
- .fetchByUuid_C_First(uuid, companyId, orderByComparator);
- }
-
- /**
- * Returns the last secret key in the ordered set where uuid = ? and companyId = ?.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the last matching secret key
- * @throws NoSuchSecretKeyException if a matching secret key could not be found
- */
- public static SecretKey findByUuid_C_Last(java.lang.String uuid,
- long companyId, OrderByComparator orderByComparator)
+
+ return getPersistence().findByUuid_C_First(
+ uuid, companyId, orderByComparator);
+ }
+
+ /**
+ * Returns the first secret key in the ordered set where uuid = ? and companyId = ?.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the first matching secret key, or null if a matching secret key could not be found
+ */
+ public static SecretKey fetchByUuid_C_First(
+ String uuid, long companyId,
+ OrderByComparator orderByComparator) {
+
+ return getPersistence().fetchByUuid_C_First(
+ uuid, companyId, orderByComparator);
+ }
+
+ /**
+ * Returns the last secret key in the ordered set where uuid = ? and companyId = ?.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the last matching secret key
+ * @throws NoSuchSecretKeyException if a matching secret key could not be found
+ */
+ public static SecretKey findByUuid_C_Last(
+ String uuid, long companyId,
+ OrderByComparator orderByComparator)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
- return getPersistence()
- .findByUuid_C_Last(uuid, companyId, orderByComparator);
- }
-
- /**
- * Returns the last secret key in the ordered set where uuid = ? and companyId = ?.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the last matching secret key, or null if a matching secret key could not be found
- */
- public static SecretKey fetchByUuid_C_Last(java.lang.String uuid,
- long companyId, OrderByComparator orderByComparator) {
- return getPersistence()
- .fetchByUuid_C_Last(uuid, companyId, orderByComparator);
- }
-
- /**
- * Returns the secret keies before and after the current secret key in the ordered set where uuid = ? and companyId = ?.
- *
- * @param secretKeyId the primary key of the current secret key
- * @param uuid the uuid
- * @param companyId the company ID
- * @param orderByComparator the comparator to order the set by (optionally null)
- * @return the previous, current, and next secret key
- * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
- */
- public static SecretKey[] findByUuid_C_PrevAndNext(long secretKeyId,
- java.lang.String uuid, long companyId,
- OrderByComparator orderByComparator)
+
+ return getPersistence().findByUuid_C_Last(
+ uuid, companyId, orderByComparator);
+ }
+
+ /**
+ * Returns the last secret key in the ordered set where uuid = ? and companyId = ?.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the last matching secret key, or null if a matching secret key could not be found
+ */
+ public static SecretKey fetchByUuid_C_Last(
+ String uuid, long companyId,
+ OrderByComparator orderByComparator) {
+
+ return getPersistence().fetchByUuid_C_Last(
+ uuid, companyId, orderByComparator);
+ }
+
+ /**
+ * Returns the secret keys before and after the current secret key in the ordered set where uuid = ? and companyId = ?.
+ *
+ * @param secretKeyId the primary key of the current secret key
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @param orderByComparator the comparator to order the set by (optionally null)
+ * @return the previous, current, and next secret key
+ * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
+ */
+ public static SecretKey[] findByUuid_C_PrevAndNext(
+ long secretKeyId, String uuid, long companyId,
+ OrderByComparator orderByComparator)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
- return getPersistence()
- .findByUuid_C_PrevAndNext(secretKeyId, uuid, companyId,
- orderByComparator);
+
+ return getPersistence().findByUuid_C_PrevAndNext(
+ secretKeyId, uuid, companyId, orderByComparator);
}
/**
- * Removes all the secret keies where uuid = ? and companyId = ? from the database.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- */
- public static void removeByUuid_C(java.lang.String uuid, long companyId) {
+ * Removes all the secret keys where uuid = ? and companyId = ? from the database.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ */
+ public static void removeByUuid_C(String uuid, long companyId) {
getPersistence().removeByUuid_C(uuid, companyId);
}
/**
- * Returns the number of secret keies where uuid = ? and companyId = ?.
- *
- * @param uuid the uuid
- * @param companyId the company ID
- * @return the number of matching secret keies
- */
- public static int countByUuid_C(java.lang.String uuid, long companyId) {
+ * Returns the number of secret keys where uuid = ? and companyId = ?.
+ *
+ * @param uuid the uuid
+ * @param companyId the company ID
+ * @return the number of matching secret keys
+ */
+ public static int countByUuid_C(String uuid, long companyId) {
return getPersistence().countByUuid_C(uuid, companyId);
}
/**
- * Returns the secret key where companyId = ? and userId = ? or throws a {@link NoSuchSecretKeyException} if it could not be found.
- *
- * @param companyId the company ID
- * @param userId the user ID
- * @return the matching secret key
- * @throws NoSuchSecretKeyException if a matching secret key could not be found
- */
+ * Returns the secret key where companyId = ? and userId = ? or throws a NoSuchSecretKeyException if it could not be found.
+ *
+ * @param companyId the company ID
+ * @param userId the user ID
+ * @return the matching secret key
+ * @throws NoSuchSecretKeyException if a matching secret key could not be found
+ */
public static SecretKey findByC_U(long companyId, long userId)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
+
return getPersistence().findByC_U(companyId, userId);
}
/**
- * Returns the secret key where companyId = ? and userId = ? or returns null if it could not be found. Uses the finder cache.
- *
- * @param companyId the company ID
- * @param userId the user ID
- * @return the matching secret key, or null if a matching secret key could not be found
- */
+ * Returns the secret key where companyId = ? and userId = ? or returns null if it could not be found. Uses the finder cache.
+ *
+ * @param companyId the company ID
+ * @param userId the user ID
+ * @return the matching secret key, or null if a matching secret key could not be found
+ */
public static SecretKey fetchByC_U(long companyId, long userId) {
return getPersistence().fetchByC_U(companyId, userId);
}
/**
- * Returns the secret key where companyId = ? and userId = ? or returns null if it could not be found, optionally using the finder cache.
- *
- * @param companyId the company ID
- * @param userId the user ID
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the matching secret key, or null if a matching secret key could not be found
- */
- public static SecretKey fetchByC_U(long companyId, long userId,
- boolean retrieveFromCache) {
- return getPersistence().fetchByC_U(companyId, userId, retrieveFromCache);
+ * Returns the secret key where companyId = ? and userId = ? or returns null if it could not be found, optionally using the finder cache.
+ *
+ * @param companyId the company ID
+ * @param userId the user ID
+ * @param useFinderCache whether to use the finder cache
+ * @return the matching secret key, or null if a matching secret key could not be found
+ */
+ public static SecretKey fetchByC_U(
+ long companyId, long userId, boolean useFinderCache) {
+
+ return getPersistence().fetchByC_U(companyId, userId, useFinderCache);
}
/**
- * Removes the secret key where companyId = ? and userId = ? from the database.
- *
- * @param companyId the company ID
- * @param userId the user ID
- * @return the secret key that was removed
- */
+ * Removes the secret key where companyId = ? and userId = ? from the database.
+ *
+ * @param companyId the company ID
+ * @param userId the user ID
+ * @return the secret key that was removed
+ */
public static SecretKey removeByC_U(long companyId, long userId)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
+
return getPersistence().removeByC_U(companyId, userId);
}
/**
- * Returns the number of secret keies where companyId = ? and userId = ?.
- *
- * @param companyId the company ID
- * @param userId the user ID
- * @return the number of matching secret keies
- */
+ * Returns the number of secret keys where companyId = ? and userId = ?.
+ *
+ * @param companyId the company ID
+ * @param userId the user ID
+ * @return the number of matching secret keys
+ */
public static int countByC_U(long companyId, long userId) {
return getPersistence().countByC_U(companyId, userId);
}
/**
- * Caches the secret key in the entity cache if it is enabled.
- *
- * @param secretKey the secret key
- */
+ * Caches the secret key in the entity cache if it is enabled.
+ *
+ * @param secretKey the secret key
+ */
public static void cacheResult(SecretKey secretKey) {
getPersistence().cacheResult(secretKey);
}
/**
- * Caches the secret keies in the entity cache if it is enabled.
- *
- * @param secretKeies the secret keies
- */
- public static void cacheResult(List secretKeies) {
- getPersistence().cacheResult(secretKeies);
+ * Caches the secret keys in the entity cache if it is enabled.
+ *
+ * @param secretKeys the secret keys
+ */
+ public static void cacheResult(List secretKeys) {
+ getPersistence().cacheResult(secretKeys);
}
/**
- * Creates a new secret key with the primary key. Does not add the secret key to the database.
- *
- * @param secretKeyId the primary key for the new secret key
- * @return the new secret key
- */
+ * Creates a new secret key with the primary key. Does not add the secret key to the database.
+ *
+ * @param secretKeyId the primary key for the new secret key
+ * @return the new secret key
+ */
public static SecretKey create(long secretKeyId) {
return getPersistence().create(secretKeyId);
}
/**
- * Removes the secret key with the primary key from the database. Also notifies the appropriate model listeners.
- *
- * @param secretKeyId the primary key of the secret key
- * @return the secret key that was removed
- * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
- */
+ * Removes the secret key with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param secretKeyId the primary key of the secret key
+ * @return the secret key that was removed
+ * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
+ */
public static SecretKey remove(long secretKeyId)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
+
return getPersistence().remove(secretKeyId);
}
@@ -545,117 +579,126 @@ public static SecretKey updateImpl(SecretKey secretKey) {
}
/**
- * Returns the secret key with the primary key or throws a {@link NoSuchSecretKeyException} if it could not be found.
- *
- * @param secretKeyId the primary key of the secret key
- * @return the secret key
- * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
- */
+ * Returns the secret key with the primary key or throws a NoSuchSecretKeyException if it could not be found.
+ *
+ * @param secretKeyId the primary key of the secret key
+ * @return the secret key
+ * @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
+ */
public static SecretKey findByPrimaryKey(long secretKeyId)
throws com.mw.totp_2fa.key.exception.NoSuchSecretKeyException {
+
return getPersistence().findByPrimaryKey(secretKeyId);
}
/**
- * Returns the secret key with the primary key or returns null if it could not be found.
- *
- * @param secretKeyId the primary key of the secret key
- * @return the secret key, or null if a secret key with the primary key could not be found
- */
+ * Returns the secret key with the primary key or returns null if it could not be found.
+ *
+ * @param secretKeyId the primary key of the secret key
+ * @return the secret key, or null if a secret key with the primary key could not be found
+ */
public static SecretKey fetchByPrimaryKey(long secretKeyId) {
return getPersistence().fetchByPrimaryKey(secretKeyId);
}
- public static java.util.Map fetchByPrimaryKeys(
- java.util.Set primaryKeys) {
- return getPersistence().fetchByPrimaryKeys(primaryKeys);
- }
-
/**
- * Returns all the secret keies.
- *
- * @return the secret keies
- */
+ * Returns all the secret keys.
+ *
+ * @return the secret keys
+ */
public static List findAll() {
return getPersistence().findAll();
}
/**
- * Returns a range of all the secret keies.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of secret keies
- */
+ * Returns a range of all the secret keys.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of secret keys
+ */
public static List findAll(int start, int end) {
return getPersistence().findAll(start, end);
}
/**
- * Returns an ordered range of all the secret keies.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @param orderByComparator the comparator to order the results by (optionally null)
- * @return the ordered range of secret keies
- */
- public static List findAll(int start, int end,
- OrderByComparator orderByComparator) {
+ * Returns an ordered range of all the secret keys.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally null)
+ * @return the ordered range of secret keys
+ */
+ public static List findAll(
+ int start, int end, OrderByComparator orderByComparator) {
+
return getPersistence().findAll(start, end, orderByComparator);
}
/**
- * Returns an ordered range of all the secret keies.
- *
- *
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
- *
- *
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @param orderByComparator the comparator to order the results by (optionally null)
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the ordered range of secret keies
- */
- public static List findAll(int start, int end,
- OrderByComparator orderByComparator,
- boolean retrieveFromCache) {
- return getPersistence()
- .findAll(start, end, orderByComparator, retrieveFromCache);
+ * Returns an ordered range of all the secret keys.
+ *
+ *
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
+ *
+ *
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally null)
+ * @param useFinderCache whether to use the finder cache
+ * @return the ordered range of secret keys
+ */
+ public static List findAll(
+ int start, int end, OrderByComparator orderByComparator,
+ boolean useFinderCache) {
+
+ return getPersistence().findAll(
+ start, end, orderByComparator, useFinderCache);
}
/**
- * Removes all the secret keies from the database.
- */
+ * Removes all the secret keys from the database.
+ */
public static void removeAll() {
getPersistence().removeAll();
}
/**
- * Returns the number of secret keies.
- *
- * @return the number of secret keies
- */
+ * Returns the number of secret keys.
+ *
+ * @return the number of secret keys
+ */
public static int countAll() {
return getPersistence().countAll();
}
- public static java.util.Set getBadColumnNames() {
- return getPersistence().getBadColumnNames();
- }
-
public static SecretKeyPersistence getPersistence() {
return _serviceTracker.getService();
}
- private static ServiceTracker _serviceTracker =
- ServiceTrackerFactory.open(SecretKeyPersistence.class);
+ private static ServiceTracker
+ _serviceTracker;
+
+ static {
+ Bundle bundle = FrameworkUtil.getBundle(SecretKeyPersistence.class);
+
+ ServiceTracker
+ serviceTracker =
+ new ServiceTracker(
+ bundle.getBundleContext(), SecretKeyPersistence.class,
+ null);
+
+ serviceTracker.open();
+
+ _serviceTracker = serviceTracker;
+ }
+
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/bnd.bnd b/modules/totp-2fa-key-service/bnd.bnd
index dbde114..136be8d 100644
--- a/modules/totp-2fa-key-service/bnd.bnd
+++ b/modules/totp-2fa-key-service/bnd.bnd
@@ -3,3 +3,9 @@ Bundle-SymbolicName: com.mw.totp-2fa.key.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
+Bundle-ClassPath:\
+ .,\
+ lib/commons-codec-1.13.jar
+-includeresource:\
+ lib/commons-codec-1.13.jar=commons-codec-1.13.jar
+-dsannotations-options: inherit
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/build.gradle b/modules/totp-2fa-key-service/build.gradle
index 52333f8..369b6e5 100644
--- a/modules/totp-2fa-key-service/build.gradle
+++ b/modules/totp-2fa-key-service/build.gradle
@@ -1,11 +1,8 @@
dependencies {
- compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
- compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
- compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.0"
- compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.0.0"
-
+ compileOnly group: "com.liferay.portal", name: "release.portal.api"
+
//Apache Commons
- compileOnly group: "commons-codec", name: "commons-codec", version: "1.9"
+ compile group: "commons-codec", name: "commons-codec", version: "1.13"
compileOnly project(":modules:totp-2fa-key-api")
}
diff --git a/modules/totp-2fa-key-service/service.xml b/modules/totp-2fa-key-service/service.xml
index 7a2ba8c..006a161 100644
--- a/modules/totp-2fa-key-service/service.xml
+++ b/modules/totp-2fa-key-service/service.xml
@@ -1,7 +1,7 @@
-
+
-
+
totp
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyBaseImpl.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyBaseImpl.java
index 394e2d4..1b60ca5 100644
--- a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyBaseImpl.java
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyBaseImpl.java
@@ -14,8 +14,6 @@
package com.mw.totp_2fa.key.model.impl;
-import aQute.bnd.annotation.ProviderType;
-
import com.mw.totp_2fa.key.model.SecretKey;
import com.mw.totp_2fa.key.service.SecretKeyLocalServiceUtil;
@@ -31,13 +29,13 @@
* @see SecretKey
* @generated
*/
-@ProviderType
-public abstract class SecretKeyBaseImpl extends SecretKeyModelImpl
- implements SecretKey {
+public abstract class SecretKeyBaseImpl
+ extends SecretKeyModelImpl implements SecretKey {
+
/*
* NOTE FOR DEVELOPERS:
*
- * Never modify or reference this class directly. All methods that expect a secret key model instance should use the {@link SecretKey} interface instead.
+ * Never modify or reference this class directly. All methods that expect a secret key model instance should use the SecretKey interface instead.
*/
@Override
public void persist() {
@@ -48,4 +46,5 @@ public void persist() {
SecretKeyLocalServiceUtil.updateSecretKey(this);
}
}
+
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyCacheModel.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyCacheModel.java
index 36af8f2..7b6ce6b 100644
--- a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyCacheModel.java
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyCacheModel.java
@@ -14,11 +14,9 @@
package com.mw.totp_2fa.key.model.impl;
-import aQute.bnd.annotation.ProviderType;
-
+import com.liferay.petra.lang.HashUtil;
+import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.model.CacheModel;
-import com.liferay.portal.kernel.util.HashUtil;
-import com.liferay.portal.kernel.util.StringBundler;
import com.mw.totp_2fa.key.model.SecretKey;
@@ -31,23 +29,22 @@
* The cache model class for representing SecretKey in entity cache.
*
* @author Brian Wing Shun Chan
- * @see SecretKey
* @generated
*/
-@ProviderType
-public class SecretKeyCacheModel implements CacheModel,
- Externalizable {
+public class SecretKeyCacheModel
+ implements CacheModel, Externalizable {
+
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
+ public boolean equals(Object object) {
+ if (this == object) {
return true;
}
- if (!(obj instanceof SecretKeyCacheModel)) {
+ if (!(object instanceof SecretKeyCacheModel)) {
return false;
}
- SecretKeyCacheModel secretKeyCacheModel = (SecretKeyCacheModel)obj;
+ SecretKeyCacheModel secretKeyCacheModel = (SecretKeyCacheModel)object;
if (secretKeyId == secretKeyCacheModel.secretKeyId) {
return true;
@@ -120,8 +117,7 @@ public void readExternal(ObjectInput objectInput) throws IOException {
}
@Override
- public void writeExternal(ObjectOutput objectOutput)
- throws IOException {
+ public void writeExternal(ObjectOutput objectOutput) throws IOException {
if (uuid == null) {
objectOutput.writeUTF("");
}
@@ -148,4 +144,5 @@ public void writeExternal(ObjectOutput objectOutput)
public long companyId;
public long userId;
public String secretKey;
+
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyModelImpl.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyModelImpl.java
index 6520109..1a0bf9c 100644
--- a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyModelImpl.java
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/model/impl/SecretKeyModelImpl.java
@@ -14,62 +14,67 @@
package com.mw.totp_2fa.key.model.impl;
-import aQute.bnd.annotation.ProviderType;
-
import com.liferay.expando.kernel.model.ExpandoBridge;
import com.liferay.expando.kernel.util.ExpandoBridgeFactoryUtil;
-
+import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.CacheModel;
+import com.liferay.portal.kernel.model.ModelWrapper;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.model.impl.BaseModelImpl;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
-import com.liferay.portal.kernel.util.StringBundler;
import com.mw.totp_2fa.key.model.SecretKey;
import com.mw.totp_2fa.key.model.SecretKeyModel;
import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+
import java.sql.Types;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Objects;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
/**
* The base model implementation for the SecretKey service. Represents a row in the "totp_SecretKey" database table, with each column mapped to a property of this class.
*
*
- * This implementation and its corresponding interface {@link SecretKeyModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SecretKeyImpl}.
+ * This implementation and its corresponding interface SecretKeyModel exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SecretKeyImpl}.
*
*
* @author Brian Wing Shun Chan
* @see SecretKeyImpl
- * @see SecretKey
- * @see SecretKeyModel
* @generated
*/
-@ProviderType
-public class SecretKeyModelImpl extends BaseModelImpl
- implements SecretKeyModel {
+public class SecretKeyModelImpl
+ extends BaseModelImpl implements SecretKeyModel {
+
/*
* NOTE FOR DEVELOPERS:
*
- * Never modify or reference this class directly. All methods that expect a secret key model instance should use the {@link SecretKey} interface instead.
+ * Never modify or reference this class directly. All methods that expect a secret key model instance should use the SecretKey interface instead.
*/
public static final String TABLE_NAME = "totp_SecretKey";
+
public static final Object[][] TABLE_COLUMNS = {
- { "uuid_", Types.VARCHAR },
- { "secretKeyId", Types.BIGINT },
- { "companyId", Types.BIGINT },
- { "userId", Types.BIGINT },
- { "secretKey", Types.VARCHAR }
- };
- public static final Map TABLE_COLUMNS_MAP = new HashMap();
+ {"uuid_", Types.VARCHAR}, {"secretKeyId", Types.BIGINT},
+ {"companyId", Types.BIGINT}, {"userId", Types.BIGINT},
+ {"secretKey", Types.VARCHAR}
+ };
+
+ public static final Map TABLE_COLUMNS_MAP =
+ new HashMap();
static {
TABLE_COLUMNS_MAP.put("uuid_", Types.VARCHAR);
@@ -79,28 +84,61 @@ public class SecretKeyModelImpl extends BaseModelImpl
TABLE_COLUMNS_MAP.put("secretKey", Types.VARCHAR);
}
- public static final String TABLE_SQL_CREATE = "create table totp_SecretKey (uuid_ VARCHAR(75) null,secretKeyId LONG not null primary key,companyId LONG,userId LONG,secretKey VARCHAR(75) null)";
+ public static final String TABLE_SQL_CREATE =
+ "create table totp_SecretKey (uuid_ VARCHAR(75) null,secretKeyId LONG not null primary key,companyId LONG,userId LONG,secretKey VARCHAR(75) null)";
+
public static final String TABLE_SQL_DROP = "drop table totp_SecretKey";
- public static final String ORDER_BY_JPQL = " ORDER BY secretKey.secretKeyId ASC";
- public static final String ORDER_BY_SQL = " ORDER BY totp_SecretKey.secretKeyId ASC";
+
+ public static final String ORDER_BY_JPQL =
+ " ORDER BY secretKey.secretKeyId ASC";
+
+ public static final String ORDER_BY_SQL =
+ " ORDER BY totp_SecretKey.secretKeyId ASC";
+
public static final String DATA_SOURCE = "liferayDataSource";
+
public static final String SESSION_FACTORY = "liferaySessionFactory";
+
public static final String TX_MANAGER = "liferayTransactionManager";
- public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.mw.totp_2fa.key.service.util.ServiceProps.get(
- "value.object.entity.cache.enabled.com.mw.totp_2fa.key.model.SecretKey"),
- true);
- public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.mw.totp_2fa.key.service.util.ServiceProps.get(
- "value.object.finder.cache.enabled.com.mw.totp_2fa.key.model.SecretKey"),
- true);
- public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.mw.totp_2fa.key.service.util.ServiceProps.get(
- "value.object.column.bitmask.enabled.com.mw.totp_2fa.key.model.SecretKey"),
- true);
+
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)}
+ */
+ @Deprecated
public static final long COMPANYID_COLUMN_BITMASK = 1L;
+
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)}
+ */
+ @Deprecated
public static final long USERID_COLUMN_BITMASK = 2L;
+
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)}
+ */
+ @Deprecated
public static final long UUID_COLUMN_BITMASK = 4L;
+
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link
+ * #getColumnBitmask(String)}
+ */
+ @Deprecated
public static final long SECRETKEYID_COLUMN_BITMASK = 8L;
- public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.mw.totp_2fa.key.service.util.ServiceProps.get(
- "lock.expiration.time.com.mw.totp_2fa.key.model.SecretKey"));
+
+ /**
+ * @deprecated As of Athanasius (7.3.x), with no direct replacement
+ */
+ @Deprecated
+ public static void setEntityCacheEnabled(boolean entityCacheEnabled) {
+ }
+
+ /**
+ * @deprecated As of Athanasius (7.3.x), with no direct replacement
+ */
+ @Deprecated
+ public static void setFinderCacheEnabled(boolean finderCacheEnabled) {
+ }
public SecretKeyModelImpl() {
}
@@ -139,49 +177,114 @@ public String getModelClassName() {
public Map getModelAttributes() {
Map attributes = new HashMap();
- attributes.put("uuid", getUuid());
- attributes.put("secretKeyId", getSecretKeyId());
- attributes.put("companyId", getCompanyId());
- attributes.put("userId", getUserId());
- attributes.put("secretKey", getSecretKey());
+ Map> attributeGetterFunctions =
+ getAttributeGetterFunctions();
- attributes.put("entityCacheEnabled", isEntityCacheEnabled());
- attributes.put("finderCacheEnabled", isFinderCacheEnabled());
+ for (Map.Entry> entry :
+ attributeGetterFunctions.entrySet()) {
+
+ String attributeName = entry.getKey();
+ Function attributeGetterFunction =
+ entry.getValue();
+
+ attributes.put(
+ attributeName, attributeGetterFunction.apply((SecretKey)this));
+ }
return attributes;
}
@Override
public void setModelAttributes(Map attributes) {
- String uuid = (String)attributes.get("uuid");
+ Map> attributeSetterBiConsumers =
+ getAttributeSetterBiConsumers();
- if (uuid != null) {
- setUuid(uuid);
- }
+ for (Map.Entry entry : attributes.entrySet()) {
+ String attributeName = entry.getKey();
- Long secretKeyId = (Long)attributes.get("secretKeyId");
+ BiConsumer attributeSetterBiConsumer =
+ attributeSetterBiConsumers.get(attributeName);
- if (secretKeyId != null) {
- setSecretKeyId(secretKeyId);
+ if (attributeSetterBiConsumer != null) {
+ attributeSetterBiConsumer.accept(
+ (SecretKey)this, entry.getValue());
+ }
}
+ }
- Long companyId = (Long)attributes.get("companyId");
+ public Map>
+ getAttributeGetterFunctions() {
- if (companyId != null) {
- setCompanyId(companyId);
- }
+ return _attributeGetterFunctions;
+ }
- Long userId = (Long)attributes.get("userId");
+ public Map>
+ getAttributeSetterBiConsumers() {
- if (userId != null) {
- setUserId(userId);
- }
+ return _attributeSetterBiConsumers;
+ }
- String secretKey = (String)attributes.get("secretKey");
+ private static Function
+ _getProxyProviderFunction() {
- if (secretKey != null) {
- setSecretKey(secretKey);
+ Class> proxyClass = ProxyUtil.getProxyClass(
+ SecretKey.class.getClassLoader(), SecretKey.class,
+ ModelWrapper.class);
+
+ try {
+ Constructor constructor =
+ (Constructor)proxyClass.getConstructor(
+ InvocationHandler.class);
+
+ return invocationHandler -> {
+ try {
+ return constructor.newInstance(invocationHandler);
+ }
+ catch (ReflectiveOperationException
+ reflectiveOperationException) {
+
+ throw new InternalError(reflectiveOperationException);
+ }
+ };
}
+ catch (NoSuchMethodException noSuchMethodException) {
+ throw new InternalError(noSuchMethodException);
+ }
+ }
+
+ private static final Map>
+ _attributeGetterFunctions;
+ private static final Map>
+ _attributeSetterBiConsumers;
+
+ static {
+ Map> attributeGetterFunctions =
+ new LinkedHashMap>();
+ Map> attributeSetterBiConsumers =
+ new LinkedHashMap>();
+
+ attributeGetterFunctions.put("uuid", SecretKey::getUuid);
+ attributeSetterBiConsumers.put(
+ "uuid", (BiConsumer)SecretKey::setUuid);
+ attributeGetterFunctions.put("secretKeyId", SecretKey::getSecretKeyId);
+ attributeSetterBiConsumers.put(
+ "secretKeyId",
+ (BiConsumer)SecretKey::setSecretKeyId);
+ attributeGetterFunctions.put("companyId", SecretKey::getCompanyId);
+ attributeSetterBiConsumers.put(
+ "companyId", (BiConsumer)SecretKey::setCompanyId);
+ attributeGetterFunctions.put("userId", SecretKey::getUserId);
+ attributeSetterBiConsumers.put(
+ "userId", (BiConsumer)SecretKey::setUserId);
+ attributeGetterFunctions.put("secretKey", SecretKey::getSecretKey);
+ attributeSetterBiConsumers.put(
+ "secretKey",
+ (BiConsumer)SecretKey::setSecretKey);
+
+ _attributeGetterFunctions = Collections.unmodifiableMap(
+ attributeGetterFunctions);
+ _attributeSetterBiConsumers = Collections.unmodifiableMap(
+ (Map)attributeSetterBiConsumers);
}
@Override
@@ -196,15 +299,20 @@ public String getUuid() {
@Override
public void setUuid(String uuid) {
- if (_originalUuid == null) {
- _originalUuid = _uuid;
+ if (_columnOriginalValues == Collections.EMPTY_MAP) {
+ _setColumnOriginalValues();
}
_uuid = uuid;
}
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link
+ * #getColumnOriginalValue(String)}
+ */
+ @Deprecated
public String getOriginalUuid() {
- return GetterUtil.getString(_originalUuid);
+ return getColumnOriginalValue("uuid_");
}
@Override
@@ -214,6 +322,10 @@ public long getSecretKeyId() {
@Override
public void setSecretKeyId(long secretKeyId) {
+ if (_columnOriginalValues == Collections.EMPTY_MAP) {
+ _setColumnOriginalValues();
+ }
+
_secretKeyId = secretKeyId;
}
@@ -224,19 +336,21 @@ public long getCompanyId() {
@Override
public void setCompanyId(long companyId) {
- _columnBitmask |= COMPANYID_COLUMN_BITMASK;
-
- if (!_setOriginalCompanyId) {
- _setOriginalCompanyId = true;
-
- _originalCompanyId = _companyId;
+ if (_columnOriginalValues == Collections.EMPTY_MAP) {
+ _setColumnOriginalValues();
}
_companyId = companyId;
}
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link
+ * #getColumnOriginalValue(String)}
+ */
+ @Deprecated
public long getOriginalCompanyId() {
- return _originalCompanyId;
+ return GetterUtil.getLong(
+ this.getColumnOriginalValue("companyId"));
}
@Override
@@ -246,12 +360,8 @@ public long getUserId() {
@Override
public void setUserId(long userId) {
- _columnBitmask |= USERID_COLUMN_BITMASK;
-
- if (!_setOriginalUserId) {
- _setOriginalUserId = true;
-
- _originalUserId = _userId;
+ if (_columnOriginalValues == Collections.EMPTY_MAP) {
+ _setColumnOriginalValues();
}
_userId = userId;
@@ -264,7 +374,7 @@ public String getUserUuid() {
return user.getUuid();
}
- catch (PortalException pe) {
+ catch (PortalException portalException) {
return "";
}
}
@@ -273,8 +383,13 @@ public String getUserUuid() {
public void setUserUuid(String userUuid) {
}
+ /**
+ * @deprecated As of Athanasius (7.3.x), replaced by {@link
+ * #getColumnOriginalValue(String)}
+ */
+ @Deprecated
public long getOriginalUserId() {
- return _originalUserId;
+ return GetterUtil.getLong(this.getColumnOriginalValue("userId"));
}
@Override
@@ -289,17 +404,41 @@ public String getSecretKey() {
@Override
public void setSecretKey(String secretKey) {
+ if (_columnOriginalValues == Collections.EMPTY_MAP) {
+ _setColumnOriginalValues();
+ }
+
_secretKey = secretKey;
}
public long getColumnBitmask() {
+ if (_columnBitmask > 0) {
+ return _columnBitmask;
+ }
+
+ if ((_columnOriginalValues == null) ||
+ (_columnOriginalValues == Collections.EMPTY_MAP)) {
+
+ return 0;
+ }
+
+ for (Map.Entry entry :
+ _columnOriginalValues.entrySet()) {
+
+ if (!Objects.equals(
+ entry.getValue(), getColumnValue(entry.getKey()))) {
+
+ _columnBitmask |= _columnBitmasks.get(entry.getKey());
+ }
+ }
+
return _columnBitmask;
}
@Override
public ExpandoBridge getExpandoBridge() {
- return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
- SecretKey.class.getName(), getPrimaryKey());
+ return ExpandoBridgeFactoryUtil.getExpandoBridge(
+ getCompanyId(), SecretKey.class.getName(), getPrimaryKey());
}
@Override
@@ -312,8 +451,13 @@ public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
@Override
public SecretKey toEscapedModel() {
if (_escapedModel == null) {
- _escapedModel = (SecretKey)ProxyUtil.newProxyInstance(_classLoader,
- _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
+ Function
+ escapedModelProxyProviderFunction =
+ EscapedModelProxyProviderFunctionHolder.
+ _escapedModelProxyProviderFunction;
+
+ _escapedModel = escapedModelProxyProviderFunction.apply(
+ new AutoEscapeBeanHandler(this));
}
return _escapedModel;
@@ -350,16 +494,16 @@ else if (getPrimaryKey() > primaryKey) {
}
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
+ public boolean equals(Object object) {
+ if (this == object) {
return true;
}
- if (!(obj instanceof SecretKey)) {
+ if (!(object instanceof SecretKey)) {
return false;
}
- SecretKey secretKey = (SecretKey)obj;
+ SecretKey secretKey = (SecretKey)object;
long primaryKey = secretKey.getPrimaryKey();
@@ -376,31 +520,29 @@ public int hashCode() {
return (int)getPrimaryKey();
}
+ /**
+ * @deprecated As of Athanasius (7.3.x), with no direct replacement
+ */
+ @Deprecated
@Override
public boolean isEntityCacheEnabled() {
- return ENTITY_CACHE_ENABLED;
+ return true;
}
+ /**
+ * @deprecated As of Athanasius (7.3.x), with no direct replacement
+ */
+ @Deprecated
@Override
public boolean isFinderCacheEnabled() {
- return FINDER_CACHE_ENABLED;
+ return true;
}
@Override
public void resetOriginalValues() {
- SecretKeyModelImpl secretKeyModelImpl = this;
-
- secretKeyModelImpl._originalUuid = secretKeyModelImpl._uuid;
-
- secretKeyModelImpl._originalCompanyId = secretKeyModelImpl._companyId;
-
- secretKeyModelImpl._setOriginalCompanyId = false;
-
- secretKeyModelImpl._originalUserId = secretKeyModelImpl._userId;
+ _columnOriginalValues = Collections.emptyMap();
- secretKeyModelImpl._setOriginalUserId = false;
-
- secretKeyModelImpl._columnBitmask = 0;
+ _columnBitmask = 0;
}
@Override
@@ -434,18 +576,31 @@ public CacheModel toCacheModel() {
@Override
public String toString() {
- StringBundler sb = new StringBundler(11);
-
- sb.append("{uuid=");
- sb.append(getUuid());
- sb.append(", secretKeyId=");
- sb.append(getSecretKeyId());
- sb.append(", companyId=");
- sb.append(getCompanyId());
- sb.append(", userId=");
- sb.append(getUserId());
- sb.append(", secretKey=");
- sb.append(getSecretKey());
+ Map> attributeGetterFunctions =
+ getAttributeGetterFunctions();
+
+ StringBundler sb = new StringBundler(
+ (4 * attributeGetterFunctions.size()) + 2);
+
+ sb.append("{");
+
+ for (Map.Entry> entry :
+ attributeGetterFunctions.entrySet()) {
+
+ String attributeName = entry.getKey();
+ Function attributeGetterFunction =
+ entry.getValue();
+
+ sb.append(attributeName);
+ sb.append("=");
+ sb.append(attributeGetterFunction.apply((SecretKey)this));
+ sb.append(", ");
+ }
+
+ if (sb.index() > 1) {
+ sb.setIndex(sb.index() - 1);
+ }
+
sb.append("}");
return sb.toString();
@@ -453,52 +608,119 @@ public String toString() {
@Override
public String toXmlString() {
- StringBundler sb = new StringBundler(19);
+ Map> attributeGetterFunctions =
+ getAttributeGetterFunctions();
+
+ StringBundler sb = new StringBundler(
+ (5 * attributeGetterFunctions.size()) + 4);
sb.append("");
- sb.append("com.mw.totp_2fa.key.model.SecretKey");
+ sb.append(getModelClassName());
sb.append("");
- sb.append(
- "uuid");
- sb.append(
- "secretKeyId");
- sb.append(
- "companyId");
- sb.append(
- "userId");
- sb.append(
- "secretKey");
+ for (Map.Entry> entry :
+ attributeGetterFunctions.entrySet()) {
+
+ String attributeName = entry.getKey();
+ Function attributeGetterFunction =
+ entry.getValue();
+
+ sb.append("");
+ sb.append(attributeName);
+ sb.append("");
+ }
sb.append("");
return sb.toString();
}
- private static final ClassLoader _classLoader = SecretKey.class.getClassLoader();
- private static final Class>[] _escapedModelInterfaces = new Class[] {
- SecretKey.class
- };
+ private static class EscapedModelProxyProviderFunctionHolder {
+
+ private static final Function
+ _escapedModelProxyProviderFunction = _getProxyProviderFunction();
+
+ }
+
private String _uuid;
- private String _originalUuid;
private long _secretKeyId;
private long _companyId;
- private long _originalCompanyId;
- private boolean _setOriginalCompanyId;
private long _userId;
- private long _originalUserId;
- private boolean _setOriginalUserId;
private String _secretKey;
+
+ public T getColumnValue(String columnName) {
+ columnName = _attributeNames.getOrDefault(columnName, columnName);
+
+ Function function = _attributeGetterFunctions.get(
+ columnName);
+
+ if (function == null) {
+ throw new IllegalArgumentException(
+ "No attribute getter function found for " + columnName);
+ }
+
+ return (T)function.apply((SecretKey)this);
+ }
+
+ public T getColumnOriginalValue(String columnName) {
+ if (_columnOriginalValues == null) {
+ return null;
+ }
+
+ if (_columnOriginalValues == Collections.EMPTY_MAP) {
+ _setColumnOriginalValues();
+ }
+
+ return (T)_columnOriginalValues.get(columnName);
+ }
+
+ private void _setColumnOriginalValues() {
+ _columnOriginalValues = new HashMap();
+
+ _columnOriginalValues.put("uuid_", _uuid);
+ _columnOriginalValues.put("secretKeyId", _secretKeyId);
+ _columnOriginalValues.put("companyId", _companyId);
+ _columnOriginalValues.put("userId", _userId);
+ _columnOriginalValues.put("secretKey", _secretKey);
+ }
+
+ private static final Map _attributeNames;
+
+ static {
+ Map attributeNames = new HashMap<>();
+
+ attributeNames.put("uuid_", "uuid");
+
+ _attributeNames = Collections.unmodifiableMap(attributeNames);
+ }
+
+ private transient Map _columnOriginalValues;
+
+ public static long getColumnBitmask(String columnName) {
+ return _columnBitmasks.get(columnName);
+ }
+
+ private static final Map _columnBitmasks;
+
+ static {
+ Map columnBitmasks = new HashMap<>();
+
+ columnBitmasks.put("uuid_", 1L);
+
+ columnBitmasks.put("secretKeyId", 2L);
+
+ columnBitmasks.put("companyId", 4L);
+
+ columnBitmasks.put("userId", 8L);
+
+ columnBitmasks.put("secretKey", 16L);
+
+ _columnBitmasks = Collections.unmodifiableMap(columnBitmasks);
+ }
+
private long _columnBitmask;
private SecretKey _escapedModel;
+
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/base/SecretKeyLocalServiceBaseImpl.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/base/SecretKeyLocalServiceBaseImpl.java
index 443658b..14551ab 100644
--- a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/base/SecretKeyLocalServiceBaseImpl.java
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/base/SecretKeyLocalServiceBaseImpl.java
@@ -14,9 +14,8 @@
package com.mw.totp_2fa.key.service.base;
-import aQute.bnd.annotation.ProviderType;
-
-import com.liferay.portal.kernel.bean.BeanReference;
+import com.liferay.petra.sql.dsl.query.DSLQuery;
+import com.liferay.portal.aop.AopService;
import com.liferay.portal.kernel.dao.db.DB;
import com.liferay.portal.kernel.dao.db.DBManagerUtil;
import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
@@ -34,23 +33,28 @@
import com.liferay.portal.kernel.search.Indexable;
import com.liferay.portal.kernel.search.IndexableType;
import com.liferay.portal.kernel.service.BaseLocalServiceImpl;
-import com.liferay.portal.kernel.service.PersistedModelLocalServiceRegistry;
-import com.liferay.portal.kernel.service.persistence.ClassNamePersistence;
-import com.liferay.portal.kernel.service.persistence.UserPersistence;
+import com.liferay.portal.kernel.service.PersistedModelLocalService;
+import com.liferay.portal.kernel.service.persistence.BasePersistence;
+import com.liferay.portal.kernel.transaction.Transactional;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PortalUtil;
-import com.liferay.portal.spring.extender.service.ServiceReference;
import com.mw.totp_2fa.key.model.SecretKey;
import com.mw.totp_2fa.key.service.SecretKeyLocalService;
+import com.mw.totp_2fa.key.service.SecretKeyLocalServiceUtil;
import com.mw.totp_2fa.key.service.persistence.SecretKeyPersistence;
import java.io.Serializable;
+import java.lang.reflect.Field;
+
import java.util.List;
import javax.sql.DataSource;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+
/**
* Provides the base implementation for the secret key local service.
*
@@ -60,21 +64,25 @@
*
* @author Brian Wing Shun Chan
* @see com.mw.totp_2fa.key.service.impl.SecretKeyLocalServiceImpl
- * @see com.mw.totp_2fa.key.service.SecretKeyLocalServiceUtil
* @generated
*/
-@ProviderType
-public abstract class SecretKeyLocalServiceBaseImpl extends BaseLocalServiceImpl
- implements SecretKeyLocalService, IdentifiableOSGiService {
+public abstract class SecretKeyLocalServiceBaseImpl
+ extends BaseLocalServiceImpl
+ implements AopService, IdentifiableOSGiService, SecretKeyLocalService {
+
/*
* NOTE FOR DEVELOPERS:
*
- * Never modify or reference this class directly. Always use {@link com.mw.totp_2fa.key.service.SecretKeyLocalServiceUtil} to access the secret key local service.
+ * Never modify or reference this class directly. Use SecretKeyLocalService via injection or a org.osgi.util.tracker.ServiceTracker or use SecretKeyLocalServiceUtil.
*/
/**
* Adds the secret key to the database. Also notifies the appropriate model listeners.
*
+ *
+ * Important: Inspect SecretKeyLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
+ *
+ *
* @param secretKey the secret key
* @return the secret key that was added
*/
@@ -93,6 +101,7 @@ public SecretKey addSecretKey(SecretKey secretKey) {
* @return the new secret key
*/
@Override
+ @Transactional(enabled = false)
public SecretKey createSecretKey(long secretKeyId) {
return secretKeyPersistence.create(secretKeyId);
}
@@ -100,20 +109,27 @@ public SecretKey createSecretKey(long secretKeyId) {
/**
* Deletes the secret key with the primary key from the database. Also notifies the appropriate model listeners.
*
+ *
+ * Important: Inspect SecretKeyLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
+ *
+ *
* @param secretKeyId the primary key of the secret key
* @return the secret key that was removed
* @throws PortalException if a secret key with the primary key could not be found
*/
@Indexable(type = IndexableType.DELETE)
@Override
- public SecretKey deleteSecretKey(long secretKeyId)
- throws PortalException {
+ public SecretKey deleteSecretKey(long secretKeyId) throws PortalException {
return secretKeyPersistence.remove(secretKeyId);
}
/**
* Deletes the secret key from the database. Also notifies the appropriate model listeners.
*
+ *
+ * Important: Inspect SecretKeyLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
+ *
+ *
* @param secretKey the secret key
* @return the secret key that was removed
*/
@@ -123,12 +139,24 @@ public SecretKey deleteSecretKey(SecretKey secretKey) {
return secretKeyPersistence.remove(secretKey);
}
+ @Override
+ public T dslQuery(DSLQuery dslQuery) {
+ return secretKeyPersistence.dslQuery(dslQuery);
+ }
+
+ @Override
+ public int dslQueryCount(DSLQuery dslQuery) {
+ Long count = dslQuery(dslQuery);
+
+ return count.intValue();
+ }
+
@Override
public DynamicQuery dynamicQuery() {
Class> clazz = getClass();
- return DynamicQueryFactoryUtil.forClass(SecretKey.class,
- clazz.getClassLoader());
+ return DynamicQueryFactoryUtil.forClass(
+ SecretKey.class, clazz.getClassLoader());
}
/**
@@ -146,7 +174,7 @@ public List dynamicQuery(DynamicQuery dynamicQuery) {
* Performs a dynamic query on the database and returns a range of the matching rows.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl.
*
*
* @param dynamicQuery the dynamic query
@@ -155,17 +183,18 @@ public List dynamicQuery(DynamicQuery dynamicQuery) {
* @return the range of matching rows
*/
@Override
- public List dynamicQuery(DynamicQuery dynamicQuery, int start,
- int end) {
- return secretKeyPersistence.findWithDynamicQuery(dynamicQuery, start,
- end);
+ public List dynamicQuery(
+ DynamicQuery dynamicQuery, int start, int end) {
+
+ return secretKeyPersistence.findWithDynamicQuery(
+ dynamicQuery, start, end);
}
/**
* Performs a dynamic query on the database and returns an ordered range of the matching rows.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl.
*
*
* @param dynamicQuery the dynamic query
@@ -175,10 +204,12 @@ public List dynamicQuery(DynamicQuery dynamicQuery, int start,
* @return the ordered range of matching rows
*/
@Override
- public List dynamicQuery(DynamicQuery dynamicQuery, int start,
- int end, OrderByComparator orderByComparator) {
- return secretKeyPersistence.findWithDynamicQuery(dynamicQuery, start,
- end, orderByComparator);
+ public List dynamicQuery(
+ DynamicQuery dynamicQuery, int start, int end,
+ OrderByComparator orderByComparator) {
+
+ return secretKeyPersistence.findWithDynamicQuery(
+ dynamicQuery, start, end, orderByComparator);
}
/**
@@ -200,10 +231,11 @@ public long dynamicQueryCount(DynamicQuery dynamicQuery) {
* @return the number of rows matching the dynamic query
*/
@Override
- public long dynamicQueryCount(DynamicQuery dynamicQuery,
- Projection projection) {
- return secretKeyPersistence.countWithDynamicQuery(dynamicQuery,
- projection);
+ public long dynamicQueryCount(
+ DynamicQuery dynamicQuery, Projection projection) {
+
+ return secretKeyPersistence.countWithDynamicQuery(
+ dynamicQuery, projection);
}
@Override
@@ -219,8 +251,9 @@ public SecretKey fetchSecretKey(long secretKeyId) {
* @return the matching secret key, or null if a matching secret key could not be found
*/
@Override
- public SecretKey fetchSecretKeyByUuidAndCompanyId(String uuid,
- long companyId) {
+ public SecretKey fetchSecretKeyByUuidAndCompanyId(
+ String uuid, long companyId) {
+
return secretKeyPersistence.fetchByUuid_C_First(uuid, companyId, null);
}
@@ -238,7 +271,8 @@ public SecretKey getSecretKey(long secretKeyId) throws PortalException {
@Override
public ActionableDynamicQuery getActionableDynamicQuery() {
- ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
+ ActionableDynamicQuery actionableDynamicQuery =
+ new DefaultActionableDynamicQuery();
actionableDynamicQuery.setBaseLocalService(secretKeyLocalService);
actionableDynamicQuery.setClassLoader(getClassLoader());
@@ -250,20 +284,26 @@ public ActionableDynamicQuery getActionableDynamicQuery() {
}
@Override
- public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
- IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
+ public IndexableActionableDynamicQuery
+ getIndexableActionableDynamicQuery() {
+
+ IndexableActionableDynamicQuery indexableActionableDynamicQuery =
+ new IndexableActionableDynamicQuery();
- indexableActionableDynamicQuery.setBaseLocalService(secretKeyLocalService);
+ indexableActionableDynamicQuery.setBaseLocalService(
+ secretKeyLocalService);
indexableActionableDynamicQuery.setClassLoader(getClassLoader());
indexableActionableDynamicQuery.setModelClass(SecretKey.class);
- indexableActionableDynamicQuery.setPrimaryKeyPropertyName("secretKeyId");
+ indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
+ "secretKeyId");
return indexableActionableDynamicQuery;
}
protected void initActionableDynamicQuery(
ActionableDynamicQuery actionableDynamicQuery) {
+
actionableDynamicQuery.setBaseLocalService(secretKeyLocalService);
actionableDynamicQuery.setClassLoader(getClassLoader());
actionableDynamicQuery.setModelClass(SecretKey.class);
@@ -271,18 +311,38 @@ protected void initActionableDynamicQuery(
actionableDynamicQuery.setPrimaryKeyPropertyName("secretKeyId");
}
+ /**
+ * @throws PortalException
+ */
+ @Override
+ public PersistedModel createPersistedModel(Serializable primaryKeyObj)
+ throws PortalException {
+
+ return secretKeyPersistence.create(((Long)primaryKeyObj).longValue());
+ }
+
/**
* @throws PortalException
*/
@Override
public PersistedModel deletePersistedModel(PersistedModel persistedModel)
throws PortalException {
+
return secretKeyLocalService.deleteSecretKey((SecretKey)persistedModel);
}
+ @Override
+ public BasePersistence getBasePersistence() {
+ return secretKeyPersistence;
+ }
+
+ /**
+ * @throws PortalException
+ */
@Override
public PersistedModel getPersistedModel(Serializable primaryKeyObj)
throws PortalException {
+
return secretKeyPersistence.findByPrimaryKey(primaryKeyObj);
}
@@ -297,38 +357,43 @@ public PersistedModel getPersistedModel(Serializable primaryKeyObj)
@Override
public SecretKey getSecretKeyByUuidAndCompanyId(String uuid, long companyId)
throws PortalException {
+
return secretKeyPersistence.findByUuid_C_First(uuid, companyId, null);
}
/**
- * Returns a range of all the secret keies.
+ * Returns a range of all the secret keys.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl.
*
*
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of secret keies
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of secret keys
*/
@Override
- public List getSecretKeies(int start, int end) {
+ public List getSecretKeys(int start, int end) {
return secretKeyPersistence.findAll(start, end);
}
/**
- * Returns the number of secret keies.
+ * Returns the number of secret keys.
*
- * @return the number of secret keies
+ * @return the number of secret keys
*/
@Override
- public int getSecretKeiesCount() {
+ public int getSecretKeysCount() {
return secretKeyPersistence.countAll();
}
/**
* Updates the secret key in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
*
+ *
+ * Important: Inspect SecretKeyLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
+ *
+ *
* @param secretKey the secret key
* @return the secret key that was updated
*/
@@ -338,165 +403,24 @@ public SecretKey updateSecretKey(SecretKey secretKey) {
return secretKeyPersistence.update(secretKey);
}
- /**
- * Returns the secret key local service.
- *
- * @return the secret key local service
- */
- public SecretKeyLocalService getSecretKeyLocalService() {
- return secretKeyLocalService;
- }
-
- /**
- * Sets the secret key local service.
- *
- * @param secretKeyLocalService the secret key local service
- */
- public void setSecretKeyLocalService(
- SecretKeyLocalService secretKeyLocalService) {
- this.secretKeyLocalService = secretKeyLocalService;
- }
-
- /**
- * Returns the secret key persistence.
- *
- * @return the secret key persistence
- */
- public SecretKeyPersistence getSecretKeyPersistence() {
- return secretKeyPersistence;
- }
-
- /**
- * Sets the secret key persistence.
- *
- * @param secretKeyPersistence the secret key persistence
- */
- public void setSecretKeyPersistence(
- SecretKeyPersistence secretKeyPersistence) {
- this.secretKeyPersistence = secretKeyPersistence;
- }
-
- /**
- * Returns the counter local service.
- *
- * @return the counter local service
- */
- public com.liferay.counter.kernel.service.CounterLocalService getCounterLocalService() {
- return counterLocalService;
- }
-
- /**
- * Sets the counter local service.
- *
- * @param counterLocalService the counter local service
- */
- public void setCounterLocalService(
- com.liferay.counter.kernel.service.CounterLocalService counterLocalService) {
- this.counterLocalService = counterLocalService;
+ @Deactivate
+ protected void deactivate() {
+ _setLocalServiceUtilService(null);
}
- /**
- * Returns the class name local service.
- *
- * @return the class name local service
- */
- public com.liferay.portal.kernel.service.ClassNameLocalService getClassNameLocalService() {
- return classNameLocalService;
- }
-
- /**
- * Sets the class name local service.
- *
- * @param classNameLocalService the class name local service
- */
- public void setClassNameLocalService(
- com.liferay.portal.kernel.service.ClassNameLocalService classNameLocalService) {
- this.classNameLocalService = classNameLocalService;
- }
-
- /**
- * Returns the class name persistence.
- *
- * @return the class name persistence
- */
- public ClassNamePersistence getClassNamePersistence() {
- return classNamePersistence;
- }
-
- /**
- * Sets the class name persistence.
- *
- * @param classNamePersistence the class name persistence
- */
- public void setClassNamePersistence(
- ClassNamePersistence classNamePersistence) {
- this.classNamePersistence = classNamePersistence;
- }
-
- /**
- * Returns the resource local service.
- *
- * @return the resource local service
- */
- public com.liferay.portal.kernel.service.ResourceLocalService getResourceLocalService() {
- return resourceLocalService;
- }
-
- /**
- * Sets the resource local service.
- *
- * @param resourceLocalService the resource local service
- */
- public void setResourceLocalService(
- com.liferay.portal.kernel.service.ResourceLocalService resourceLocalService) {
- this.resourceLocalService = resourceLocalService;
- }
-
- /**
- * Returns the user local service.
- *
- * @return the user local service
- */
- public com.liferay.portal.kernel.service.UserLocalService getUserLocalService() {
- return userLocalService;
- }
-
- /**
- * Sets the user local service.
- *
- * @param userLocalService the user local service
- */
- public void setUserLocalService(
- com.liferay.portal.kernel.service.UserLocalService userLocalService) {
- this.userLocalService = userLocalService;
- }
-
- /**
- * Returns the user persistence.
- *
- * @return the user persistence
- */
- public UserPersistence getUserPersistence() {
- return userPersistence;
- }
-
- /**
- * Sets the user persistence.
- *
- * @param userPersistence the user persistence
- */
- public void setUserPersistence(UserPersistence userPersistence) {
- this.userPersistence = userPersistence;
+ @Override
+ public Class>[] getAopInterfaces() {
+ return new Class>[] {
+ SecretKeyLocalService.class, IdentifiableOSGiService.class,
+ PersistedModelLocalService.class
+ };
}
- public void afterPropertiesSet() {
- persistedModelLocalServiceRegistry.register("com.mw.totp_2fa.key.model.SecretKey",
- secretKeyLocalService);
- }
+ @Override
+ public void setAopProxy(Object aopProxy) {
+ secretKeyLocalService = (SecretKeyLocalService)aopProxy;
- public void destroy() {
- persistedModelLocalServiceRegistry.unregister(
- "com.mw.totp_2fa.key.model.SecretKey");
+ _setLocalServiceUtilService(secretKeyLocalService);
}
/**
@@ -531,32 +455,51 @@ protected void runSQL(String sql) {
sql = db.buildSQL(sql);
sql = PortalUtil.transformSQL(sql);
- SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
- sql);
+ SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(
+ dataSource, sql);
sqlUpdate.update();
}
- catch (Exception e) {
- throw new SystemException(e);
+ catch (Exception exception) {
+ throw new SystemException(exception);
+ }
+ }
+
+ private void _setLocalServiceUtilService(
+ SecretKeyLocalService secretKeyLocalService) {
+
+ try {
+ Field field = SecretKeyLocalServiceUtil.class.getDeclaredField(
+ "_service");
+
+ field.setAccessible(true);
+
+ field.set(null, secretKeyLocalService);
+ }
+ catch (ReflectiveOperationException reflectiveOperationException) {
+ throw new RuntimeException(reflectiveOperationException);
}
}
- @BeanReference(type = SecretKeyLocalService.class)
protected SecretKeyLocalService secretKeyLocalService;
- @BeanReference(type = SecretKeyPersistence.class)
+
+ @Reference
protected SecretKeyPersistence secretKeyPersistence;
- @ServiceReference(type = com.liferay.counter.kernel.service.CounterLocalService.class)
- protected com.liferay.counter.kernel.service.CounterLocalService counterLocalService;
- @ServiceReference(type = com.liferay.portal.kernel.service.ClassNameLocalService.class)
- protected com.liferay.portal.kernel.service.ClassNameLocalService classNameLocalService;
- @ServiceReference(type = ClassNamePersistence.class)
- protected ClassNamePersistence classNamePersistence;
- @ServiceReference(type = com.liferay.portal.kernel.service.ResourceLocalService.class)
- protected com.liferay.portal.kernel.service.ResourceLocalService resourceLocalService;
- @ServiceReference(type = com.liferay.portal.kernel.service.UserLocalService.class)
- protected com.liferay.portal.kernel.service.UserLocalService userLocalService;
- @ServiceReference(type = UserPersistence.class)
- protected UserPersistence userPersistence;
- @ServiceReference(type = PersistedModelLocalServiceRegistry.class)
- protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
+
+ @Reference
+ protected com.liferay.counter.kernel.service.CounterLocalService
+ counterLocalService;
+
+ @Reference
+ protected com.liferay.portal.kernel.service.ClassNameLocalService
+ classNameLocalService;
+
+ @Reference
+ protected com.liferay.portal.kernel.service.ResourceLocalService
+ resourceLocalService;
+
+ @Reference
+ protected com.liferay.portal.kernel.service.UserLocalService
+ userLocalService;
+
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/impl/SecretKeyLocalServiceImpl.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/impl/SecretKeyLocalServiceImpl.java
index 403adbf..06385df 100644
--- a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/impl/SecretKeyLocalServiceImpl.java
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/impl/SecretKeyLocalServiceImpl.java
@@ -14,6 +14,7 @@
package com.mw.totp_2fa.key.service.impl;
+import com.liferay.portal.aop.AopService;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.User;
@@ -24,6 +25,7 @@
import java.security.SecureRandom;
import org.apache.commons.codec.binary.Base32;
+import org.osgi.service.component.annotations.Component;
/**
* The implementation of the secret key local service.
@@ -39,6 +41,7 @@
* @see SecretKeyLocalServiceBaseImpl
* @see com.mw.totp_2fa.key.service.SecretKeyLocalServiceUtil
*/
+@Component(service = AopService.class)
public class SecretKeyLocalServiceImpl extends SecretKeyLocalServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/SecretKeyPersistenceImpl.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/SecretKeyPersistenceImpl.java
index 376f256..60a0bc3 100644
--- a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/SecretKeyPersistenceImpl.java
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/SecretKeyPersistenceImpl.java
@@ -14,8 +14,9 @@
package com.mw.totp_2fa.key.service.persistence.impl;
-import aQute.bnd.annotation.ProviderType;
-
+import com.liferay.petra.string.StringBundler;
+import com.liferay.portal.kernel.configuration.Configuration;
+import com.liferay.portal.kernel.dao.orm.ArgumentsResolver;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
@@ -23,36 +24,47 @@
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
+import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
-import com.liferay.portal.kernel.service.persistence.CompanyProvider;
-import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
+import com.liferay.portal.kernel.model.BaseModel;
+import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
+import com.liferay.portal.kernel.service.persistence.BasePersistence;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
+import com.liferay.portal.kernel.util.HashMapDictionary;
import com.liferay.portal.kernel.util.OrderByComparator;
+import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
-import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
-import com.liferay.portal.spring.extender.service.ServiceReference;
import com.mw.totp_2fa.key.exception.NoSuchSecretKeyException;
import com.mw.totp_2fa.key.model.SecretKey;
+import com.mw.totp_2fa.key.model.SecretKeyTable;
import com.mw.totp_2fa.key.model.impl.SecretKeyImpl;
import com.mw.totp_2fa.key.model.impl.SecretKeyModelImpl;
import com.mw.totp_2fa.key.service.persistence.SecretKeyPersistence;
+import com.mw.totp_2fa.key.service.persistence.impl.constants.totpPersistenceConstants;
import java.io.Serializable;
-import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.sql.DataSource;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the secret key service.
@@ -62,56 +74,38 @@
*
*
* @author Brian Wing Shun Chan
- * @see SecretKeyPersistence
- * @see com.mw.totp_2fa.key.service.persistence.SecretKeyUtil
* @generated
*/
-@ProviderType
-public class SecretKeyPersistenceImpl extends BasePersistenceImpl
- implements SecretKeyPersistence {
+@Component(service = {SecretKeyPersistence.class, BasePersistence.class})
+public class SecretKeyPersistenceImpl
+ extends BasePersistenceImpl implements SecretKeyPersistence {
+
/*
* NOTE FOR DEVELOPERS:
*
- * Never modify or reference this class directly. Always use {@link SecretKeyUtil} to access the secret key persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class.
+ * Never modify or reference this class directly. Always use SecretKeyUtil to access the secret key persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class.
*/
- public static final String FINDER_CLASS_NAME_ENTITY = SecretKeyImpl.class.getName();
- public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
- ".List1";
- public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
- ".List2";
- public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
- public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
- public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, Long.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
- public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
- new String[] {
- String.class.getName(),
-
- Integer.class.getName(), Integer.class.getName(),
- OrderByComparator.class.getName()
- });
- public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
- new String[] { String.class.getName() },
- SecretKeyModelImpl.UUID_COLUMN_BITMASK);
- public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, Long.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
- new String[] { String.class.getName() });
+ public static final String FINDER_CLASS_NAME_ENTITY =
+ SecretKeyImpl.class.getName();
+
+ public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
+ FINDER_CLASS_NAME_ENTITY + ".List1";
+
+ public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
+ FINDER_CLASS_NAME_ENTITY + ".List2";
+
+ private FinderPath _finderPathWithPaginationFindAll;
+ private FinderPath _finderPathWithoutPaginationFindAll;
+ private FinderPath _finderPathCountAll;
+ private FinderPath _finderPathWithPaginationFindByUuid;
+ private FinderPath _finderPathWithoutPaginationFindByUuid;
+ private FinderPath _finderPathCountByUuid;
/**
- * Returns all the secret keies where uuid = ?.
+ * Returns all the secret keys where uuid = ?.
*
* @param uuid the uuid
- * @return the matching secret keies
+ * @return the matching secret keys
*/
@Override
public List findByUuid(String uuid) {
@@ -119,16 +113,16 @@ public List findByUuid(String uuid) {
}
/**
- * Returns a range of all the secret keies where uuid = ?.
+ * Returns a range of all the secret keys where uuid = ?.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
* @param uuid the uuid
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of matching secret keies
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of matching secret keys
*/
@Override
public List findByUuid(String uuid, int start, int end) {
@@ -136,66 +130,73 @@ public List findByUuid(String uuid, int start, int end) {
}
/**
- * Returns an ordered range of all the secret keies where uuid = ?.
+ * Returns an ordered range of all the secret keys where uuid = ?.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
* @param uuid the uuid
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
- * @return the ordered range of matching secret keies
+ * @return the ordered range of matching secret keys
*/
@Override
- public List findByUuid(String uuid, int start, int end,
+ public List findByUuid(
+ String uuid, int start, int end,
OrderByComparator orderByComparator) {
+
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
- * Returns an ordered range of all the secret keies where uuid = ?.
+ * Returns an ordered range of all the secret keys where uuid = ?.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
* @param uuid the uuid
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the ordered range of matching secret keies
+ * @param useFinderCache whether to use the finder cache
+ * @return the ordered range of matching secret keys
*/
@Override
- public List findByUuid(String uuid, int start, int end,
+ public List findByUuid(
+ String uuid, int start, int end,
OrderByComparator orderByComparator,
- boolean retrieveFromCache) {
- boolean pagination = true;
+ boolean useFinderCache) {
+
+ uuid = Objects.toString(uuid, "");
+
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
- (orderByComparator == null)) {
- pagination = false;
- finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
- finderArgs = new Object[] { uuid };
+ (orderByComparator == null)) {
+
+ if (useFinderCache) {
+ finderPath = _finderPathWithoutPaginationFindByUuid;
+ finderArgs = new Object[] {uuid};
+ }
}
- else {
- finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
- finderArgs = new Object[] { uuid, start, end, orderByComparator };
+ else if (useFinderCache) {
+ finderPath = _finderPathWithPaginationFindByUuid;
+ finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
- if (retrieveFromCache) {
- list = (List)finderCache.getResult(finderPath,
- finderArgs, this);
+ if (useFinderCache) {
+ list = (List)finderCache.getResult(
+ finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (SecretKey secretKey : list) {
- if (!Objects.equals(uuid, secretKey.getUuid())) {
+ if (!uuid.equals(secretKey.getUuid())) {
list = null;
break;
@@ -205,77 +206,63 @@ public List findByUuid(String uuid, int start, int end,
}
if (list == null) {
- StringBundler query = null;
+ StringBundler sb = null;
if (orderByComparator != null) {
- query = new StringBundler(3 +
- (orderByComparator.getOrderByFields().length * 2));
+ sb = new StringBundler(
+ 3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
- query = new StringBundler(3);
+ sb = new StringBundler(3);
}
- query.append(_SQL_SELECT_SECRETKEY_WHERE);
+ sb.append(_SQL_SELECT_SECRETKEY_WHERE);
boolean bindUuid = false;
- if (uuid == null) {
- query.append(_FINDER_COLUMN_UUID_UUID_1);
- }
- else if (uuid.equals("")) {
- query.append(_FINDER_COLUMN_UUID_UUID_3);
+ if (uuid.isEmpty()) {
+ sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
- query.append(_FINDER_COLUMN_UUID_UUID_2);
+ sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
- appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
- orderByComparator);
+ appendOrderByComparator(
+ sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
- else
- if (pagination) {
- query.append(SecretKeyModelImpl.ORDER_BY_JPQL);
+ else {
+ sb.append(SecretKeyModelImpl.ORDER_BY_JPQL);
}
- String sql = query.toString();
+ String sql = sb.toString();
Session session = null;
try {
session = openSession();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
- qPos.add(uuid);
+ queryPos.add(uuid);
}
- if (!pagination) {
- list = (List)QueryUtil.list(q, getDialect(),
- start, end, false);
-
- Collections.sort(list);
-
- list = Collections.unmodifiableList(list);
- }
- else {
- list = (List)QueryUtil.list(q, getDialect(),
- start, end);
- }
+ list = (List)QueryUtil.list(
+ query, getDialect(), start, end);
cacheResult(list);
- finderCache.putResult(finderPath, finderArgs, list);
+ if (useFinderCache) {
+ finderCache.putResult(finderPath, finderArgs, list);
+ }
}
- catch (Exception e) {
- finderCache.removeResult(finderPath, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -294,25 +281,26 @@ else if (uuid.equals("")) {
* @throws NoSuchSecretKeyException if a matching secret key could not be found
*/
@Override
- public SecretKey findByUuid_First(String uuid,
- OrderByComparator orderByComparator)
+ public SecretKey findByUuid_First(
+ String uuid, OrderByComparator orderByComparator)
throws NoSuchSecretKeyException {
+
SecretKey secretKey = fetchByUuid_First(uuid, orderByComparator);
if (secretKey != null) {
return secretKey;
}
- StringBundler msg = new StringBundler(4);
+ StringBundler sb = new StringBundler(4);
- msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+ sb.append(_NO_SUCH_ENTITY_WITH_KEY);
- msg.append("uuid=");
- msg.append(uuid);
+ sb.append("uuid=");
+ sb.append(uuid);
- msg.append("}");
+ sb.append("}");
- throw new NoSuchSecretKeyException(msg.toString());
+ throw new NoSuchSecretKeyException(sb.toString());
}
/**
@@ -323,8 +311,9 @@ public SecretKey findByUuid_First(String uuid,
* @return the first matching secret key, or null if a matching secret key could not be found
*/
@Override
- public SecretKey fetchByUuid_First(String uuid,
- OrderByComparator orderByComparator) {
+ public SecretKey fetchByUuid_First(
+ String uuid, OrderByComparator orderByComparator) {
+
List list = findByUuid(uuid, 0, 1, orderByComparator);
if (!list.isEmpty()) {
@@ -343,25 +332,26 @@ public SecretKey fetchByUuid_First(String uuid,
* @throws NoSuchSecretKeyException if a matching secret key could not be found
*/
@Override
- public SecretKey findByUuid_Last(String uuid,
- OrderByComparator orderByComparator)
+ public SecretKey findByUuid_Last(
+ String uuid, OrderByComparator orderByComparator)
throws NoSuchSecretKeyException {
+
SecretKey secretKey = fetchByUuid_Last(uuid, orderByComparator);
if (secretKey != null) {
return secretKey;
}
- StringBundler msg = new StringBundler(4);
+ StringBundler sb = new StringBundler(4);
- msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+ sb.append(_NO_SUCH_ENTITY_WITH_KEY);
- msg.append("uuid=");
- msg.append(uuid);
+ sb.append("uuid=");
+ sb.append(uuid);
- msg.append("}");
+ sb.append("}");
- throw new NoSuchSecretKeyException(msg.toString());
+ throw new NoSuchSecretKeyException(sb.toString());
}
/**
@@ -372,16 +362,17 @@ public SecretKey findByUuid_Last(String uuid,
* @return the last matching secret key, or null if a matching secret key could not be found
*/
@Override
- public SecretKey fetchByUuid_Last(String uuid,
- OrderByComparator orderByComparator) {
+ public SecretKey fetchByUuid_Last(
+ String uuid, OrderByComparator orderByComparator) {
+
int count = countByUuid(uuid);
if (count == 0) {
return null;
}
- List list = findByUuid(uuid, count - 1, count,
- orderByComparator);
+ List list = findByUuid(
+ uuid, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
@@ -391,7 +382,7 @@ public SecretKey fetchByUuid_Last(String uuid,
}
/**
- * Returns the secret keies before and after the current secret key in the ordered set where uuid = ?.
+ * Returns the secret keys before and after the current secret key in the ordered set where uuid = ?.
*
* @param secretKeyId the primary key of the current secret key
* @param uuid the uuid
@@ -400,9 +391,13 @@ public SecretKey fetchByUuid_Last(String uuid,
* @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
*/
@Override
- public SecretKey[] findByUuid_PrevAndNext(long secretKeyId, String uuid,
- OrderByComparator orderByComparator)
+ public SecretKey[] findByUuid_PrevAndNext(
+ long secretKeyId, String uuid,
+ OrderByComparator orderByComparator)
throws NoSuchSecretKeyException {
+
+ uuid = Objects.toString(uuid, "");
+
SecretKey secretKey = findByPrimaryKey(secretKeyId);
Session session = null;
@@ -412,135 +407,134 @@ public SecretKey[] findByUuid_PrevAndNext(long secretKeyId, String uuid,
SecretKey[] array = new SecretKeyImpl[3];
- array[0] = getByUuid_PrevAndNext(session, secretKey, uuid,
- orderByComparator, true);
+ array[0] = getByUuid_PrevAndNext(
+ session, secretKey, uuid, orderByComparator, true);
array[1] = secretKey;
- array[2] = getByUuid_PrevAndNext(session, secretKey, uuid,
- orderByComparator, false);
+ array[2] = getByUuid_PrevAndNext(
+ session, secretKey, uuid, orderByComparator, false);
return array;
}
- catch (Exception e) {
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
}
}
- protected SecretKey getByUuid_PrevAndNext(Session session,
- SecretKey secretKey, String uuid,
+ protected SecretKey getByUuid_PrevAndNext(
+ Session session, SecretKey secretKey, String uuid,
OrderByComparator orderByComparator, boolean previous) {
- StringBundler query = null;
+
+ StringBundler sb = null;
if (orderByComparator != null) {
- query = new StringBundler(4 +
- (orderByComparator.getOrderByConditionFields().length * 3) +
+ sb = new StringBundler(
+ 4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
- query = new StringBundler(3);
+ sb = new StringBundler(3);
}
- query.append(_SQL_SELECT_SECRETKEY_WHERE);
+ sb.append(_SQL_SELECT_SECRETKEY_WHERE);
boolean bindUuid = false;
- if (uuid == null) {
- query.append(_FINDER_COLUMN_UUID_UUID_1);
- }
- else if (uuid.equals("")) {
- query.append(_FINDER_COLUMN_UUID_UUID_3);
+ if (uuid.isEmpty()) {
+ sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
- query.append(_FINDER_COLUMN_UUID_UUID_2);
+ sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
- String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
+ String[] orderByConditionFields =
+ orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
- query.append(WHERE_AND);
+ sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
- query.append(_ORDER_BY_ENTITY_ALIAS);
- query.append(orderByConditionFields[i]);
+ sb.append(_ORDER_BY_ENTITY_ALIAS);
+ sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
- query.append(WHERE_GREATER_THAN_HAS_NEXT);
+ sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
- query.append(WHERE_LESSER_THAN_HAS_NEXT);
+ sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
- query.append(WHERE_GREATER_THAN);
+ sb.append(WHERE_GREATER_THAN);
}
else {
- query.append(WHERE_LESSER_THAN);
+ sb.append(WHERE_LESSER_THAN);
}
}
}
- query.append(ORDER_BY_CLAUSE);
+ sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
- query.append(_ORDER_BY_ENTITY_ALIAS);
- query.append(orderByFields[i]);
+ sb.append(_ORDER_BY_ENTITY_ALIAS);
+ sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
- query.append(ORDER_BY_ASC_HAS_NEXT);
+ sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
- query.append(ORDER_BY_DESC_HAS_NEXT);
+ sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
- query.append(ORDER_BY_ASC);
+ sb.append(ORDER_BY_ASC);
}
else {
- query.append(ORDER_BY_DESC);
+ sb.append(ORDER_BY_DESC);
}
}
}
}
else {
- query.append(SecretKeyModelImpl.ORDER_BY_JPQL);
+ sb.append(SecretKeyModelImpl.ORDER_BY_JPQL);
}
- String sql = query.toString();
+ String sql = sb.toString();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- q.setFirstResult(0);
- q.setMaxResults(2);
+ query.setFirstResult(0);
+ query.setMaxResults(2);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
- qPos.add(uuid);
+ queryPos.add(uuid);
}
if (orderByComparator != null) {
- Object[] values = orderByComparator.getOrderByConditionValues(secretKey);
+ for (Object orderByConditionValue :
+ orderByComparator.getOrderByConditionValues(secretKey)) {
- for (Object value : values) {
- qPos.add(value);
+ queryPos.add(orderByConditionValue);
}
}
- List list = q.list();
+ List list = query.list();
if (list.size() == 2) {
return list.get(1);
@@ -551,74 +545,72 @@ else if (uuid.equals("")) {
}
/**
- * Removes all the secret keies where uuid = ? from the database.
+ * Removes all the secret keys where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
- for (SecretKey secretKey : findByUuid(uuid, QueryUtil.ALL_POS,
- QueryUtil.ALL_POS, null)) {
+ for (SecretKey secretKey :
+ findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
+
remove(secretKey);
}
}
/**
- * Returns the number of secret keies where uuid = ?.
+ * Returns the number of secret keys where uuid = ?.
*
* @param uuid the uuid
- * @return the number of matching secret keies
+ * @return the number of matching secret keys
*/
@Override
public int countByUuid(String uuid) {
- FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
+ uuid = Objects.toString(uuid, "");
+
+ FinderPath finderPath = _finderPathCountByUuid;
- Object[] finderArgs = new Object[] { uuid };
+ Object[] finderArgs = new Object[] {uuid};
- Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
+ Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
- StringBundler query = new StringBundler(2);
+ StringBundler sb = new StringBundler(2);
- query.append(_SQL_COUNT_SECRETKEY_WHERE);
+ sb.append(_SQL_COUNT_SECRETKEY_WHERE);
boolean bindUuid = false;
- if (uuid == null) {
- query.append(_FINDER_COLUMN_UUID_UUID_1);
- }
- else if (uuid.equals("")) {
- query.append(_FINDER_COLUMN_UUID_UUID_3);
+ if (uuid.isEmpty()) {
+ sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
- query.append(_FINDER_COLUMN_UUID_UUID_2);
+ sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
- String sql = query.toString();
+ String sql = sb.toString();
Session session = null;
try {
session = openSession();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
- qPos.add(uuid);
+ queryPos.add(uuid);
}
- count = (Long)q.uniqueResult();
+ count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
- catch (Exception e) {
- finderCache.removeResult(finderPath, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -628,130 +620,124 @@ else if (uuid.equals("")) {
return count.intValue();
}
- private static final String _FINDER_COLUMN_UUID_UUID_1 = "secretKey.uuid IS NULL";
- private static final String _FINDER_COLUMN_UUID_UUID_2 = "secretKey.uuid = ?";
- private static final String _FINDER_COLUMN_UUID_UUID_3 = "(secretKey.uuid IS NULL OR secretKey.uuid = '')";
- public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
- new String[] {
- String.class.getName(), Long.class.getName(),
-
- Integer.class.getName(), Integer.class.getName(),
- OrderByComparator.class.getName()
- });
- public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
- new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
- new String[] { String.class.getName(), Long.class.getName() },
- SecretKeyModelImpl.UUID_COLUMN_BITMASK |
- SecretKeyModelImpl.COMPANYID_COLUMN_BITMASK);
- public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, Long.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
- new String[] { String.class.getName(), Long.class.getName() });
+ private static final String _FINDER_COLUMN_UUID_UUID_2 =
+ "secretKey.uuid = ?";
+
+ private static final String _FINDER_COLUMN_UUID_UUID_3 =
+ "(secretKey.uuid IS NULL OR secretKey.uuid = '')";
+
+ private FinderPath _finderPathWithPaginationFindByUuid_C;
+ private FinderPath _finderPathWithoutPaginationFindByUuid_C;
+ private FinderPath _finderPathCountByUuid_C;
/**
- * Returns all the secret keies where uuid = ? and companyId = ?.
+ * Returns all the secret keys where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
- * @return the matching secret keies
+ * @return the matching secret keys
*/
@Override
public List findByUuid_C(String uuid, long companyId) {
- return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
- QueryUtil.ALL_POS, null);
+ return findByUuid_C(
+ uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
- * Returns a range of all the secret keies where uuid = ? and companyId = ?.
+ * Returns a range of all the secret keys where uuid = ? and companyId = ?.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
* @param uuid the uuid
* @param companyId the company ID
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of matching secret keies
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of matching secret keys
*/
@Override
- public List findByUuid_C(String uuid, long companyId, int start,
- int end) {
+ public List findByUuid_C(
+ String uuid, long companyId, int start, int end) {
+
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
- * Returns an ordered range of all the secret keies where uuid = ? and companyId = ?.
+ * Returns an ordered range of all the secret keys where uuid = ? and companyId = ?.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
* @param uuid the uuid
* @param companyId the company ID
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
- * @return the ordered range of matching secret keies
+ * @return the ordered range of matching secret keys
*/
@Override
- public List findByUuid_C(String uuid, long companyId, int start,
- int end, OrderByComparator orderByComparator) {
- return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
+ public List findByUuid_C(
+ String uuid, long companyId, int start, int end,
+ OrderByComparator orderByComparator) {
+
+ return findByUuid_C(
+ uuid, companyId, start, end, orderByComparator, true);
}
/**
- * Returns an ordered range of all the secret keies where uuid = ? and companyId = ?.
+ * Returns an ordered range of all the secret keys where uuid = ? and companyId = ?.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
* @param uuid the uuid
* @param companyId the company ID
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the ordered range of matching secret keies
+ * @param useFinderCache whether to use the finder cache
+ * @return the ordered range of matching secret keys
*/
@Override
- public List findByUuid_C(String uuid, long companyId, int start,
- int end, OrderByComparator orderByComparator,
- boolean retrieveFromCache) {
- boolean pagination = true;
+ public List findByUuid_C(
+ String uuid, long companyId, int start, int end,
+ OrderByComparator orderByComparator,
+ boolean useFinderCache) {
+
+ uuid = Objects.toString(uuid, "");
+
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
- (orderByComparator == null)) {
- pagination = false;
- finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
- finderArgs = new Object[] { uuid, companyId };
+ (orderByComparator == null)) {
+
+ if (useFinderCache) {
+ finderPath = _finderPathWithoutPaginationFindByUuid_C;
+ finderArgs = new Object[] {uuid, companyId};
+ }
}
- else {
- finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
+ else if (useFinderCache) {
+ finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
- uuid, companyId,
-
- start, end, orderByComparator
- };
+ uuid, companyId, start, end, orderByComparator
+ };
}
List list = null;
- if (retrieveFromCache) {
- list = (List)finderCache.getResult(finderPath,
- finderArgs, this);
+ if (useFinderCache) {
+ list = (List)finderCache.getResult(
+ finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (SecretKey secretKey : list) {
- if (!Objects.equals(uuid, secretKey.getUuid()) ||
- (companyId != secretKey.getCompanyId())) {
+ if (!uuid.equals(secretKey.getUuid()) ||
+ (companyId != secretKey.getCompanyId())) {
+
list = null;
break;
@@ -761,81 +747,67 @@ public List findByUuid_C(String uuid, long companyId, int start,
}
if (list == null) {
- StringBundler query = null;
+ StringBundler sb = null;
if (orderByComparator != null) {
- query = new StringBundler(4 +
- (orderByComparator.getOrderByFields().length * 2));
+ sb = new StringBundler(
+ 4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
- query = new StringBundler(4);
+ sb = new StringBundler(4);
}
- query.append(_SQL_SELECT_SECRETKEY_WHERE);
+ sb.append(_SQL_SELECT_SECRETKEY_WHERE);
boolean bindUuid = false;
- if (uuid == null) {
- query.append(_FINDER_COLUMN_UUID_C_UUID_1);
- }
- else if (uuid.equals("")) {
- query.append(_FINDER_COLUMN_UUID_C_UUID_3);
+ if (uuid.isEmpty()) {
+ sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
- query.append(_FINDER_COLUMN_UUID_C_UUID_2);
+ sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
- query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
+ sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
- appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
- orderByComparator);
+ appendOrderByComparator(
+ sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
- else
- if (pagination) {
- query.append(SecretKeyModelImpl.ORDER_BY_JPQL);
+ else {
+ sb.append(SecretKeyModelImpl.ORDER_BY_JPQL);
}
- String sql = query.toString();
+ String sql = sb.toString();
Session session = null;
try {
session = openSession();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
- qPos.add(uuid);
+ queryPos.add(uuid);
}
- qPos.add(companyId);
+ queryPos.add(companyId);
- if (!pagination) {
- list = (List)QueryUtil.list(q, getDialect(),
- start, end, false);
-
- Collections.sort(list);
-
- list = Collections.unmodifiableList(list);
- }
- else {
- list = (List)QueryUtil.list(q, getDialect(),
- start, end);
- }
+ list = (List)QueryUtil.list(
+ query, getDialect(), start, end);
cacheResult(list);
- finderCache.putResult(finderPath, finderArgs, list);
+ if (useFinderCache) {
+ finderCache.putResult(finderPath, finderArgs, list);
+ }
}
- catch (Exception e) {
- finderCache.removeResult(finderPath, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -855,29 +827,31 @@ else if (uuid.equals("")) {
* @throws NoSuchSecretKeyException if a matching secret key could not be found
*/
@Override
- public SecretKey findByUuid_C_First(String uuid, long companyId,
- OrderByComparator orderByComparator)
+ public SecretKey findByUuid_C_First(
+ String uuid, long companyId,
+ OrderByComparator orderByComparator)
throws NoSuchSecretKeyException {
- SecretKey secretKey = fetchByUuid_C_First(uuid, companyId,
- orderByComparator);
+
+ SecretKey secretKey = fetchByUuid_C_First(
+ uuid, companyId, orderByComparator);
if (secretKey != null) {
return secretKey;
}
- StringBundler msg = new StringBundler(6);
+ StringBundler sb = new StringBundler(6);
- msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+ sb.append(_NO_SUCH_ENTITY_WITH_KEY);
- msg.append("uuid=");
- msg.append(uuid);
+ sb.append("uuid=");
+ sb.append(uuid);
- msg.append(", companyId=");
- msg.append(companyId);
+ sb.append(", companyId=");
+ sb.append(companyId);
- msg.append("}");
+ sb.append("}");
- throw new NoSuchSecretKeyException(msg.toString());
+ throw new NoSuchSecretKeyException(sb.toString());
}
/**
@@ -889,10 +863,12 @@ public SecretKey findByUuid_C_First(String uuid, long companyId,
* @return the first matching secret key, or null if a matching secret key could not be found
*/
@Override
- public SecretKey fetchByUuid_C_First(String uuid, long companyId,
+ public SecretKey fetchByUuid_C_First(
+ String uuid, long companyId,
OrderByComparator orderByComparator) {
- List list = findByUuid_C(uuid, companyId, 0, 1,
- orderByComparator);
+
+ List list = findByUuid_C(
+ uuid, companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
@@ -911,29 +887,31 @@ public SecretKey fetchByUuid_C_First(String uuid, long companyId,
* @throws NoSuchSecretKeyException if a matching secret key could not be found
*/
@Override
- public SecretKey findByUuid_C_Last(String uuid, long companyId,
- OrderByComparator orderByComparator)
+ public SecretKey findByUuid_C_Last(
+ String uuid, long companyId,
+ OrderByComparator orderByComparator)
throws NoSuchSecretKeyException {
- SecretKey secretKey = fetchByUuid_C_Last(uuid, companyId,
- orderByComparator);
+
+ SecretKey secretKey = fetchByUuid_C_Last(
+ uuid, companyId, orderByComparator);
if (secretKey != null) {
return secretKey;
}
- StringBundler msg = new StringBundler(6);
+ StringBundler sb = new StringBundler(6);
- msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+ sb.append(_NO_SUCH_ENTITY_WITH_KEY);
- msg.append("uuid=");
- msg.append(uuid);
+ sb.append("uuid=");
+ sb.append(uuid);
- msg.append(", companyId=");
- msg.append(companyId);
+ sb.append(", companyId=");
+ sb.append(companyId);
- msg.append("}");
+ sb.append("}");
- throw new NoSuchSecretKeyException(msg.toString());
+ throw new NoSuchSecretKeyException(sb.toString());
}
/**
@@ -945,16 +923,18 @@ public SecretKey findByUuid_C_Last(String uuid, long companyId,
* @return the last matching secret key, or null if a matching secret key could not be found
*/
@Override
- public SecretKey fetchByUuid_C_Last(String uuid, long companyId,
+ public SecretKey fetchByUuid_C_Last(
+ String uuid, long companyId,
OrderByComparator orderByComparator) {
+
int count = countByUuid_C(uuid, companyId);
if (count == 0) {
return null;
}
- List list = findByUuid_C(uuid, companyId, count - 1, count,
- orderByComparator);
+ List list = findByUuid_C(
+ uuid, companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
@@ -964,7 +944,7 @@ public SecretKey fetchByUuid_C_Last(String uuid, long companyId,
}
/**
- * Returns the secret keies before and after the current secret key in the ordered set where uuid = ? and companyId = ?.
+ * Returns the secret keys before and after the current secret key in the ordered set where uuid = ? and companyId = ?.
*
* @param secretKeyId the primary key of the current secret key
* @param uuid the uuid
@@ -974,9 +954,13 @@ public SecretKey fetchByUuid_C_Last(String uuid, long companyId,
* @throws NoSuchSecretKeyException if a secret key with the primary key could not be found
*/
@Override
- public SecretKey[] findByUuid_C_PrevAndNext(long secretKeyId, String uuid,
- long companyId, OrderByComparator orderByComparator)
+ public SecretKey[] findByUuid_C_PrevAndNext(
+ long secretKeyId, String uuid, long companyId,
+ OrderByComparator orderByComparator)
throws NoSuchSecretKeyException {
+
+ uuid = Objects.toString(uuid, "");
+
SecretKey secretKey = findByPrimaryKey(secretKeyId);
Session session = null;
@@ -986,139 +970,138 @@ public SecretKey[] findByUuid_C_PrevAndNext(long secretKeyId, String uuid,
SecretKey[] array = new SecretKeyImpl[3];
- array[0] = getByUuid_C_PrevAndNext(session, secretKey, uuid,
- companyId, orderByComparator, true);
+ array[0] = getByUuid_C_PrevAndNext(
+ session, secretKey, uuid, companyId, orderByComparator, true);
array[1] = secretKey;
- array[2] = getByUuid_C_PrevAndNext(session, secretKey, uuid,
- companyId, orderByComparator, false);
+ array[2] = getByUuid_C_PrevAndNext(
+ session, secretKey, uuid, companyId, orderByComparator, false);
return array;
}
- catch (Exception e) {
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
}
}
- protected SecretKey getByUuid_C_PrevAndNext(Session session,
- SecretKey secretKey, String uuid, long companyId,
+ protected SecretKey getByUuid_C_PrevAndNext(
+ Session session, SecretKey secretKey, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
- StringBundler query = null;
+
+ StringBundler sb = null;
if (orderByComparator != null) {
- query = new StringBundler(5 +
- (orderByComparator.getOrderByConditionFields().length * 3) +
+ sb = new StringBundler(
+ 5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
- query = new StringBundler(4);
+ sb = new StringBundler(4);
}
- query.append(_SQL_SELECT_SECRETKEY_WHERE);
+ sb.append(_SQL_SELECT_SECRETKEY_WHERE);
boolean bindUuid = false;
- if (uuid == null) {
- query.append(_FINDER_COLUMN_UUID_C_UUID_1);
- }
- else if (uuid.equals("")) {
- query.append(_FINDER_COLUMN_UUID_C_UUID_3);
+ if (uuid.isEmpty()) {
+ sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
- query.append(_FINDER_COLUMN_UUID_C_UUID_2);
+ sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
- query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
+ sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
- String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
+ String[] orderByConditionFields =
+ orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
- query.append(WHERE_AND);
+ sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
- query.append(_ORDER_BY_ENTITY_ALIAS);
- query.append(orderByConditionFields[i]);
+ sb.append(_ORDER_BY_ENTITY_ALIAS);
+ sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
- query.append(WHERE_GREATER_THAN_HAS_NEXT);
+ sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
- query.append(WHERE_LESSER_THAN_HAS_NEXT);
+ sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
- query.append(WHERE_GREATER_THAN);
+ sb.append(WHERE_GREATER_THAN);
}
else {
- query.append(WHERE_LESSER_THAN);
+ sb.append(WHERE_LESSER_THAN);
}
}
}
- query.append(ORDER_BY_CLAUSE);
+ sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
- query.append(_ORDER_BY_ENTITY_ALIAS);
- query.append(orderByFields[i]);
+ sb.append(_ORDER_BY_ENTITY_ALIAS);
+ sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
- query.append(ORDER_BY_ASC_HAS_NEXT);
+ sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
- query.append(ORDER_BY_DESC_HAS_NEXT);
+ sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
- query.append(ORDER_BY_ASC);
+ sb.append(ORDER_BY_ASC);
}
else {
- query.append(ORDER_BY_DESC);
+ sb.append(ORDER_BY_DESC);
}
}
}
}
else {
- query.append(SecretKeyModelImpl.ORDER_BY_JPQL);
+ sb.append(SecretKeyModelImpl.ORDER_BY_JPQL);
}
- String sql = query.toString();
+ String sql = sb.toString();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- q.setFirstResult(0);
- q.setMaxResults(2);
+ query.setFirstResult(0);
+ query.setMaxResults(2);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
- qPos.add(uuid);
+ queryPos.add(uuid);
}
- qPos.add(companyId);
+ queryPos.add(companyId);
if (orderByComparator != null) {
- Object[] values = orderByComparator.getOrderByConditionValues(secretKey);
+ for (Object orderByConditionValue :
+ orderByComparator.getOrderByConditionValues(secretKey)) {
- for (Object value : values) {
- qPos.add(value);
+ queryPos.add(orderByConditionValue);
}
}
- List list = q.list();
+ List list = query.list();
if (list.size() == 2) {
return list.get(1);
@@ -1129,80 +1112,80 @@ else if (uuid.equals("")) {
}
/**
- * Removes all the secret keies where uuid = ? and companyId = ? from the database.
+ * Removes all the secret keys where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
- for (SecretKey secretKey : findByUuid_C(uuid, companyId,
- QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
+ for (SecretKey secretKey :
+ findByUuid_C(
+ uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
+ null)) {
+
remove(secretKey);
}
}
/**
- * Returns the number of secret keies where uuid = ? and companyId = ?.
+ * Returns the number of secret keys where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
- * @return the number of matching secret keies
+ * @return the number of matching secret keys
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
- FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
+ uuid = Objects.toString(uuid, "");
+
+ FinderPath finderPath = _finderPathCountByUuid_C;
- Object[] finderArgs = new Object[] { uuid, companyId };
+ Object[] finderArgs = new Object[] {uuid, companyId};
- Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
+ Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
- StringBundler query = new StringBundler(3);
+ StringBundler sb = new StringBundler(3);
- query.append(_SQL_COUNT_SECRETKEY_WHERE);
+ sb.append(_SQL_COUNT_SECRETKEY_WHERE);
boolean bindUuid = false;
- if (uuid == null) {
- query.append(_FINDER_COLUMN_UUID_C_UUID_1);
- }
- else if (uuid.equals("")) {
- query.append(_FINDER_COLUMN_UUID_C_UUID_3);
+ if (uuid.isEmpty()) {
+ sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
- query.append(_FINDER_COLUMN_UUID_C_UUID_2);
+ sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
- query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
+ sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
- String sql = query.toString();
+ String sql = sb.toString();
Session session = null;
try {
session = openSession();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
- qPos.add(uuid);
+ queryPos.add(uuid);
}
- qPos.add(companyId);
+ queryPos.add(companyId);
- count = (Long)q.uniqueResult();
+ count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
- catch (Exception e) {
- finderCache.removeResult(finderPath, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -1212,23 +1195,20 @@ else if (uuid.equals("")) {
return count.intValue();
}
- private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "secretKey.uuid IS NULL AND ";
- private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "secretKey.uuid = ? AND ";
- private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(secretKey.uuid IS NULL OR secretKey.uuid = '') AND ";
- private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "secretKey.companyId = ?";
- public static final FinderPath FINDER_PATH_FETCH_BY_C_U = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, SecretKeyImpl.class,
- FINDER_CLASS_NAME_ENTITY, "fetchByC_U",
- new String[] { Long.class.getName(), Long.class.getName() },
- SecretKeyModelImpl.COMPANYID_COLUMN_BITMASK |
- SecretKeyModelImpl.USERID_COLUMN_BITMASK);
- public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyModelImpl.FINDER_CACHE_ENABLED, Long.class,
- FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
- new String[] { Long.class.getName(), Long.class.getName() });
+ private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
+ "secretKey.uuid = ? AND ";
+
+ private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
+ "(secretKey.uuid IS NULL OR secretKey.uuid = '') AND ";
+
+ private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
+ "secretKey.companyId = ?";
+
+ private FinderPath _finderPathFetchByC_U;
+ private FinderPath _finderPathCountByC_U;
/**
- * Returns the secret key where companyId = ? and userId = ? or throws a {@link NoSuchSecretKeyException} if it could not be found.
+ * Returns the secret key where companyId = ? and userId = ? or throws a NoSuchSecretKeyException if it could not be found.
*
* @param companyId the company ID
* @param userId the user ID
@@ -1238,26 +1218,27 @@ else if (uuid.equals("")) {
@Override
public SecretKey findByC_U(long companyId, long userId)
throws NoSuchSecretKeyException {
+
SecretKey secretKey = fetchByC_U(companyId, userId);
if (secretKey == null) {
- StringBundler msg = new StringBundler(6);
+ StringBundler sb = new StringBundler(6);
- msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+ sb.append(_NO_SUCH_ENTITY_WITH_KEY);
- msg.append("companyId=");
- msg.append(companyId);
+ sb.append("companyId=");
+ sb.append(companyId);
- msg.append(", userId=");
- msg.append(userId);
+ sb.append(", userId=");
+ sb.append(userId);
- msg.append("}");
+ sb.append("}");
if (_log.isDebugEnabled()) {
- _log.debug(msg.toString());
+ _log.debug(sb.toString());
}
- throw new NoSuchSecretKeyException(msg.toString());
+ throw new NoSuchSecretKeyException(sb.toString());
}
return secretKey;
@@ -1280,59 +1261,66 @@ public SecretKey fetchByC_U(long companyId, long userId) {
*
* @param companyId the company ID
* @param userId the user ID
- * @param retrieveFromCache whether to retrieve from the finder cache
+ * @param useFinderCache whether to use the finder cache
* @return the matching secret key, or null if a matching secret key could not be found
*/
@Override
- public SecretKey fetchByC_U(long companyId, long userId,
- boolean retrieveFromCache) {
- Object[] finderArgs = new Object[] { companyId, userId };
+ public SecretKey fetchByC_U(
+ long companyId, long userId, boolean useFinderCache) {
+
+ Object[] finderArgs = null;
+
+ if (useFinderCache) {
+ finderArgs = new Object[] {companyId, userId};
+ }
Object result = null;
- if (retrieveFromCache) {
- result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_U,
- finderArgs, this);
+ if (useFinderCache) {
+ result = finderCache.getResult(_finderPathFetchByC_U, finderArgs);
}
if (result instanceof SecretKey) {
SecretKey secretKey = (SecretKey)result;
if ((companyId != secretKey.getCompanyId()) ||
- (userId != secretKey.getUserId())) {
+ (userId != secretKey.getUserId())) {
+
result = null;
}
}
if (result == null) {
- StringBundler query = new StringBundler(4);
+ StringBundler sb = new StringBundler(4);
- query.append(_SQL_SELECT_SECRETKEY_WHERE);
+ sb.append(_SQL_SELECT_SECRETKEY_WHERE);
- query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
+ sb.append(_FINDER_COLUMN_C_U_COMPANYID_2);
- query.append(_FINDER_COLUMN_C_U_USERID_2);
+ sb.append(_FINDER_COLUMN_C_U_USERID_2);
- String sql = query.toString();
+ String sql = sb.toString();
Session session = null;
try {
session = openSession();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
- qPos.add(companyId);
+ queryPos.add(companyId);
- qPos.add(userId);
+ queryPos.add(userId);
- List list = q.list();
+ List list = query.list();
if (list.isEmpty()) {
- finderCache.putResult(FINDER_PATH_FETCH_BY_C_U, finderArgs,
- list);
+ if (useFinderCache) {
+ finderCache.putResult(
+ _finderPathFetchByC_U, finderArgs, list);
+ }
}
else {
SecretKey secretKey = list.get(0);
@@ -1340,18 +1328,10 @@ public SecretKey fetchByC_U(long companyId, long userId,
result = secretKey;
cacheResult(secretKey);
-
- if ((secretKey.getCompanyId() != companyId) ||
- (secretKey.getUserId() != userId)) {
- finderCache.putResult(FINDER_PATH_FETCH_BY_C_U,
- finderArgs, secretKey);
- }
}
}
- catch (Exception e) {
- finderCache.removeResult(FINDER_PATH_FETCH_BY_C_U, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -1376,58 +1356,57 @@ public SecretKey fetchByC_U(long companyId, long userId,
@Override
public SecretKey removeByC_U(long companyId, long userId)
throws NoSuchSecretKeyException {
+
SecretKey secretKey = findByC_U(companyId, userId);
return remove(secretKey);
}
/**
- * Returns the number of secret keies where companyId = ? and userId = ?.
+ * Returns the number of secret keys where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
- * @return the number of matching secret keies
+ * @return the number of matching secret keys
*/
@Override
public int countByC_U(long companyId, long userId) {
- FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
+ FinderPath finderPath = _finderPathCountByC_U;
- Object[] finderArgs = new Object[] { companyId, userId };
+ Object[] finderArgs = new Object[] {companyId, userId};
- Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
+ Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
- StringBundler query = new StringBundler(3);
+ StringBundler sb = new StringBundler(3);
- query.append(_SQL_COUNT_SECRETKEY_WHERE);
+ sb.append(_SQL_COUNT_SECRETKEY_WHERE);
- query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
+ sb.append(_FINDER_COLUMN_C_U_COMPANYID_2);
- query.append(_FINDER_COLUMN_C_U_USERID_2);
+ sb.append(_FINDER_COLUMN_C_U_USERID_2);
- String sql = query.toString();
+ String sql = sb.toString();
Session session = null;
try {
session = openSession();
- Query q = session.createQuery(sql);
+ Query query = session.createQuery(sql);
- QueryPos qPos = QueryPos.getInstance(q);
+ QueryPos queryPos = QueryPos.getInstance(query);
- qPos.add(companyId);
+ queryPos.add(companyId);
- qPos.add(userId);
+ queryPos.add(userId);
- count = (Long)q.uniqueResult();
+ count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
- catch (Exception e) {
- finderCache.removeResult(finderPath, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -1437,29 +1416,25 @@ public int countByC_U(long companyId, long userId) {
return count.intValue();
}
- private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "secretKey.companyId = ? AND ";
- private static final String _FINDER_COLUMN_C_U_USERID_2 = "secretKey.userId = ?";
+ private static final String _FINDER_COLUMN_C_U_COMPANYID_2 =
+ "secretKey.companyId = ? AND ";
+
+ private static final String _FINDER_COLUMN_C_U_USERID_2 =
+ "secretKey.userId = ?";
public SecretKeyPersistenceImpl() {
- setModelClass(SecretKey.class);
+ Map dbColumnNames = new HashMap();
- try {
- Field field = BasePersistenceImpl.class.getDeclaredField(
- "_dbColumnNames");
+ dbColumnNames.put("uuid", "uuid_");
- field.setAccessible(true);
+ setDBColumnNames(dbColumnNames);
- Map dbColumnNames = new HashMap();
+ setModelClass(SecretKey.class);
- dbColumnNames.put("uuid", "uuid_");
+ setModelImplClass(SecretKeyImpl.class);
+ setModelPKClass(long.class);
- field.set(this, dbColumnNames);
- }
- catch (Exception e) {
- if (_log.isDebugEnabled()) {
- _log.debug(e, e);
- }
- }
+ setTable(SecretKeyTable.INSTANCE);
}
/**
@@ -1469,116 +1444,82 @@ public SecretKeyPersistenceImpl() {
*/
@Override
public void cacheResult(SecretKey secretKey) {
- entityCache.putResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
+ entityCache.putResult(
SecretKeyImpl.class, secretKey.getPrimaryKey(), secretKey);
- finderCache.putResult(FINDER_PATH_FETCH_BY_C_U,
- new Object[] { secretKey.getCompanyId(), secretKey.getUserId() },
+ finderCache.putResult(
+ _finderPathFetchByC_U,
+ new Object[] {secretKey.getCompanyId(), secretKey.getUserId()},
secretKey);
-
- secretKey.resetOriginalValues();
}
/**
- * Caches the secret keies in the entity cache if it is enabled.
+ * Caches the secret keys in the entity cache if it is enabled.
*
- * @param secretKeies the secret keies
+ * @param secretKeys the secret keys
*/
@Override
- public void cacheResult(List secretKeies) {
- for (SecretKey secretKey : secretKeies) {
- if (entityCache.getResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, secretKey.getPrimaryKey()) == null) {
+ public void cacheResult(List secretKeys) {
+ for (SecretKey secretKey : secretKeys) {
+ if (entityCache.getResult(
+ SecretKeyImpl.class, secretKey.getPrimaryKey()) == null) {
+
cacheResult(secretKey);
}
- else {
- secretKey.resetOriginalValues();
- }
}
}
/**
- * Clears the cache for all secret keies.
+ * Clears the cache for all secret keys.
*
*
- * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
+ * The EntityCache and FinderCache are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(SecretKeyImpl.class);
- finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ finderCache.clearCache(SecretKeyImpl.class);
}
/**
* Clears the cache for the secret key.
*
*
- * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
+ * The EntityCache and FinderCache are both cleared by this method.
*
*/
@Override
public void clearCache(SecretKey secretKey) {
- entityCache.removeResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, secretKey.getPrimaryKey());
-
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
-
- clearUniqueFindersCache((SecretKeyModelImpl)secretKey, true);
+ entityCache.removeResult(SecretKeyImpl.class, secretKey);
}
@Override
- public void clearCache(List secretKeies) {
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ public void clearCache(List secretKeys) {
+ for (SecretKey secretKey : secretKeys) {
+ entityCache.removeResult(SecretKeyImpl.class, secretKey);
+ }
+ }
- for (SecretKey secretKey : secretKeies) {
- entityCache.removeResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, secretKey.getPrimaryKey());
+ @Override
+ public void clearCache(Set primaryKeys) {
+ finderCache.clearCache(SecretKeyImpl.class);
- clearUniqueFindersCache((SecretKeyModelImpl)secretKey, true);
+ for (Serializable primaryKey : primaryKeys) {
+ entityCache.removeResult(SecretKeyImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(
SecretKeyModelImpl secretKeyModelImpl) {
- Object[] args = new Object[] {
- secretKeyModelImpl.getCompanyId(),
- secretKeyModelImpl.getUserId()
- };
-
- finderCache.putResult(FINDER_PATH_COUNT_BY_C_U, args, Long.valueOf(1),
- false);
- finderCache.putResult(FINDER_PATH_FETCH_BY_C_U, args,
- secretKeyModelImpl, false);
- }
-
- protected void clearUniqueFindersCache(
- SecretKeyModelImpl secretKeyModelImpl, boolean clearCurrent) {
- if (clearCurrent) {
- Object[] args = new Object[] {
- secretKeyModelImpl.getCompanyId(),
- secretKeyModelImpl.getUserId()
- };
- finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
- finderCache.removeResult(FINDER_PATH_FETCH_BY_C_U, args);
- }
-
- if ((secretKeyModelImpl.getColumnBitmask() &
- FINDER_PATH_FETCH_BY_C_U.getColumnBitmask()) != 0) {
- Object[] args = new Object[] {
- secretKeyModelImpl.getOriginalCompanyId(),
- secretKeyModelImpl.getOriginalUserId()
- };
+ Object[] args = new Object[] {
+ secretKeyModelImpl.getCompanyId(), secretKeyModelImpl.getUserId()
+ };
- finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
- finderCache.removeResult(FINDER_PATH_FETCH_BY_C_U, args);
- }
+ finderCache.putResult(_finderPathCountByC_U, args, Long.valueOf(1));
+ finderCache.putResult(_finderPathFetchByC_U, args, secretKeyModelImpl);
}
/**
@@ -1598,7 +1539,7 @@ public SecretKey create(long secretKeyId) {
secretKey.setUuid(uuid);
- secretKey.setCompanyId(companyProvider.getCompanyId());
+ secretKey.setCompanyId(CompanyThreadLocal.getCompanyId());
return secretKey;
}
@@ -1625,30 +1566,31 @@ public SecretKey remove(long secretKeyId) throws NoSuchSecretKeyException {
@Override
public SecretKey remove(Serializable primaryKey)
throws NoSuchSecretKeyException {
+
Session session = null;
try {
session = openSession();
- SecretKey secretKey = (SecretKey)session.get(SecretKeyImpl.class,
- primaryKey);
+ SecretKey secretKey = (SecretKey)session.get(
+ SecretKeyImpl.class, primaryKey);
if (secretKey == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
- throw new NoSuchSecretKeyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
- primaryKey);
+ throw new NoSuchSecretKeyException(
+ _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(secretKey);
}
- catch (NoSuchSecretKeyException nsee) {
- throw nsee;
+ catch (NoSuchSecretKeyException noSuchEntityException) {
+ throw noSuchEntityException;
}
- catch (Exception e) {
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -1657,24 +1599,22 @@ public SecretKey remove(Serializable primaryKey)
@Override
protected SecretKey removeImpl(SecretKey secretKey) {
- secretKey = toUnwrappedModel(secretKey);
-
Session session = null;
try {
session = openSession();
if (!session.contains(secretKey)) {
- secretKey = (SecretKey)session.get(SecretKeyImpl.class,
- secretKey.getPrimaryKeyObj());
+ secretKey = (SecretKey)session.get(
+ SecretKeyImpl.class, secretKey.getPrimaryKeyObj());
}
if (secretKey != null) {
session.delete(secretKey);
}
}
- catch (Exception e) {
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -1689,10 +1629,24 @@ protected SecretKey removeImpl(SecretKey secretKey) {
@Override
public SecretKey updateImpl(SecretKey secretKey) {
- secretKey = toUnwrappedModel(secretKey);
-
boolean isNew = secretKey.isNew();
+ if (!(secretKey instanceof SecretKeyModelImpl)) {
+ InvocationHandler invocationHandler = null;
+
+ if (ProxyUtil.isProxyClass(secretKey.getClass())) {
+ invocationHandler = ProxyUtil.getInvocationHandler(secretKey);
+
+ throw new IllegalArgumentException(
+ "Implement ModelWrapper in secretKey proxy " +
+ invocationHandler.getClass());
+ }
+
+ throw new IllegalArgumentException(
+ "Implement ModelWrapper in custom SecretKey implementation " +
+ secretKey.getClass());
+ }
+
SecretKeyModelImpl secretKeyModelImpl = (SecretKeyModelImpl)secretKey;
if (Validator.isNull(secretKey.getUuid())) {
@@ -1706,121 +1660,36 @@ public SecretKey updateImpl(SecretKey secretKey) {
try {
session = openSession();
- if (secretKey.isNew()) {
+ if (isNew) {
session.save(secretKey);
-
- secretKey.setNew(false);
}
else {
secretKey = (SecretKey)session.merge(secretKey);
}
}
- catch (Exception e) {
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
}
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
-
- if (!SecretKeyModelImpl.COLUMN_BITMASK_ENABLED) {
- finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
- }
- else
- if (isNew) {
- Object[] args = new Object[] { secretKeyModelImpl.getUuid() };
+ entityCache.putResult(
+ SecretKeyImpl.class, secretKeyModelImpl, false, true);
- finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
- args);
-
- args = new Object[] {
- secretKeyModelImpl.getUuid(),
- secretKeyModelImpl.getCompanyId()
- };
-
- finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
- args);
-
- finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL,
- FINDER_ARGS_EMPTY);
- }
-
- else {
- if ((secretKeyModelImpl.getColumnBitmask() &
- FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
- Object[] args = new Object[] {
- secretKeyModelImpl.getOriginalUuid()
- };
-
- finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
- args);
-
- args = new Object[] { secretKeyModelImpl.getUuid() };
-
- finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
- args);
- }
-
- if ((secretKeyModelImpl.getColumnBitmask() &
- FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
- Object[] args = new Object[] {
- secretKeyModelImpl.getOriginalUuid(),
- secretKeyModelImpl.getOriginalCompanyId()
- };
-
- finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
- args);
-
- args = new Object[] {
- secretKeyModelImpl.getUuid(),
- secretKeyModelImpl.getCompanyId()
- };
+ cacheUniqueFindersCache(secretKeyModelImpl);
- finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
- finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
- args);
- }
+ if (isNew) {
+ secretKey.setNew(false);
}
- entityCache.putResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, secretKey.getPrimaryKey(), secretKey, false);
-
- clearUniqueFindersCache(secretKeyModelImpl, false);
- cacheUniqueFindersCache(secretKeyModelImpl);
-
secretKey.resetOriginalValues();
return secretKey;
}
- protected SecretKey toUnwrappedModel(SecretKey secretKey) {
- if (secretKey instanceof SecretKeyImpl) {
- return secretKey;
- }
-
- SecretKeyImpl secretKeyImpl = new SecretKeyImpl();
-
- secretKeyImpl.setNew(secretKey.isNew());
- secretKeyImpl.setPrimaryKey(secretKey.getPrimaryKey());
-
- secretKeyImpl.setUuid(secretKey.getUuid());
- secretKeyImpl.setSecretKeyId(secretKey.getSecretKeyId());
- secretKeyImpl.setCompanyId(secretKey.getCompanyId());
- secretKeyImpl.setUserId(secretKey.getUserId());
- secretKeyImpl.setSecretKey(secretKey.getSecretKey());
-
- return secretKeyImpl;
- }
-
/**
- * Returns the secret key with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found.
+ * Returns the secret key with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException if it could not be found.
*
* @param primaryKey the primary key of the secret key
* @return the secret key
@@ -1829,6 +1698,7 @@ protected SecretKey toUnwrappedModel(SecretKey secretKey) {
@Override
public SecretKey findByPrimaryKey(Serializable primaryKey)
throws NoSuchSecretKeyException {
+
SecretKey secretKey = fetchByPrimaryKey(primaryKey);
if (secretKey == null) {
@@ -1836,15 +1706,15 @@ public SecretKey findByPrimaryKey(Serializable primaryKey)
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
- throw new NoSuchSecretKeyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
- primaryKey);
+ throw new NoSuchSecretKeyException(
+ _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return secretKey;
}
/**
- * Returns the secret key with the primary key or throws a {@link NoSuchSecretKeyException} if it could not be found.
+ * Returns the secret key with the primary key or throws a NoSuchSecretKeyException if it could not be found.
*
* @param secretKeyId the primary key of the secret key
* @return the secret key
@@ -1853,55 +1723,8 @@ public SecretKey findByPrimaryKey(Serializable primaryKey)
@Override
public SecretKey findByPrimaryKey(long secretKeyId)
throws NoSuchSecretKeyException {
- return findByPrimaryKey((Serializable)secretKeyId);
- }
- /**
- * Returns the secret key with the primary key or returns null if it could not be found.
- *
- * @param primaryKey the primary key of the secret key
- * @return the secret key, or null if a secret key with the primary key could not be found
- */
- @Override
- public SecretKey fetchByPrimaryKey(Serializable primaryKey) {
- Serializable serializable = entityCache.getResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, primaryKey);
-
- if (serializable == nullModel) {
- return null;
- }
-
- SecretKey secretKey = (SecretKey)serializable;
-
- if (secretKey == null) {
- Session session = null;
-
- try {
- session = openSession();
-
- secretKey = (SecretKey)session.get(SecretKeyImpl.class,
- primaryKey);
-
- if (secretKey != null) {
- cacheResult(secretKey);
- }
- else {
- entityCache.putResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, primaryKey, nullModel);
- }
- }
- catch (Exception e) {
- entityCache.removeResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, primaryKey);
-
- throw processException(e);
- }
- finally {
- closeSession(session);
- }
- }
-
- return secretKey;
+ return findByPrimaryKey((Serializable)secretKeyId);
}
/**
@@ -1915,104 +1738,10 @@ public SecretKey fetchByPrimaryKey(long secretKeyId) {
return fetchByPrimaryKey((Serializable)secretKeyId);
}
- @Override
- public Map fetchByPrimaryKeys(
- Set primaryKeys) {
- if (primaryKeys.isEmpty()) {
- return Collections.emptyMap();
- }
-
- Map map = new HashMap();
-
- if (primaryKeys.size() == 1) {
- Iterator iterator = primaryKeys.iterator();
-
- Serializable primaryKey = iterator.next();
-
- SecretKey secretKey = fetchByPrimaryKey(primaryKey);
-
- if (secretKey != null) {
- map.put(primaryKey, secretKey);
- }
-
- return map;
- }
-
- Set uncachedPrimaryKeys = null;
-
- for (Serializable primaryKey : primaryKeys) {
- Serializable serializable = entityCache.getResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, primaryKey);
-
- if (serializable != nullModel) {
- if (serializable == null) {
- if (uncachedPrimaryKeys == null) {
- uncachedPrimaryKeys = new HashSet();
- }
-
- uncachedPrimaryKeys.add(primaryKey);
- }
- else {
- map.put(primaryKey, (SecretKey)serializable);
- }
- }
- }
-
- if (uncachedPrimaryKeys == null) {
- return map;
- }
-
- StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
- 1);
-
- query.append(_SQL_SELECT_SECRETKEY_WHERE_PKS_IN);
-
- for (Serializable primaryKey : uncachedPrimaryKeys) {
- query.append((long)primaryKey);
-
- query.append(",");
- }
-
- query.setIndex(query.index() - 1);
-
- query.append(")");
-
- String sql = query.toString();
-
- Session session = null;
-
- try {
- session = openSession();
-
- Query q = session.createQuery(sql);
-
- for (SecretKey secretKey : (List)q.list()) {
- map.put(secretKey.getPrimaryKeyObj(), secretKey);
-
- cacheResult(secretKey);
-
- uncachedPrimaryKeys.remove(secretKey.getPrimaryKeyObj());
- }
-
- for (Serializable primaryKey : uncachedPrimaryKeys) {
- entityCache.putResult(SecretKeyModelImpl.ENTITY_CACHE_ENABLED,
- SecretKeyImpl.class, primaryKey, nullModel);
- }
- }
- catch (Exception e) {
- throw processException(e);
- }
- finally {
- closeSession(session);
- }
-
- return map;
- }
-
/**
- * Returns all the secret keies.
+ * Returns all the secret keys.
*
- * @return the secret keies
+ * @return the secret keys
*/
@Override
public List findAll() {
@@ -2020,15 +1749,15 @@ public List findAll() {
}
/**
- * Returns a range of all the secret keies.
+ * Returns a range of all the secret keys.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
- * @return the range of secret keies
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
+ * @return the range of secret keys
*/
@Override
public List findAll(int start, int end) {
@@ -2036,83 +1765,84 @@ public List findAll(int start, int end) {
}
/**
- * Returns an ordered range of all the secret keies.
+ * Returns an ordered range of all the secret keys.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
- * @return the ordered range of secret keies
+ * @return the ordered range of secret keys
*/
@Override
- public List findAll(int start, int end,
- OrderByComparator orderByComparator) {
+ public List findAll(
+ int start, int end, OrderByComparator orderByComparator) {
+
return findAll(start, end, orderByComparator, true);
}
/**
- * Returns an ordered range of all the secret keies.
+ * Returns an ordered range of all the secret keys.
*
*
- * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SecretKeyModelImpl}. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
+ * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from SecretKeyModelImpl.
*
*
- * @param start the lower bound of the range of secret keies
- * @param end the upper bound of the range of secret keies (not inclusive)
+ * @param start the lower bound of the range of secret keys
+ * @param end the upper bound of the range of secret keys (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
- * @param retrieveFromCache whether to retrieve from the finder cache
- * @return the ordered range of secret keies
+ * @param useFinderCache whether to use the finder cache
+ * @return the ordered range of secret keys
*/
@Override
- public List findAll(int start, int end,
- OrderByComparator orderByComparator,
- boolean retrieveFromCache) {
- boolean pagination = true;
+ public List findAll(
+ int start, int end, OrderByComparator orderByComparator,
+ boolean useFinderCache) {
+
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
- (orderByComparator == null)) {
- pagination = false;
- finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
- finderArgs = FINDER_ARGS_EMPTY;
+ (orderByComparator == null)) {
+
+ if (useFinderCache) {
+ finderPath = _finderPathWithoutPaginationFindAll;
+ finderArgs = FINDER_ARGS_EMPTY;
+ }
}
- else {
- finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
- finderArgs = new Object[] { start, end, orderByComparator };
+ else if (useFinderCache) {
+ finderPath = _finderPathWithPaginationFindAll;
+ finderArgs = new Object[] {start, end, orderByComparator};
}
List list = null;
- if (retrieveFromCache) {
- list = (List)finderCache.getResult(finderPath,
- finderArgs, this);
+ if (useFinderCache) {
+ list = (List)finderCache.getResult(
+ finderPath, finderArgs);
}
if (list == null) {
- StringBundler query = null;
+ StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
- query = new StringBundler(2 +
- (orderByComparator.getOrderByFields().length * 2));
+ sb = new StringBundler(
+ 2 + (orderByComparator.getOrderByFields().length * 2));
- query.append(_SQL_SELECT_SECRETKEY);
+ sb.append(_SQL_SELECT_SECRETKEY);
- appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
- orderByComparator);
+ appendOrderByComparator(
+ sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
- sql = query.toString();
+ sql = sb.toString();
}
else {
sql = _SQL_SELECT_SECRETKEY;
- if (pagination) {
- sql = sql.concat(SecretKeyModelImpl.ORDER_BY_JPQL);
- }
+ sql = sql.concat(SecretKeyModelImpl.ORDER_BY_JPQL);
}
Session session = null;
@@ -2120,29 +1850,19 @@ public List findAll(int start, int end,
try {
session = openSession();
- Query q = session.createQuery(sql);
-
- if (!pagination) {
- list = (List)QueryUtil.list(q, getDialect(),
- start, end, false);
+ Query query = session.createQuery(sql);
- Collections.sort(list);
-
- list = Collections.unmodifiableList(list);
- }
- else {
- list = (List)QueryUtil.list(q, getDialect(),
- start, end);
- }
+ list = (List)QueryUtil.list(
+ query, getDialect(), start, end);
cacheResult(list);
- finderCache.putResult(finderPath, finderArgs, list);
+ if (useFinderCache) {
+ finderCache.putResult(finderPath, finderArgs, list);
+ }
}
- catch (Exception e) {
- finderCache.removeResult(finderPath, finderArgs);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -2153,7 +1873,7 @@ public List findAll(int start, int end,
}
/**
- * Removes all the secret keies from the database.
+ * Removes all the secret keys from the database.
*
*/
@Override
@@ -2164,14 +1884,14 @@ public void removeAll() {
}
/**
- * Returns the number of secret keies.
+ * Returns the number of secret keys.
*
- * @return the number of secret keies
+ * @return the number of secret keys
*/
@Override
public int countAll() {
- Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
- FINDER_ARGS_EMPTY, this);
+ Long count = (Long)finderCache.getResult(
+ _finderPathCountAll, FINDER_ARGS_EMPTY);
if (count == null) {
Session session = null;
@@ -2179,18 +1899,15 @@ public int countAll() {
try {
session = openSession();
- Query q = session.createQuery(_SQL_COUNT_SECRETKEY);
+ Query query = session.createQuery(_SQL_COUNT_SECRETKEY);
- count = (Long)q.uniqueResult();
+ count = (Long)query.uniqueResult();
- finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
- count);
+ finderCache.putResult(
+ _finderPathCountAll, FINDER_ARGS_EMPTY, count);
}
- catch (Exception e) {
- finderCache.removeResult(FINDER_PATH_COUNT_ALL,
- FINDER_ARGS_EMPTY);
-
- throw processException(e);
+ catch (Exception exception) {
+ throw processException(exception);
}
finally {
closeSession(session);
@@ -2205,6 +1922,21 @@ public Set getBadColumnNames() {
return _badColumnNames;
}
+ @Override
+ protected EntityCache getEntityCache() {
+ return entityCache;
+ }
+
+ @Override
+ protected String getPKDBName() {
+ return "secretKeyId";
+ }
+
+ @Override
+ protected String getSelectSQL() {
+ return _SQL_SELECT_SECRETKEY;
+ }
+
@Override
protected Map getTableColumnsMap() {
return SecretKeyModelImpl.TABLE_COLUMNS_MAP;
@@ -2213,32 +1945,233 @@ protected Map getTableColumnsMap() {
/**
* Initializes the secret key persistence.
*/
- public void afterPropertiesSet() {
+ @Activate
+ public void activate(BundleContext bundleContext) {
+ _bundleContext = bundleContext;
+
+ _argumentsResolverServiceRegistration = _bundleContext.registerService(
+ ArgumentsResolver.class, new SecretKeyModelArgumentsResolver(),
+ new HashMapDictionary<>());
+
+ _finderPathWithPaginationFindAll = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0],
+ new String[0], true);
+
+ _finderPathWithoutPaginationFindAll = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0],
+ new String[0], true);
+
+ _finderPathCountAll = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
+ new String[0], new String[0], false);
+
+ _finderPathWithPaginationFindByUuid = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
+ new String[] {
+ String.class.getName(), Integer.class.getName(),
+ Integer.class.getName(), OrderByComparator.class.getName()
+ },
+ new String[] {"uuid_"}, true);
+
+ _finderPathWithoutPaginationFindByUuid = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
+ new String[] {String.class.getName()}, new String[] {"uuid_"},
+ true);
+
+ _finderPathCountByUuid = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
+ new String[] {String.class.getName()}, new String[] {"uuid_"},
+ false);
+
+ _finderPathWithPaginationFindByUuid_C = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
+ new String[] {
+ String.class.getName(), Long.class.getName(),
+ Integer.class.getName(), Integer.class.getName(),
+ OrderByComparator.class.getName()
+ },
+ new String[] {"uuid_", "companyId"}, true);
+
+ _finderPathWithoutPaginationFindByUuid_C = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
+ new String[] {String.class.getName(), Long.class.getName()},
+ new String[] {"uuid_", "companyId"}, true);
+
+ _finderPathCountByUuid_C = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
+ new String[] {String.class.getName(), Long.class.getName()},
+ new String[] {"uuid_", "companyId"}, false);
+
+ _finderPathFetchByC_U = new FinderPath(
+ FINDER_CLASS_NAME_ENTITY, "fetchByC_U",
+ new String[] {Long.class.getName(), Long.class.getName()},
+ new String[] {"companyId", "userId"}, true);
+
+ _finderPathCountByC_U = new FinderPath(
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
+ new String[] {Long.class.getName(), Long.class.getName()},
+ new String[] {"companyId", "userId"}, false);
}
- public void destroy() {
+ @Deactivate
+ public void deactivate() {
entityCache.removeCache(SecretKeyImpl.class.getName());
- finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
- finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
- finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ _argumentsResolverServiceRegistration.unregister();
+ }
+
+ @Override
+ @Reference(
+ target = totpPersistenceConstants.SERVICE_CONFIGURATION_FILTER,
+ unbind = "-"
+ )
+ public void setConfiguration(Configuration configuration) {
+ }
+
+ @Override
+ @Reference(
+ target = totpPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
+ unbind = "-"
+ )
+ public void setDataSource(DataSource dataSource) {
+ super.setDataSource(dataSource);
}
- @ServiceReference(type = CompanyProviderWrapper.class)
- protected CompanyProvider companyProvider;
- @ServiceReference(type = EntityCache.class)
+ @Override
+ @Reference(
+ target = totpPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
+ unbind = "-"
+ )
+ public void setSessionFactory(SessionFactory sessionFactory) {
+ super.setSessionFactory(sessionFactory);
+ }
+
+ private BundleContext _bundleContext;
+
+ @Reference
protected EntityCache entityCache;
- @ServiceReference(type = FinderCache.class)
+
+ @Reference
protected FinderCache finderCache;
- private static final String _SQL_SELECT_SECRETKEY = "SELECT secretKey FROM SecretKey secretKey";
- private static final String _SQL_SELECT_SECRETKEY_WHERE_PKS_IN = "SELECT secretKey FROM SecretKey secretKey WHERE secretKeyId IN (";
- private static final String _SQL_SELECT_SECRETKEY_WHERE = "SELECT secretKey FROM SecretKey secretKey WHERE ";
- private static final String _SQL_COUNT_SECRETKEY = "SELECT COUNT(secretKey) FROM SecretKey secretKey";
- private static final String _SQL_COUNT_SECRETKEY_WHERE = "SELECT COUNT(secretKey) FROM SecretKey secretKey WHERE ";
+
+ private static final String _SQL_SELECT_SECRETKEY =
+ "SELECT secretKey FROM SecretKey secretKey";
+
+ private static final String _SQL_SELECT_SECRETKEY_WHERE =
+ "SELECT secretKey FROM SecretKey secretKey WHERE ";
+
+ private static final String _SQL_COUNT_SECRETKEY =
+ "SELECT COUNT(secretKey) FROM SecretKey secretKey";
+
+ private static final String _SQL_COUNT_SECRETKEY_WHERE =
+ "SELECT COUNT(secretKey) FROM SecretKey secretKey WHERE ";
+
private static final String _ORDER_BY_ENTITY_ALIAS = "secretKey.";
- private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SecretKey exists with the primary key ";
- private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SecretKey exists with the key {";
- private static final Log _log = LogFactoryUtil.getLog(SecretKeyPersistenceImpl.class);
- private static final Set _badColumnNames = SetUtil.fromArray(new String[] {
- "uuid"
- });
+
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
+ "No SecretKey exists with the primary key ";
+
+ private static final String _NO_SUCH_ENTITY_WITH_KEY =
+ "No SecretKey exists with the key {";
+
+ private static final Log _log = LogFactoryUtil.getLog(
+ SecretKeyPersistenceImpl.class);
+
+ private static final Set _badColumnNames = SetUtil.fromArray(
+ new String[] {"uuid"});
+
+ @Override
+ protected FinderCache getFinderCache() {
+ return finderCache;
+ }
+
+ private ServiceRegistration
+ _argumentsResolverServiceRegistration;
+
+ private static class SecretKeyModelArgumentsResolver
+ implements ArgumentsResolver {
+
+ @Override
+ public Object[] getArguments(
+ FinderPath finderPath, BaseModel> baseModel, boolean checkColumn,
+ boolean original) {
+
+ String[] columnNames = finderPath.getColumnNames();
+
+ if ((columnNames == null) || (columnNames.length == 0)) {
+ if (baseModel.isNew()) {
+ return FINDER_ARGS_EMPTY;
+ }
+
+ return null;
+ }
+
+ SecretKeyModelImpl secretKeyModelImpl =
+ (SecretKeyModelImpl)baseModel;
+
+ long columnBitmask = secretKeyModelImpl.getColumnBitmask();
+
+ if (!checkColumn || (columnBitmask == 0)) {
+ return _getValue(secretKeyModelImpl, columnNames, original);
+ }
+
+ Long finderPathColumnBitmask = _finderPathColumnBitmasksCache.get(
+ finderPath);
+
+ if (finderPathColumnBitmask == null) {
+ finderPathColumnBitmask = 0L;
+
+ for (String columnName : columnNames) {
+ finderPathColumnBitmask |=
+ secretKeyModelImpl.getColumnBitmask(columnName);
+ }
+
+ _finderPathColumnBitmasksCache.put(
+ finderPath, finderPathColumnBitmask);
+ }
+
+ if ((columnBitmask & finderPathColumnBitmask) != 0) {
+ return _getValue(secretKeyModelImpl, columnNames, original);
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getClassName() {
+ return SecretKeyImpl.class.getName();
+ }
+
+ @Override
+ public String getTableName() {
+ return SecretKeyTable.INSTANCE.getTableName();
+ }
+
+ private static Object[] _getValue(
+ SecretKeyModelImpl secretKeyModelImpl, String[] columnNames,
+ boolean original) {
+
+ Object[] arguments = new Object[columnNames.length];
+
+ for (int i = 0; i < arguments.length; i++) {
+ String columnName = columnNames[i];
+
+ if (original) {
+ arguments[i] = secretKeyModelImpl.getColumnOriginalValue(
+ columnName);
+ }
+ else {
+ arguments[i] = secretKeyModelImpl.getColumnValue(
+ columnName);
+ }
+ }
+
+ return arguments;
+ }
+
+ private static final Map
+ _finderPathColumnBitmasksCache = new ConcurrentHashMap<>();
+
+ }
+
}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/constants/totpPersistenceConstants.java b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/constants/totpPersistenceConstants.java
new file mode 100644
index 0000000..bec01ff
--- /dev/null
+++ b/modules/totp-2fa-key-service/src/main/java/com/mw/totp_2fa/key/service/persistence/impl/constants/totpPersistenceConstants.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.mw.totp_2fa.key.service.persistence.impl.constants;
+
+import com.liferay.petra.string.StringBundler;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * @author Brian Wing Shun Chan
+ * @generated
+ */
+@Component(immediate = true, service = {})
+public class totpPersistenceConstants {
+
+ public static final String BUNDLE_SYMBOLIC_NAME =
+ "com.mw.totp-2fa.key.service";
+
+ public static final String ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER =
+ "(origin.bundle.symbolic.name=" + BUNDLE_SYMBOLIC_NAME + ")";
+
+ public static final String SERVICE_CONFIGURATION_FILTER =
+ "(&" + ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER + "(name=service))";
+
+ @Activate
+ protected void activate(BundleContext bundleContext) {
+ Bundle bundle = bundleContext.getBundle();
+
+ if (!BUNDLE_SYMBOLIC_NAME.equals(bundle.getSymbolicName())) {
+ throw new IllegalStateException(
+ StringBundler.concat(
+ "Incorrect ", Constants.BUNDLE_SYMBOLICNAME, " for bundle ",
+ bundle.getSymbolicName()));
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/resources/META-INF/module-hbm.xml b/modules/totp-2fa-key-service/src/main/resources/META-INF/module-hbm.xml
index 1ebca5b..b168fbd 100644
--- a/modules/totp-2fa-key-service/src/main/resources/META-INF/module-hbm.xml
+++ b/modules/totp-2fa-key-service/src/main/resources/META-INF/module-hbm.xml
@@ -4,12 +4,12 @@
-
+
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/modules/totp-2fa-key-service/src/main/resources/service.properties b/modules/totp-2fa-key-service/src/main/resources/service.properties
index 6e716e0..f597a0c 100644
--- a/modules/totp-2fa-key-service/src/main/resources/service.properties
+++ b/modules/totp-2fa-key-service/src/main/resources/service.properties
@@ -6,12 +6,12 @@
# Specify where to get the overridden properties. Updates should not be made
# on this file but on the overridden version of this file.
#
- include-and-override=${base.path}/service-ext.properties
+ include-and-override=service-ext.properties
##
## Build
##
build.namespace=totp
- build.number=10
- build.date=1538263074342
\ No newline at end of file
+ build.number=13
+ build.date=1633810009670
\ No newline at end of file
diff --git a/modules/totp-2fa-login-auth/build.gradle b/modules/totp-2fa-login-auth/build.gradle
index 26bf907..de34056 100644
--- a/modules/totp-2fa-login-auth/build.gradle
+++ b/modules/totp-2fa-login-auth/build.gradle
@@ -1,11 +1,5 @@
dependencies {
- compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.6.0"
- compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
- compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
- compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype", version: "2.0.3"
- compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
- compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
- compileOnly group: "com.liferay", name: "com.liferay.login.web", version: "3.0.9"
+ compileOnly group: "com.liferay.portal", name: "release.portal.api"
compileOnly project(":modules:totp-2fa-service")
compileOnly project(":modules:totp-2fa-key-api")
diff --git a/modules/totp-2fa-login-auth/src/main/java/com/mw/totp_2fa/login/portlet/filter/LoginPortletFilter.java b/modules/totp-2fa-login-auth/src/main/java/com/mw/totp_2fa/login/portlet/filter/LoginPortletFilter.java
index a1a1a60..5ab0b1c 100644
--- a/modules/totp-2fa-login-auth/src/main/java/com/mw/totp_2fa/login/portlet/filter/LoginPortletFilter.java
+++ b/modules/totp-2fa-login-auth/src/main/java/com/mw/totp_2fa/login/portlet/filter/LoginPortletFilter.java
@@ -1,6 +1,6 @@
package com.mw.totp_2fa.login.portlet.filter;
-import com.liferay.login.web.internal.constants.LoginPortletKeys;
+import com.liferay.login.web.constants.LoginPortletKeys;
import com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
@@ -35,7 +35,7 @@
configurationPid = TOTP_2FAConfiguration.PID,
property = {
"javax.portlet.name=" + LoginPortletKeys.LOGIN,
- "javax.portlet.name=" + LoginPortletKeys.FAST_LOGIN
+ "javax.portlet.name=" + LoginPortletKeys.FAST_LOGIN,
},
service = PortletFilter.class)
public class LoginPortletFilter implements RenderFilter{
diff --git a/modules/totp-2fa-qrcode/bnd.bnd b/modules/totp-2fa-qrcode/bnd.bnd
index 354eba0..08c6c7e 100644
--- a/modules/totp-2fa-qrcode/bnd.bnd
+++ b/modules/totp-2fa-qrcode/bnd.bnd
@@ -10,7 +10,10 @@ Bundle-ClassPath:\
lib/java-jwt-3.4.0.jar,\
lib/jackson-annotations-2.9.7.jar,\
lib/jackson-core-2.9.7.jar,\
- lib/jackson-databind-2.9.7.jar
+ lib/jackson-databind-2.9.7.jar,\
+ lib/commons-codec-1.13.jar,\
+ lib/jsr-305-1.0.0.jar,\
+ lib/jsoup-1.14.3.jar
-includeresource:\
lib/javase-3.3.0.jar=javase-3.3.0.jar,\
lib/core-3.3.0.jar=core-3.3.0.jar,\
@@ -18,7 +21,10 @@ Bundle-ClassPath:\
lib/jai-imageio-core-1.4.0.jar=jai-imageio-core-1.4.0.jar,\
lib/java-jwt-3.4.0.jar=java-jwt-3.4.0.jar,\
lib/jackson-annotations-2.9.7.jar=jackson-annotations-2.9.7.jar,\
+ lib/commons-codec-1.13.jar=commons-codec-1.13.jar,\
lib/jackson-core-2.9.7.jar=jackson-core-2.9.7.jar,\
+ lib/jsr-305-1.0.0.jar=jsr-305-1.0.0.jar,\
+ lib/jsoup-1.14.3.jar=jsoup-1.14.3.jar,\
lib/jackson-databind-2.9.7.jar=jackson-databind-2.9.7.jar
Export-Package: \
com.mw.totp_2fa.qrcode.constants,\
diff --git a/modules/totp-2fa-qrcode/build.gradle b/modules/totp-2fa-qrcode/build.gradle
index 16b8298..888542b 100644
--- a/modules/totp-2fa-qrcode/build.gradle
+++ b/modules/totp-2fa-qrcode/build.gradle
@@ -1,12 +1,9 @@
dependencies {
- compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.6.0"
- compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
- compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
- compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype", version: "2.0.3"
- compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
- compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
- compileOnly group: "com.liferay", name: "com.liferay.users.admin.api", version: "3.0.0"
-
+ compileOnly group: "com.liferay.portal", name: "release.portal.api"
+ compile group: "commons-codec", name: "commons-codec", version: "1.13"
+ compile "org.jsoup:jsoup:1.14.3"
+ compile group: 'org.xbib', name: 'jsr-305', version: '1.0.0'
+
//Mail
compileOnly group: "javax.mail", name: "mail", version :"1.4"
diff --git a/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/MyAccountPortletFilter.java b/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/MyAccountPortletFilter.java
index 23b78d4..483122e 100644
--- a/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/MyAccountPortletFilter.java
+++ b/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/MyAccountPortletFilter.java
@@ -24,6 +24,9 @@
import javax.portlet.filter.PortletFilter;
import javax.portlet.filter.RenderResponseWrapper;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
@@ -86,25 +89,18 @@ public void doFilter(RenderRequest request, RenderResponse response, FilterChain
hasSecretKey = true;
}
- String fieldsetCloseTag = "";
-
- int index = text.lastIndexOf(fieldsetCloseTag);
-
- if (index >= 0) {
- String prefixText = text.substring(0, index);
- String postfixText = text.substring(index);
-
- String customText = getContent(false, tfaConfiguration.showSecretKeysOnAccountScreens(), qrCodeService, hasSecretKey, UsersAdminPortletKeys.MY_ACCOUNT, request, user, secretKeyObject);
-
- response.getWriter().write(prefixText + customText + postfixText);
- } else {
- response.getWriter().write(text);
- }
+ Document doc = Jsoup.parse(text);
+ Element form = doc.select("form").first();
+ form.append(getContent(true, tfaConfiguration.showSecretKeysOnAccountScreens(), qrCodeService, hasSecretKey, UsersAdminPortletKeys.USERS_ADMIN, request, user, secretKeyObject));
+
+ response.getWriter().write(doc.html());
}
@Activate
@Modified
protected void activate(Map properties) {
+ _log.info("activate!");
+
tfaConfiguration = ConfigurableUtil.createConfigurable(TOTP_2FAConfiguration.class, properties);
}
diff --git a/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/UsersAdminPortletFilter.java b/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/UsersAdminPortletFilter.java
index b42b2dc..a851be0 100644
--- a/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/UsersAdminPortletFilter.java
+++ b/modules/totp-2fa-qrcode/src/main/java/com/mw/totp_2fa/qrcode/usersAdmin/UsersAdminPortletFilter.java
@@ -23,6 +23,9 @@
import javax.portlet.filter.PortletFilter;
import javax.portlet.filter.RenderResponseWrapper;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
@@ -41,7 +44,7 @@
immediate = true,
configurationPid = TOTP_2FAConfiguration.PID,
property = {
- "javax.portlet.name=" + UsersAdminPortletKeys.USERS_ADMIN
+ "javax.portlet.name=" + UsersAdminPortletKeys.USERS_ADMIN
},
service = PortletFilter.class)
public class UsersAdminPortletFilter extends AbstractProfilePortletFilter {
@@ -84,25 +87,18 @@ public void doFilter(RenderRequest request, RenderResponse response, FilterChain
hasSecretKey = true;
}
- String fieldsetCloseTag = "";
-
- int index = text.lastIndexOf(fieldsetCloseTag);
-
- if (index >= 0) {
- String prefixText = text.substring(0, index);
- String postfixText = text.substring(index);
-
- String customText = getContent(true, tfaConfiguration.showSecretKeysOnAccountScreens(), qrCodeService, hasSecretKey, UsersAdminPortletKeys.USERS_ADMIN, request, user, secretKeyObject);
-
- response.getWriter().write(prefixText + customText.toString() + postfixText);
- } else {
- response.getWriter().write(text);
- }
+ Document doc = Jsoup.parse(text);
+ Element form = doc.select("form").first();
+ form.append(getContent(true, tfaConfiguration.showSecretKeysOnAccountScreens(), qrCodeService, hasSecretKey, UsersAdminPortletKeys.USERS_ADMIN, request, user, secretKeyObject));
+
+ response.getWriter().write(doc.html());
}
@Activate
@Modified
protected void activate(Map properties) {
+ _log.info("activate!");
+
tfaConfiguration = ConfigurableUtil.createConfigurable(TOTP_2FAConfiguration.class, properties);
}
diff --git a/modules/totp-2fa-service/bnd.bnd b/modules/totp-2fa-service/bnd.bnd
index be957d4..174b543 100644
--- a/modules/totp-2fa-service/bnd.bnd
+++ b/modules/totp-2fa-service/bnd.bnd
@@ -4,10 +4,12 @@ Bundle-Version: 1.0.0
Bundle-ClassPath:\
.,\
lib/java-otp-0.1.0.jar,\
- lib/two-factor-auth-1.0.jar
+ lib/two-factor-auth-1.0.jar,\
+ lib/commons-codec-1.13.jar
-includeresource:\
lib/java-otp-0.1.0.jar=java-otp-0.1.0.jar,\
- lib/two-factor-auth-1.0.jar=two-factor-auth-1.0.jar
+ lib/two-factor-auth-1.0.jar=two-factor-auth-1.0.jar,\
+ lib/commons-codec-1.13.jar=commons-codec-1.13.jar
Export-Package: \
com.mw.totp_2fa.config,\
com.mw.totp_2fa.api,\
diff --git a/modules/totp-2fa-service/build.gradle b/modules/totp-2fa-service/build.gradle
index 20010cd..36df0a3 100644
--- a/modules/totp-2fa-service/build.gradle
+++ b/modules/totp-2fa-service/build.gradle
@@ -1,12 +1,6 @@
dependencies {
- compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
- compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.6.0"
- compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
- compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version :"1.3.0"
+ compileOnly group: "com.liferay.portal", name: "release.portal.api"
compileOnly group: "commons-codec", name: "commons-codec", version: "1.9"
- compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
- compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype", version: "2.0.3"
- compileOnly group: "com.liferay", name: "com.liferay.configuration.admin.api", version: "1.0.1"
//TOTP 2FA Implementations
compile group: "com.eatthepath", name: "java-otp", version :"0.1.0"
diff --git a/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/config/TOTP_2FAConfiguration.java b/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/config/TOTP_2FAConfiguration.java
index 2aa54ab..4c40c29 100644
--- a/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/config/TOTP_2FAConfiguration.java
+++ b/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/config/TOTP_2FAConfiguration.java
@@ -7,7 +7,8 @@
import aQute.bnd.annotation.metatype.Meta.Type;
@ExtendedObjectClassDefinition(category = "totp_2fa", scope = ExtendedObjectClassDefinition.Scope.SYSTEM)
-@Meta.OCD(id = TOTP_2FAConfiguration.PID, localization = "content/TOTP_2FALanguage", name = "configuration.name.totp_2fa")
+//@Meta.OCD(id = TOTP_2FAConfiguration.PID, localization = "content/TOTP_2FALanguage", name = "configuration.name.totp_2fa")
+@Meta.OCD(id = TOTP_2FAConfiguration.PID, name = "configuration.name.totp_2fa")
public interface TOTP_2FAConfiguration {
public static final String ALGORITHM = "SHA1"; // Intentionally not externalized (yet).
diff --git a/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverrideDE.java b/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverrideDE.java
new file mode 100644
index 0000000..f2c24a4
--- /dev/null
+++ b/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverrideDE.java
@@ -0,0 +1,32 @@
+package com.mw.totp_2fa.lang;
+
+import com.liferay.portal.kernel.language.UTF8Control;
+
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * @author Michael Wall / siehe siehe https://help.liferay.com/hc/en-us/articles/360017886312-Overriding-Global-Language-Keys
+ */
+@Component(
+ immediate = true,
+ service = ResourceBundle.class,
+ property = { "language.id=de_DE" }
+)
+public class LanguageOverrideDE extends ResourceBundle {
+
+ @Override
+ protected Object handleGetObject(String key) {
+ return _resourceBundle.getObject(key);
+ }
+
+ @Override
+ public Enumeration getKeys() {
+ return _resourceBundle.getKeys();
+ }
+
+ private final ResourceBundle _resourceBundle = ResourceBundle.getBundle(
+ "content.Language_de", UTF8Control.INSTANCE);
+}
\ No newline at end of file
diff --git a/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverride.java b/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverrideEN.java
similarity index 62%
rename from modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverride.java
rename to modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverrideEN.java
index 1f27dd1..d053748 100644
--- a/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverride.java
+++ b/modules/totp-2fa-service/src/main/java/com/mw/totp_2fa/lang/LanguageOverrideEN.java
@@ -8,14 +8,14 @@
import org.osgi.service.component.annotations.Component;
/**
- * @author Michael Wall
+ * @author Michael Wall / siehe https://help.liferay.com/hc/en-us/articles/360017886312-Overriding-Global-Language-Keys
*/
@Component(
immediate = true,
- property = { "language.id=en_US" },
- service = ResourceBundle.class
+ service = ResourceBundle.class,
+ property = { "language.id=en_US" }
)
-public class LanguageOverride extends ResourceBundle {
+public class LanguageOverrideEN extends ResourceBundle {
@Override
protected Object handleGetObject(String key) {
@@ -28,5 +28,5 @@ public Enumeration getKeys() {
}
private final ResourceBundle _resourceBundle = ResourceBundle.getBundle(
- "content.TOTP_2FALanguage", UTF8Control.INSTANCE);
+ "content.Language", UTF8Control.INSTANCE);
}
\ No newline at end of file
diff --git a/modules/totp-2fa-service/src/main/resources/content/TOTP_2FALanguage.properties b/modules/totp-2fa-service/src/main/resources/content/Language.properties
similarity index 100%
rename from modules/totp-2fa-service/src/main/resources/content/TOTP_2FALanguage.properties
rename to modules/totp-2fa-service/src/main/resources/content/Language.properties
diff --git a/modules/totp-2fa-service/src/main/resources/content/Language_de.properties b/modules/totp-2fa-service/src/main/resources/content/Language_de.properties
new file mode 100644
index 0000000..5dcdbcb
--- /dev/null
+++ b/modules/totp-2fa-service/src/main/resources/content/Language_de.properties
@@ -0,0 +1,77 @@
+totp_2fa=TOTP 2FA
+category.totp_2fa=TOTP 2FA
+
+configuration.name.totp_2fa=TOTP 2FA
+
+configuration.loginTotp2faEnabled.name=Anmeldung TOTP 2FA aktiviert
+configuration.loginTotp2faEnabled.desc=Steuert, ob TOTP 2FA / Authentifikator-Code beim Anmelden erforderlich ist. Unabhängig von dieser Einstellung werden geheime Schlüssel generiert und QR-Code-URL-E-Mails gesendet.
+
+configuration.applicationName.name=Anwendungsname
+configuration.applicationName.desc=Der Anwendungsname (z. B. MW Bank), der in QR-Code-E-Mails verwendet werden soll.
+
+configuration.qrcodeIssuer.name=QR-Code-Ausstellername
+configuration.qrcodeIssuer.desc=Wird als Ausstellername verwendet, wenn ein QR-Code für einen geheimen Schlüssel des Benutzers generiert wird. Bitte beachten Sie, dass durch eine Änderung zuvor ausgegebene QR-Code-URLs ungültig werden.
+
+configuration.qrcodeUrl.name=QR-Code-URL
+configuration.qrcodeUrl.desc=URL zum Generieren eines QR-Codes für einen geheimen Schlüssel eines Benutzers.
+
+configuration.qrcodeResendUrl.name=URL zum erneuten Senden des QR-Codes
+configuration.qrcodeResendUrl.desc=URL zum erneuten Senden eines QR-Codes, wenn eine vorherige QR-Code-URL abgelaufen ist.
+
+configuration.qrcodeUrlJWTSecret.name=QR-Code-URL-JWT-Geheimnis
+configuration.qrcodeUrlJWTSecret.desc=JWT-Token-Geheimnis, das zum Kodieren und Dekodieren von Token-Parametern in QR-Code-URLs verwendet wird. Bitte beachten Sie, dass durch eine Änderung zuvor ausgegebene QR-Code-URLs ungültig werden.
+
+configuration.qrcodeUrlDurationMinutes.name=QR-Code-URL-Dauer (Minuten)
+configuration.qrcodeUrlDurationMinutes.desc=Dauer in Minuten, für die eine per E-Mail gesendete QR-Code-URL gültig ist. Verwenden Sie 0, um nie abzulaufen.
+
+configuration.qrcodeEmailFrom.name=QR-Code-E-Mail von
+configuration.qrcodeEmailFrom.desc=Die Absender-E-Mail-Adresse, die für QR-Code-E-Mails verwendet werden soll.
+
+configuration.qrcodeEmailFromLabel.name=QR-Code-E-Mail von Label
+configuration.qrcodeEmailFromLabel.desc=Das von-Label, das für QR-Code-E-Mails verwendet werden soll.
+
+configuration.loginTotp2faSkipUserRole.name=Login TOTP 2FA Benutzerrolle überspringen
+configuration.loginTotp2faSkipUserRole.desc=Weisen Sie Benutzern diese reguläre Benutzerrolle zu, damit sie 2FA bei der Anmeldung umgehen können. Die Rolle muss erstellt werden, falls sie noch nicht vorhanden ist. Die Überprüfung des Authentifizierungscodes wird übersprungen, wenn der Benutzer diese reguläre Benutzerrolle hat. Die folgenden Rollen werden bei Eingabe ignoriert: Benutzer, Besitzer, Gast. Leer lassen, wenn diese Funktion nicht verwendet wird.
+
+configuration.showSecretKeysOnAccountScreens.name=Geheime Schlüssel auf Kontobildschirmen anzeigen
+configuration.showSecretKeysOnAccountScreens.desc=Ob der geheime Schlüssel eines Benutzers auf den Liferay-Kontobildschirmen angezeigt werden soll.
+
+configuration.allowForTimeSkew.name=Erweitert > Zeitversatz zulassen
+configuration.allowForTimeSkew.desc=Erlaubt die Übereinstimmung des 2FA-Authentifizierungscodes basierend auf dem vorherigen, aktuellen oder nächsten Authentifizierungscode basierend auf dem aktuellen Zeitstempel minus oder plus der Dauer der Dauer des Authentifizierungscodes.
+
+configuration.authenticatorCodeLength.name=Erweitert > Authentifizierungscodelänge
+configuration.authenticatorCodeLength.desc=Legt die Länge des Codes fest, der von 2FA-Apps generiert wird, wenn das Profil aus einer QR-Code-URL erstellt wird. Wird auch zur Validierung verwendet. Wenn Sie diese Einstellung ändern, werden alle bereits vorhandenen 2FA-App-Profile und zuvor ausgegebenen QR-Code-URLs ungültig. HINWEIS: Die j256-TOTP-Implementierung mit zwei Faktoren erfordert eine 'Authenticator Code Length' von 6, wenn nicht 6, werden nur die letzten 6 Ziffern überprüft.
+
+configuration.authenticatorCodeDuration.name=Erweitert > Dauer des Authentifizierungscodes (Sekunden)
+configuration.authenticatorCodeDuration.desc=Dauer (in Sekunden) des Codes, der von 2FA-Apps generiert wird, wenn das Profil aus einer QR-Code-URL erstellt wird. Wenn Sie diese Einstellung ändern, werden alle bereits vorhandenen 2FA-App-Profile und zuvor ausgegebenen QR-Code-URLs ungültig.
+
+configuration.totp2faImplementation.name=Erweitert > TOTP 2FA-Implementierung
+configuration.totp2faImplementation.desc=Die spezifische Implementierung, die beim Generieren des Authenticator-Codes zum Vergleich verwendet werden soll. HINWEIS: Die j256-TOTP-Implementierung mit zwei Faktoren erfordert eine 'Authenticator Code Length' von 6, wenn nicht 6, werden nur die letzten 6 Ziffern überprüft.
+
+authenticator-code=Zwei-Faktor-Authentifizierung (Code)
+
+2fa-required-on-login-when-2fa-enabled=2FA erforderlich bei der Anmeldung (wenn 2FA aktiviert)
+2fa-qr-code=2FA QR-Code
+2fa-secret-key=2FA-Geheimschlüssel
+genere-secret-key=Erzeuge 2FA-Geheimschlüssel
+generate-secret-key-and-email-qr-code=Geheimen 2FA-Schlüssel generieren und QR-Code-URL per E-Mail senden
+regenerate-secret-key=2FA-Geheimschlüssel neu generieren
+regenerate-secret-key-and-email-qr-code=2FA-Geheimschlüssel neu generieren und QR-Code-URL per E-Mail senden
+email-2fa-qr-code-url=2FA QR-Code-URL per E-Mail senden
+not-available=Nicht verfügbar
+any-unsaved-changed-to-this-screen-will-be-lost=(alle nicht gespeicherten Änderungen auf diesem Bildschirm gehen verloren)
+
+qrCode.mail.subject={0} Konto 2FA-Anmeldung
+qrCode.mail.body=Willkommen bei {0}.\n\nUm 2FA zu verwenden, laden Sie eine 2FA-Telefon-App (z. B. Google Authenticator) herunter und klicken Sie hier, um sie anzusehen und scannen Sie Ihren einzigartigen QR-Code in der 2FA-App und verwenden Sie dann den aktuellen Authentifizierungscode aus der 2FA-App beim Anmelden.\n\nBitte entfernen Sie alle vorherigen Einträge für dieses Konto aus Ihrer 2FA-App, bevor Sie diesen neuen Eintrag hinzufügen.
+
+qr-code-url-has-expired-click-here-to-request-a-new-qr-code-url=QR-Code-URL ist abgelaufen. Klicken Sie hier, um einen neuen QR-Code anzufordern.
+qr-code-url-invalid=QR-Code-URL ungültig.
+qr-code-url-missing-expected-parameters=QR-Code-URL fehlen erwartete Parameter.
+an-error-occurred-generating-the-qr-code=Bei der Generierung des QR-Codes ist ein Fehler aufgetreten.
+qr-code-resend-url-invalid=URL zum erneuten Senden des QR-Codes ungültig.
+qr-code-resend-url-missing-expected-parameters=URL des QR-Codes erneut senden, es fehlen die erwarteten Parameter.
+Matching-active-user-not-found=Passender aktiver Benutzer nicht gefunden.
+secret-key-not-found-for-this-user-please-contact-the-system-administrators=Geheimer Schlüssel für diesen Benutzer nicht gefunden, bitte kontaktieren Sie die Systemadministratoren.
+an-error-occurred-generating-the-qr-code=Bei der Generierung des QR-Codes ist ein Fehler aufgetreten.
+an-error-occurred-resending-the-qr-code-url=Beim erneuten Senden der QR-Code-URL ist ein Fehler aufgetreten.
+qr-code-url-has-been-resent-to-the-account-email-address=QR-Code-URL wurde erneut an die E-Mail-Adresse des Kontos gesendet.
\ No newline at end of file
diff --git a/modules/totp-2fa-user-model-listener/build.gradle b/modules/totp-2fa-user-model-listener/build.gradle
index cff4fdc..d129f9a 100644
--- a/modules/totp-2fa-user-model-listener/build.gradle
+++ b/modules/totp-2fa-user-model-listener/build.gradle
@@ -1,7 +1,5 @@
dependencies {
- compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.6.0"
- compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
- compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
+ compileOnly group: "com.liferay.portal", name: "release.portal.api"
compileOnly project(":modules:totp-2fa-service")
compileOnly project(":modules:totp-2fa-qrcode")
diff --git a/readme.md b/readme.md
index ae9af47..d50b7e3 100644
--- a/readme.md
+++ b/readme.md
@@ -1,6 +1,6 @@
# Introduction
-This OSGi project extends the Liferay Login functionality to add 2 Factor Authentication (2FA) to Liferay DXP 7.1, with QR Code support. See Liferay Blog post [Adding 2FA to Liferay DXP 7.1](https://community.liferay.com/blogs/-/blogs/adding-2fa-to-liferay-dxp-7-1) for screenshots.
+This OSGi project ports Michael Wall's 2 Factor Authentication (2FA) Plugin to Liferay CE 7.4.2 CE GA3 (see Liferay Blog post [Adding 2FA to Liferay DXP 7.1](https://community.liferay.com/blogs/-/blogs/adding-2fa-to-liferay-dxp-7-1) for screenshots).
The Google Authenticator app (available for iPhone and Android) or other 2FA apps can be used by the user during login to generate a one-time passcode, with QR Code support included to populate the 2FA app user profile.
@@ -45,7 +45,7 @@ The following steps cover building, deploying, configuring and testing:
# Notes
-1. Supported Liferay versions: **DXP 7.1**
+1. Supported Liferay versions: **CE 7.4.2 CE GA3+**
2. 2FA on Login must be explicitly configured and enabled after initial deployment, see 'Deployment & Setup Steps' to enable
3. Ensure that the phone and server time are roughly the same, if not then the generated codes may not match when the comparison is done, as the code is only valid for 30 / 60 seconds. See System Settings > TOTP 2FA > Advanced > Allow for Time Skew below to make the verification more lenient
4. If the Google Authenticator code is red it means it is about to expire. If Allow for Time Skew is off then wait until a new one is generated before trying as a time difference of a few seconds between the phone and server means it may not work
@@ -147,4 +147,4 @@ An OSGi Resource Bundle service component is defined for en_US, mapped to TOTP_2
2. The Authenticator Code is shown on the same screen as the Username and Password rather than on a subsequent screen
3. More complex authentication scenarios such as SSO / Oauth etc. are not supported
4. Liferay Screens > Login Screenlet not (currently) supported
-5. System Settings > TOTP 2 FA scope is set to System so the settings apply to all Liferay instances
\ No newline at end of file
+5. System Settings > TOTP 2 FA scope is set to System so the settings apply to all Liferay instances
diff --git a/settings.gradle b/settings.gradle
index dc64429..d8b9fde 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,12 +1,19 @@
buildscript {
dependencies {
- classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.5.0"
+ classpath group: "biz.aQute.bnd", name: "biz.aQute.bnd", version: "5.2.0"
+ classpath(group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "3.4.12") {
+ exclude group: "biz.aQute.bnd", module: "biz.aQute.bnd"
+ }
classpath group: "net.saliman", name: "gradle-properties-plugin", version: "1.4.6"
}
repositories {
maven {
- url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
+ url "https://repository-cdn.liferay.com/nexus/content/groups/public"
+ }
+
+ maven {
+ url "https://repository.liferay.com/nexus/content/groups/public"
}
}
}