From 348f0f77d162a7630d64b3e74f47a3c44af51ac3 Mon Sep 17 00:00:00 2001 From: nwcm <111259588+nwcm@users.noreply.github.com> Date: Mon, 10 Nov 2025 15:19:20 +1100 Subject: [PATCH 1/2] Annotate public and protected with @NamespaceAccessible --- .../main/classes/fflib_Application.cls | 43 ++ .../main/classes/fflib_IDomain.cls | 1 + .../main/classes/fflib_IDomainConstructor.cls | 1 + .../main/classes/fflib_IDomainFactory.cls | 1 + .../main/classes/fflib_IObjects.cls | 1 + .../main/classes/fflib_ISObjectDomain.cls | 2 +- .../main/classes/fflib_ISObjectSelector.cls | 2 +- .../main/classes/fflib_ISObjectUnitOfWork.cls | 1 + .../main/classes/fflib_ISObjects.cls | 1 + .../main/classes/fflib_ISelectorFactory.cls | 1 + .../main/classes/fflib_IServiceFactory.cls | 1 + .../main/classes/fflib_IUnitOfWorkFactory.cls | 1 + .../main/classes/fflib_Objects.cls | 41 +- .../main/classes/fflib_QueryFactory.cls | 167 +++++--- .../main/classes/fflib_SObjectDescribe.cls | 94 +++-- .../main/classes/fflib_SObjectDomain.cls | 388 ++++++++++++------ .../main/classes/fflib_SObjectSelector.cls | 120 ++++-- .../main/classes/fflib_SObjectUnitOfWork.cls | 262 ++++++++---- .../main/classes/fflib_SObjects.cls | 130 ++++-- .../main/classes/fflib_SecurityUtils.cls | 26 ++ .../main/classes/fflib_StringBuilder.cls | 60 ++- 21 files changed, 926 insertions(+), 418 deletions(-) diff --git a/sfdx-source/apex-common/main/classes/fflib_Application.cls b/sfdx-source/apex-common/main/classes/fflib_Application.cls index d957ca1d511..39015400673 100644 --- a/sfdx-source/apex-common/main/classes/fflib_Application.cls +++ b/sfdx-source/apex-common/main/classes/fflib_Application.cls @@ -29,19 +29,24 @@ * of the Apex Enterprise Patterns, Service, Unit Of Work, Selector and Domain. * See the sample applications Application.cls file for an example **/ +@NamespaceAccessible public virtual class fflib_Application { /** * Class implements a Unit of Work factory **/ + @NamespaceAccessible public virtual class UnitOfWorkFactory implements fflib_IUnitOfWorkFactory { + @NamespaceAccessible protected List m_objectTypes; + @NamespaceAccessible protected fflib_ISObjectUnitOfWork m_mockUow; /** * Constructs a Unit Of Work factory **/ + @NamespaceAccessible public UnitOfWorkFactory() { } /** @@ -49,6 +54,7 @@ public virtual class fflib_Application * * @param objectTypes List of SObjectTypes in dependency order **/ + @NamespaceAccessible public UnitOfWorkFactory(List objectTypes) { m_objectTypes = objectTypes.clone(); @@ -59,6 +65,7 @@ public virtual class fflib_Application * SObjectType list provided in the constructor, returns a Mock implementation * if set via the setMock method **/ + @NamespaceAccessible public virtual fflib_ISObjectUnitOfWork newInstance() { // Mock? @@ -72,6 +79,7 @@ public virtual class fflib_Application * SObjectType list provided in the constructor, returns a Mock implementation * if set via the setMock method **/ + @NamespaceAccessible public virtual fflib_ISObjectUnitOfWork newInstance(fflib_SObjectUnitOfWork.IDML dml) { // Mock? @@ -88,6 +96,7 @@ public virtual class fflib_Application * @remark If mock is set, the list of SObjectType in the mock could be different * than the list of SObjectType specified in this method call **/ + @NamespaceAccessible public virtual fflib_ISObjectUnitOfWork newInstance(List objectTypes) { // Mock? @@ -104,6 +113,7 @@ public virtual class fflib_Application * @remark If mock is set, the list of SObjectType in the mock could be different * than the list of SObjectType specified in this method call **/ + @NamespaceAccessible public virtual fflib_ISObjectUnitOfWork newInstance(List objectTypes, fflib_SObjectUnitOfWork.IDML dml) { // Mock? @@ -113,6 +123,7 @@ public virtual class fflib_Application } @TestVisible + @NamespaceAccessible protected virtual void setMock(fflib_ISObjectUnitOfWork mockUow) { m_mockUow = mockUow; @@ -122,15 +133,19 @@ public virtual class fflib_Application /** * Simple Service Factory implementation **/ + @NamespaceAccessible public virtual class ServiceFactory implements fflib_IServiceFactory { + @NamespaceAccessible protected Map m_serviceInterfaceTypeByServiceImplType; + @NamespaceAccessible protected Map m_serviceInterfaceTypeByMockService; /** * Constructs a simple Service Factory **/ + @NamespaceAccessible public ServiceFactory() { } /** @@ -141,6 +156,7 @@ public virtual class fflib_Application * * @param serviceInterfaceTypeByServiceImplType Map of interfaces to classes **/ + @NamespaceAccessible public ServiceFactory(Map serviceInterfaceTypeByServiceImplType) { m_serviceInterfaceTypeByServiceImplType = serviceInterfaceTypeByServiceImplType; @@ -155,6 +171,7 @@ public virtual class fflib_Application * @param serviceInterfaceType Apex interface type * @exception Is thrown if there is no registered Apex class for the interface type **/ + @NamespaceAccessible public virtual Object newInstance(Type serviceInterfaceType) { // Mock implementation? @@ -169,6 +186,7 @@ public virtual class fflib_Application } @TestVisible + @NamespaceAccessible protected virtual void setMock(Type serviceInterfaceType, Object serviceImpl) { m_serviceInterfaceTypeByMockService.put(serviceInterfaceType, serviceImpl); @@ -178,14 +196,18 @@ public virtual class fflib_Application /** * Class implements a Selector class factory **/ + @NamespaceAccessible public virtual class SelectorFactory implements fflib_ISelectorFactory { + @NamespaceAccessible protected Map m_sObjectBySelectorType; + @NamespaceAccessible protected Map m_sObjectByMockSelector; /** * Constructs a simple Selector Factory **/ + @NamespaceAccessible public SelectorFactory() { } /** @@ -195,6 +217,7 @@ public virtual class fflib_Application * * @param sObjectBySelectorType Map of SObjectType's to Selector Apex Classes **/ + @NamespaceAccessible public SelectorFactory(Map sObjectBySelectorType) { m_sObjectBySelectorType = sObjectBySelectorType; @@ -207,6 +230,7 @@ public virtual class fflib_Application * * @param sObjectType An SObjectType token, e.g. Account.SObjectType **/ + @NamespaceAccessible public virtual fflib_ISObjectSelector newInstance(SObjectType sObjectType) { // Mock implementation? @@ -230,6 +254,7 @@ public virtual class fflib_Application * @param recordIds The SObject record Ids, must be all the same SObjectType * @exception Is thrown if the record Ids are not all the same or the SObjectType is not registered **/ + @NamespaceAccessible public virtual List selectById(Set recordIds) { // No point creating an empty Domain class, nor can we determine the SObjectType anyway @@ -258,6 +283,7 @@ public virtual class fflib_Application * @param relatedRecords used to extract the related record Ids, e.g. Opportunity records * @param relationshipField field in the passed records that contains the relationship records to query, e.g. Opportunity.AccountId **/ + @NamespaceAccessible public virtual List selectByRelationship(List relatedRecords, SObjectField relationshipField) { Set relatedIds = new Set(); @@ -271,6 +297,7 @@ public virtual class fflib_Application } @TestVisible + @NamespaceAccessible protected virtual void setMock(fflib_ISObjectSelector selectorInstance) { m_sObjectByMockSelector.put(selectorInstance.sObjectType(), selectorInstance); @@ -280,17 +307,22 @@ public virtual class fflib_Application /** * Class implements a Domain class factory **/ + @NamespaceAccessible public virtual class DomainFactory implements fflib_IDomainFactory { + @NamespaceAccessible protected fflib_Application.SelectorFactory m_selectorFactory; + @NamespaceAccessible protected Map constructorTypeByObject; + @NamespaceAccessible protected Map mockDomainByObject; /** * Constructs a Domain factory **/ + @NamespaceAccessible public DomainFactory() { } /** @@ -302,6 +334,7 @@ public virtual class fflib_Application * @param selectorFactory , e.g. Application.Selector * @param constructorTypeByObject Map of Domain classes by ObjectType **/ + @NamespaceAccessible public DomainFactory(fflib_Application.SelectorFactory selectorFactory, Map constructorTypeByObject) { @@ -319,6 +352,7 @@ public virtual class fflib_Application * @param selectorFactory, e.g. Application.Selector * @param sObjectByDomainConstructorType Map of Apex classes by SObjectType **/ + @NamespaceAccessible public DomainFactory(fflib_Application.SelectorFactory selectorFactory, Map sObjectByDomainConstructorType) { @@ -335,6 +369,7 @@ public virtual class fflib_Application * @param recordIds A list of Id's of the same type * @exception Throws an exception via the Selector Factory if the Ids are not all of the same SObjectType **/ + @NamespaceAccessible public virtual fflib_IDomain newInstance(Set recordIds) { return newInstance(m_selectorFactory.selectById(recordIds)); @@ -349,6 +384,7 @@ public virtual class fflib_Application * @exception Throws an exception if the SObjectType cannot be determined from the list * or the constructor for Domain class was not registered for the SObjectType **/ + @NamespaceAccessible public virtual fflib_IDomain newInstance(List records) { SObjectType domainSObjectType = records.getSObjectType(); @@ -358,6 +394,7 @@ public virtual class fflib_Application return newInstance((List) records, (Object) domainSObjectType); } + @NamespaceAccessible public virtual fflib_IDomain newInstance(List objects, Object objectType) { // Mock implementation? @@ -401,6 +438,7 @@ public virtual class fflib_Application * @remark Will support List but all records in the list will be assumed to be of * the type specified in sObjectType **/ + @NamespaceAccessible public virtual fflib_IDomain newInstance(List records, SObjectType domainSObjectType) { if(domainSObjectType==null) @@ -413,17 +451,20 @@ public virtual class fflib_Application } @TestVisible + @NamespaceAccessible protected virtual void setMock(fflib_ISObjectDomain mockDomain) { mockDomainByObject.put((Object) mockDomain.sObjectType(), (fflib_IDomain) mockDomain); } @TestVisible + @NamespaceAccessible protected virtual void setMock(fflib_IDomain mockDomain) { mockDomainByObject.put(mockDomain.getType(), mockDomain); } + @NamespaceAccessible protected virtual Map getConstructorTypeByObject(Map constructorTypeBySObjectType) { Map result = new Map(); @@ -438,10 +479,12 @@ public virtual class fflib_Application } } + @NamespaceAccessible public class ApplicationException extends Exception { } /** * Exception representing a developer coding error, not intended for end user eyes **/ + @NamespaceAccessible public class DeveloperException extends Exception { } } \ No newline at end of file diff --git a/sfdx-source/apex-common/main/classes/fflib_IDomain.cls b/sfdx-source/apex-common/main/classes/fflib_IDomain.cls index 298f5b8ed42..1bc95dd1669 100644 --- a/sfdx-source/apex-common/main/classes/fflib_IDomain.cls +++ b/sfdx-source/apex-common/main/classes/fflib_IDomain.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_IDomain { Object getType(); diff --git a/sfdx-source/apex-common/main/classes/fflib_IDomainConstructor.cls b/sfdx-source/apex-common/main/classes/fflib_IDomainConstructor.cls index c4096d1d00a..ff2de4e17ae 100644 --- a/sfdx-source/apex-common/main/classes/fflib_IDomainConstructor.cls +++ b/sfdx-source/apex-common/main/classes/fflib_IDomainConstructor.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_IDomainConstructor { fflib_IDomain construct(List objects); diff --git a/sfdx-source/apex-common/main/classes/fflib_IDomainFactory.cls b/sfdx-source/apex-common/main/classes/fflib_IDomainFactory.cls index 1e0f982d5ae..1f425a567b2 100644 --- a/sfdx-source/apex-common/main/classes/fflib_IDomainFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_IDomainFactory.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_IDomainFactory { fflib_IDomain newInstance(Set recordIds); diff --git a/sfdx-source/apex-common/main/classes/fflib_IObjects.cls b/sfdx-source/apex-common/main/classes/fflib_IObjects.cls index 80358b22dd7..55f23ac7d87 100644 --- a/sfdx-source/apex-common/main/classes/fflib_IObjects.cls +++ b/sfdx-source/apex-common/main/classes/fflib_IObjects.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_IObjects extends fflib_IDomain { /** diff --git a/sfdx-source/apex-common/main/classes/fflib_ISObjectDomain.cls b/sfdx-source/apex-common/main/classes/fflib_ISObjectDomain.cls index 3dfadce34d4..ab59bb6877b 100644 --- a/sfdx-source/apex-common/main/classes/fflib_ISObjectDomain.cls +++ b/sfdx-source/apex-common/main/classes/fflib_ISObjectDomain.cls @@ -23,7 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ - +@NamespaceAccessible public interface fflib_ISObjectDomain extends fflib_IDomain { /** diff --git a/sfdx-source/apex-common/main/classes/fflib_ISObjectSelector.cls b/sfdx-source/apex-common/main/classes/fflib_ISObjectSelector.cls index 6cc8a3baddc..4aa47918461 100644 --- a/sfdx-source/apex-common/main/classes/fflib_ISObjectSelector.cls +++ b/sfdx-source/apex-common/main/classes/fflib_ISObjectSelector.cls @@ -23,7 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ - +@NamespaceAccessible public interface fflib_ISObjectSelector { /** diff --git a/sfdx-source/apex-common/main/classes/fflib_ISObjectUnitOfWork.cls b/sfdx-source/apex-common/main/classes/fflib_ISObjectUnitOfWork.cls index 164920c9c45..a8cae0e4a2a 100644 --- a/sfdx-source/apex-common/main/classes/fflib_ISObjectUnitOfWork.cls +++ b/sfdx-source/apex-common/main/classes/fflib_ISObjectUnitOfWork.cls @@ -27,6 +27,7 @@ /** * @see fflib_SObjectUnitOfWork **/ +@NamespaceAccessible public interface fflib_ISObjectUnitOfWork { /** diff --git a/sfdx-source/apex-common/main/classes/fflib_ISObjects.cls b/sfdx-source/apex-common/main/classes/fflib_ISObjects.cls index bf30d9a276e..b34e5056fc8 100644 --- a/sfdx-source/apex-common/main/classes/fflib_ISObjects.cls +++ b/sfdx-source/apex-common/main/classes/fflib_ISObjects.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_ISObjects extends fflib_IObjects { /** diff --git a/sfdx-source/apex-common/main/classes/fflib_ISelectorFactory.cls b/sfdx-source/apex-common/main/classes/fflib_ISelectorFactory.cls index a39095b289b..1d30475da66 100644 --- a/sfdx-source/apex-common/main/classes/fflib_ISelectorFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_ISelectorFactory.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_ISelectorFactory { fflib_ISObjectSelector newInstance(SObjectType sObjectType); diff --git a/sfdx-source/apex-common/main/classes/fflib_IServiceFactory.cls b/sfdx-source/apex-common/main/classes/fflib_IServiceFactory.cls index 93fa4124cc7..500b5cf048d 100644 --- a/sfdx-source/apex-common/main/classes/fflib_IServiceFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_IServiceFactory.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_IServiceFactory { Object newInstance(Type serviceInterfaceType); diff --git a/sfdx-source/apex-common/main/classes/fflib_IUnitOfWorkFactory.cls b/sfdx-source/apex-common/main/classes/fflib_IUnitOfWorkFactory.cls index 371ab1ccde9..0cbb38e2d51 100644 --- a/sfdx-source/apex-common/main/classes/fflib_IUnitOfWorkFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_IUnitOfWorkFactory.cls @@ -23,6 +23,7 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public interface fflib_IUnitOfWorkFactory { fflib_ISObjectUnitOfWork newInstance(); diff --git a/sfdx-source/apex-common/main/classes/fflib_Objects.cls b/sfdx-source/apex-common/main/classes/fflib_Objects.cls index 44c4f069eaf..bb976395958 100644 --- a/sfdx-source/apex-common/main/classes/fflib_Objects.cls +++ b/sfdx-source/apex-common/main/classes/fflib_Objects.cls @@ -23,41 +23,49 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ -public virtual class fflib_Objects implements fflib_IObjects +@NamespaceAccessible + public virtual class fflib_Objects implements fflib_IObjects { + @NamespaceAccessible protected List objects { get; private set;} { objects = new List(); } /** * Class constructor */ - public fflib_Objects(List objects) + @NamespaceAccessible + public fflib_Objects(List objects) { this.objects = objects.clone(); } - public virtual Object getType() + @NamespaceAccessible + public virtual Object getType() { return Object.class; } - public List getObjects() + @NamespaceAccessible + public List getObjects() { return this.objects; } - public Boolean contains(Object value) + @NamespaceAccessible + public Boolean contains(Object value) { return getObjects()?.contains(value); } - public Boolean containsAll(List values) + @NamespaceAccessible + public Boolean containsAll(List values) { if (values == null) return false; return containsAll(new Set(values)); } - public Boolean containsAll(Set values) + @NamespaceAccessible + public Boolean containsAll(Set values) { if (values == null) return false; @@ -68,19 +76,22 @@ public virtual class fflib_Objects implements fflib_IObjects return true; } - public Boolean containsNot(Object value) + @NamespaceAccessible + public Boolean containsNot(Object value) { return !contains(value); } - public Boolean containsNot(List values) + @NamespaceAccessible + public Boolean containsNot(List values) { if (values == null) return true; return containsNot(new Set(values)); } - public Boolean containsNot(Set values) + @NamespaceAccessible + public Boolean containsNot(Set values) { if (values == null) return true; @@ -91,21 +102,25 @@ public virtual class fflib_Objects implements fflib_IObjects return true; } - public Boolean isEmpty() + @NamespaceAccessible + public Boolean isEmpty() { return (getObjects() == null || getObjects().isEmpty()); } - public Boolean isNotEmpty() + @NamespaceAccessible + public Boolean isNotEmpty() { return !isEmpty(); } - public Integer size() + @NamespaceAccessible + public Integer size() { return getObjects().size(); } + @NamespaceAccessible protected void setObjects(List objects) { this.objects = objects; diff --git a/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls b/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls index cf31cc0e40c..779f83a3364 100644 --- a/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls @@ -51,15 +51,19 @@ * There is a google doc providing additional guidance on the use of this class with field sets at * https://docs.google.com/a/financialforce.com/document/d/1I4cxN4xHT4UJj_3Oi0YBL_MJ5chm-KG8kMN1D1un8-g/edit?usp=sharing **/ +@NamespaceAccessible public class fflib_QueryFactory { //No explicit sharing declaration - inherit from caller - public enum SortOrder {ASCENDING, DESCENDING} - public enum FLSEnforcement{NONE, LEGACY, USER_MODE, SYSTEM_MODE} + @NamespaceAccessible + public enum SortOrder {ASCENDING, DESCENDING} + @NamespaceAccessible + public enum FLSEnforcement{NONE, LEGACY, USER_MODE, SYSTEM_MODE} /** * This property is read-only and may not be set after instantiation. * The {@link Schema.SObjectType} token of the SObject that will be used in the FROM clause of the resultant query. **/ - public Schema.SObjectType table {get; private set;} + @NamespaceAccessible + public Schema.SObjectType table {get; private set;} @TestVisible private Set fields; private String conditionExpression; @@ -169,7 +173,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * This method will never return true if the provided object is not an instance of fflib_QueryFactory. * @param obj the object to check equality of. **/ - public Boolean equals(Object obj){ + @NamespaceAccessible + public Boolean equals(Object obj){ if( !(obj instanceof fflib_QueryFactory) || ((fflib_QueryFactory)obj).table != this.table || ((fflib_QueryFactory)obj).fields.size() != this.fields.size() ) return false; return ((fflib_QueryFactory)obj).toSOQL() == this.toSOQL(); @@ -180,7 +185,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * You *must* call selectField(s) before {@link #toSOQL} will return a valid, runnable query. * @param table the SObject to be used in the FROM clause of the resultant query. This sets the value of {@link #table}. **/ - public fflib_QueryFactory(Schema.SObjectType table){ + @NamespaceAccessible + public fflib_QueryFactory(Schema.SObjectType table){ this.table = table; fields = new Set(); order = new List(); @@ -203,7 +209,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * This method checks to see if the User has Read Access on {@link #table}. * Asserts true if User has access. **/ - public fflib_QueryFactory assertIsAccessible(){ + @NamespaceAccessible + public fflib_QueryFactory assertIsAccessible(){ fflib_SecurityUtils.checkObjectIsReadable(table); return this; } @@ -215,11 +222,13 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param enforce whether to enforce field level security (read) * @deprecated - use the setEnforceFLS overload that specifies Legacy or Native FLS enforcement **/ - public fflib_QueryFactory setEnforceFLS(Boolean enforce){ + @NamespaceAccessible + public fflib_QueryFactory setEnforceFLS(Boolean enforce){ return setEnforceFLS(enforce ? FLSEnforcement.LEGACY : FLSEnforcement.NONE); } - public fflib_QueryFactory setEnforceFLS(FLSEnforcement enforcement){ + @NamespaceAccessible + public fflib_QueryFactory setEnforceFLS(FLSEnforcement enforcement){ this.mFlsEnforcement = enforcement; return this; } @@ -231,7 +240,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * If you are processing large query sets, you should switch this off. * @param doSort whether or not select fields should be sorted in the soql statement. **/ - public fflib_QueryFactory setSortSelectFields(Boolean doSort){ + @NamespaceAccessible + public fflib_QueryFactory setSortSelectFields(Boolean doSort){ this.sortSelectFields = doSort; return this; } @@ -240,7 +250,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * Selecting fields is idempotent, if this field is already selected calling this method will have no additional impact. * @param fieldName the API name of the field to add to the query's SELECT clause. **/ - public fflib_QueryFactory selectField(String fieldName){ + @NamespaceAccessible + public fflib_QueryFactory selectField(String fieldName){ return selectFields(new Set{fieldName}); } @@ -250,7 +261,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fieldName the API name of the field to add to the query's SELECT clause. * @param relatedSObjectType the related sObjectType to resolve polymorphic object fields. **/ - public fflib_QueryFactory selectField(String fieldName, Schema.sObjectType relatedObjectType) { + @NamespaceAccessible + public fflib_QueryFactory selectField(String fieldName, Schema.sObjectType relatedObjectType) { addField(getFieldPath(fieldName, relatedObjectType)); return this; } @@ -261,21 +273,24 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param field the {@link Schema.SObjectField} to select with this query. * @exception InvalidFieldException If the field is null {@code field}. **/ - public fflib_QueryFactory selectField(Schema.SObjectField field){ + @NamespaceAccessible + public fflib_QueryFactory selectField(Schema.SObjectField field){ return selectFields(new Set{field}); } /** * Selects multiple fields. This acts the same as calling {@link #selectField(String)} multiple times. * @param fieldNames the Set of field API names to select. **/ - public fflib_QueryFactory selectFields(Set fieldNames){ + @NamespaceAccessible + public fflib_QueryFactory selectFields(Set fieldNames){ return selectStringField(fieldNames.iterator()); } /** * Selects multiple fields. This acts the same as calling {@link #selectField(String)} multiple times. * @param fieldNames the List of field API names to select. **/ - public fflib_QueryFactory selectFields(List fieldNames){ + @NamespaceAccessible + public fflib_QueryFactory selectFields(List fieldNames){ return selectStringField(fieldNames.iterator()); } @@ -291,7 +306,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fields the Set of {@link Schema.SObjectField}s to select. * @exception InvalidFieldException if the fields are null {@code fields}. **/ - public fflib_QueryFactory selectFields(Set fields){ + @NamespaceAccessible + public fflib_QueryFactory selectFields(Set fields){ return selectSObjectFields(fields.iterator()); } @@ -300,7 +316,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fields the List of {@link Schema.SObjectField}s to select. * @exception InvalidFieldException if the fields are null {@code fields}. **/ - public fflib_QueryFactory selectFields(List fields) { + @NamespaceAccessible + public fflib_QueryFactory selectFields(List fields) { return selectSObjectFields(fields.iterator()); } @@ -321,7 +338,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr /** * @see #selectFieldSet(Schema.FieldSet,Boolean) **/ - public fflib_QueryFactory selectFieldSet(Schema.FieldSet fieldSet){ + @NamespaceAccessible + public fflib_QueryFactory selectFieldSet(Schema.FieldSet fieldSet){ return selectFieldSet(fieldSet,true); } /** @@ -330,7 +348,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param allowCrossObject if false this method will throw an exception if any fields in the field set reference fields on a related record. * @exception InvalidFieldSetException if the fieldset is invalid for table {@code fields}. **/ - public fflib_QueryFactory selectFieldSet(Schema.FieldSet fieldSet, Boolean allowCrossObject){ + @NamespaceAccessible + public fflib_QueryFactory selectFieldSet(Schema.FieldSet fieldSet, Boolean allowCrossObject){ if(fieldSet.getSObjectType() != table) throw new InvalidFieldSetException('Field set "'+fieldSet.getName()+'" is not for SObject type "'+table+'"'); for(Schema.FieldSetMember field: fieldSet.getFields()){ @@ -359,46 +378,53 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr /** * @param conditionExpression Sets the WHERE clause to the string provided. Do not include the "WHERE". **/ - public fflib_QueryFactory setCondition(String conditionExpression){ + @NamespaceAccessible + public fflib_QueryFactory setCondition(String conditionExpression){ this.conditionExpression = conditionExpression; return this; } /** * @returns the current value of the WHERE clause, if any, as set by {@link #setCondition} **/ - public String getCondition(){ + @NamespaceAccessible + public String getCondition(){ return this.conditionExpression; } /** * @param limitCount if not null causes a LIMIT clause to be added to the resulting query. **/ - public fflib_QueryFactory setLimit(Integer limitCount){ + @NamespaceAccessible + public fflib_QueryFactory setLimit(Integer limitCount){ this.limitCount = limitCount; return this; } /** * @returns the current value of the LIMIT clause, if any. **/ - public Integer getLimit(){ + @NamespaceAccessible + public Integer getLimit(){ return this.limitCount; } /** * @param offsetCount if not null causes a OFFSET clause to be added to the resulting query. **/ - public fflib_QueryFactory setOffset(Integer offsetCount){ + @NamespaceAccessible + public fflib_QueryFactory setOffset(Integer offsetCount){ this.offsetCount = offsetCount; return this; } /** * @returns the current value of the OFFSET clause, if any. **/ - public Integer getOffset(){ + @NamespaceAccessible + public Integer getOffset(){ return this.offsetCount; } /** * @param o an instance of {@link fflib_QueryFactory.Ordering} to be added to the query's ORDER BY clause. **/ - public fflib_QueryFactory addOrdering(Ordering o){ + @NamespaceAccessible + public fflib_QueryFactory addOrdering(Ordering o){ this.order.add(o); return this; } @@ -406,21 +432,24 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr /** * @param o an instance of {@link fflib_QueryFactory.Ordering} to remove all existing (for instance defaults) and be added to the query's ORDER BY clause. **/ - public fflib_QueryFactory setOrdering(Ordering o){ + @NamespaceAccessible + public fflib_QueryFactory setOrdering(Ordering o){ this.order = new List{ o }; return this; } /** * @returns the list of orderings that will be used as the query's ORDER BY clause. You may remove elements from the returned list, or otherwise mutate it, to remove previously added orderings. **/ - public List getOrderings(){ + @NamespaceAccessible + public List getOrderings(){ return this.order; } /** * @returns the selected fields **/ - public Set getSelectedFields() { + @NamespaceAccessible + public Set getSelectedFields() { return this.fields; } @@ -431,7 +460,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @exception InvalidSubqueryRelationshipException If this method is called on a subselectQuery or with an invalid relationship * @param related The related object type **/ - public fflib_QueryFactory subselectQuery(SObjectType related){ + @NamespaceAccessible + public fflib_QueryFactory subselectQuery(SObjectType related){ System.debug(LoggingLevel.WARN, 'fflib_QueryFactory.subselectQuery(Schema.SObjectType) is deprecated and will be removed in a future release. Use fflib_QueryFactory.subselectQuery(String) or fflib_QueryFactory.subselectQuery(ChildRelationship) instead.'); return setSubselectQuery(getChildRelationship(related), false); } @@ -444,7 +474,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param related The related object type * @param assertIsAccessible indicates whether to check if the user has access to the subquery object **/ - public fflib_QueryFactory subselectQuery(SObjectType related, Boolean assertIsAccessible){ + @NamespaceAccessible + public fflib_QueryFactory subselectQuery(SObjectType related, Boolean assertIsAccessible){ System.debug(LoggingLevel.WARN, 'fflib_QueryFactory.subselectQuery(Schema.SObjectType, Boolean) is deprecated and will be removed in a future release. Use fflib_QueryFactory.subselectQuery(String, Boolean) or fflib_QueryFactory.subselectQuery(ChildRelationship, Boolean) instead.'); return setSubselectQuery(getChildRelationship(related), assertIsAccessible); } @@ -455,7 +486,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @exception InvalidSubqueryRelationshipException If this method is called on a subselectQuery or with an invalid relationship * @param relationshipName The relationshipName to be added as a subquery **/ - public fflib_QueryFactory subselectQuery(String relationshipName){ + @NamespaceAccessible + public fflib_QueryFactory subselectQuery(String relationshipName){ return subselectQuery(relationshipName, false); } @@ -466,7 +498,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param relationshipName The relationshipName to be added as a subquery * @param assertIsAccessible indicates whether to check if the user has access to the subquery object **/ - public fflib_QueryFactory subselectQuery(String relationshipName, Boolean assertIsAccessible){ + @NamespaceAccessible + public fflib_QueryFactory subselectQuery(String relationshipName, Boolean assertIsAccessible){ Schema.ChildRelationship relationship = getChildRelationship(relationshipName); if (relationship != null) { return setSubselectQuery(relationship, assertIsAccessible); @@ -480,7 +513,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @exception InvalidSubqueryRelationshipException If this method is called on a subselectQuery or with an invalid relationship * @param relationship The ChildRelationship to be added as a subquery **/ - public fflib_QueryFactory subselectQuery(Schema.ChildRelationship relationship){ + @NamespaceAccessible + public fflib_QueryFactory subselectQuery(Schema.ChildRelationship relationship){ return subselectQuery(relationship, false); } @@ -491,7 +525,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param relationship The ChildRelationship to be added as a subquery * @param assertIsAccessible indicates whether to check if the user has access to the subquery object **/ - public fflib_QueryFactory subselectQuery(Schema.ChildRelationship relationship, Boolean assertIsAccessible){ + @NamespaceAccessible + public fflib_QueryFactory subselectQuery(Schema.ChildRelationship relationship, Boolean assertIsAccessible){ return setSubselectQuery(relationship, assertIsAccessible); } @@ -524,7 +559,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr /** * @returns the list of subquery instances of fflib_QueryFactory which will be added to the SOQL as relationship/child/sub-queries. **/ - public List getSubselectQueries(){ + @NamespaceAccessible + public List getSubselectQueries(){ if (subselectQueryMap != null) { return subselectQueryMap.values(); } @@ -570,6 +606,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param direction the direction to be sorted on (ASCENDING or DESCENDING) * @param nullsLast whether to sort null values last (NULLS LAST keyword included). **/ + @NamespaceAccessible public fflib_QueryFactory addOrdering(String fieldName, SortOrder direction, Boolean nullsLast){ order.add( new Ordering(getFieldPath(fieldName), direction, nullsLast) @@ -588,6 +625,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param direction the direction to be sorted on (ASCENDING or DESCENDING) * @param nullsLast whether to sort null values last (NULLS LAST keyword included). **/ + @NamespaceAccessible public fflib_QueryFactory addOrdering(SObjectField field, SortOrder direction, Boolean nullsLast){ order.add( new Ordering(getFieldTokenPath(field), direction, nullsLast) @@ -607,6 +645,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fieldName The string value of the field to be sorted on * @param direction the direction to be sorted on (ASCENDING or DESCENDING) **/ + @NamespaceAccessible public fflib_QueryFactory addOrdering(String fieldName, SortOrder direction){ order.add( new Ordering(getFieldPath(fieldName), direction) @@ -626,6 +665,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param field The SObjectField to sort. This can only be a direct reference. * @param direction the direction to be sorted on (ASCENDING or DESCENDING) **/ + @NamespaceAccessible public fflib_QueryFactory addOrdering(SObjectField field, SortOrder direction){ order.add( new Ordering(getFieldTokenPath(field), direction) @@ -644,7 +684,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param direction the direction to be sorted on (ASCENDING or DESCENDING) * @param nullsLast whether to sort null values last (NULLS LAST keyword included). **/ - public fflib_QueryFactory setOrdering(String fieldName, SortOrder direction, Boolean nullsLast){ + @NamespaceAccessible + public fflib_QueryFactory setOrdering(String fieldName, SortOrder direction, Boolean nullsLast){ Ordering ordr = new Ordering(getFieldPath(fieldName), direction, nullsLast); return setOrdering(ordr); } @@ -660,7 +701,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param direction the direction to be sorted on (ASCENDING or DESCENDING) * @param nullsLast whether to sort null values last (NULLS LAST keyword included). **/ - public fflib_QueryFactory setOrdering(SObjectField field, SortOrder direction, Boolean nullsLast){ + @NamespaceAccessible + public fflib_QueryFactory setOrdering(SObjectField field, SortOrder direction, Boolean nullsLast){ Ordering ordr = new Ordering(getFieldTokenPath(field), direction, nullsLast); return setOrdering(ordr); } @@ -675,7 +717,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fieldName The string value of the field to be sorted on * @param direction the direction to be sorted on (ASCENDING or DESCENDING) **/ - public fflib_QueryFactory setOrdering(String fieldName, SortOrder direction){ + @NamespaceAccessible + public fflib_QueryFactory setOrdering(String fieldName, SortOrder direction){ Ordering ordr = new Ordering(getFieldPath(fieldName), direction); return setOrdering(ordr); } @@ -690,7 +733,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param field The SObjectField to sort. This can only be a direct reference. * @param direction the direction to be sorted on (ASCENDING or DESCENDING) **/ - public fflib_QueryFactory setOrdering(SObjectField field, SortOrder direction){ + @NamespaceAccessible + public fflib_QueryFactory setOrdering(SObjectField field, SortOrder direction){ Ordering ordr = new Ordering(getFieldTokenPath(field), direction); return setOrdering(ordr); } @@ -698,7 +742,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr /** * whether an ALL ROWS clause will be added to the resulting query **/ - public fflib_QueryFactory setAllRows(){ + @NamespaceAccessible + public fflib_QueryFactory setAllRows(){ this.allRows = true; return this; } @@ -707,7 +752,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * Convert the values provided to this instance into a full SOQL string for use with Database.query * Check to see if subqueries queries need to be added after the field list. **/ - public String toSOQL(){ + @NamespaceAccessible + public String toSOQL(){ String result = 'SELECT '; //if no fields have been added, just add the Id field so that the query or subquery will not just fail if (fields.size() == 0){ @@ -768,7 +814,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * Create a "deep" clone of this object that can be safely mutated without affecting the cloned instance * @return a deep clone of this fflib_QueryFactory **/ - public fflib_QueryFactory deepClone(){ + @NamespaceAccessible + public fflib_QueryFactory deepClone(){ fflib_QueryFactory clone = new fflib_QueryFactory(this.table) .setLimit(this.limitCount) @@ -792,12 +839,14 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr return clone; } - public class Ordering{ + @NamespaceAccessible + public class Ordering{ private SortOrder direction; private boolean nullsLast; private String field; - public Ordering(String sobjType, String fieldName, SortOrder direction){ + @NamespaceAccessible + public Ordering(String sobjType, String fieldName, SortOrder direction){ this( fflib_SObjectDescribe.getDescribe(sobjType).getField(fieldName), direction @@ -807,10 +856,12 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * Construct a new ordering instance for use with {@link fflib_QueryFactory#addOrdering} * Once constructed it's properties may not be modified. **/ - public Ordering(Schema.SObjectField field, SortOrder direction){ + @NamespaceAccessible + public Ordering(Schema.SObjectField field, SortOrder direction){ this(fflib_QueryFactory.getFieldTokenPath(field), direction, false); //SOQL docs state NULLS FIRST is default behavior } - public Ordering(Schema.SObjectField field, SortOrder direction, Boolean nullsLast){ + @NamespaceAccessible + public Ordering(Schema.SObjectField field, SortOrder direction, Boolean nullsLast){ this(fflib_QueryFactory.getFieldTokenPath(field), direction, nullsLast); } @TestVisible @@ -823,30 +874,38 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr this.field = field; this.nullsLast = nullsLast; } - public String getField(){ + @NamespaceAccessible + public String getField(){ return this.field; } - public SortOrder getDirection(){ + @NamespaceAccessible + public SortOrder getDirection(){ return direction; } - public String toSOQL(){ + @NamespaceAccessible + public String toSOQL(){ return field + ' ' + (direction == SortOrder.ASCENDING ? 'ASC' : 'DESC') + (nullsLast ? ' NULLS LAST ' : ' NULLS FIRST '); } } - public class InvalidFieldException extends Exception{ + @NamespaceAccessible + public class InvalidFieldException extends Exception{ private String fieldName; private Schema.SObjectType objectType; - public InvalidFieldException(String fieldName, Schema.SObjectType objectType){ + @NamespaceAccessible + public InvalidFieldException(String fieldName, Schema.SObjectType objectType){ this.objectType = objectType; this.fieldName = fieldName; this.setMessage( 'Invalid field \''+fieldName+'\' for object \''+objectType+'\'' ); } } - public class InvalidFieldSetException extends Exception{} - public class NonReferenceFieldException extends Exception{} - public class InvalidSubqueryRelationshipException extends Exception{} + @NamespaceAccessible + public class InvalidFieldSetException extends Exception{} + @NamespaceAccessible + public class NonReferenceFieldException extends Exception{} + @NamespaceAccessible + public class InvalidSubqueryRelationshipException extends Exception{} } diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls index 0eac50185f0..627f48b1a85 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls @@ -36,6 +36,7 @@ * This allows both upgrading old code to APIv29 by making use of these as a nearly drop in replacement, as well as keeping * namespace detection logic encapsulated. **/ +@NamespaceAccessible public class fflib_SObjectDescribe { //internal implementation details private Schema.SObjectType token; @@ -85,13 +86,15 @@ public class fflib_SObjectDescribe { /** * Returns the Schema.SObjectType this fflib_SObjectDescribe instance is based on. **/ - public Schema.SObjectType getSObjectType(){ + @NamespaceAccessible + public Schema.SObjectType getSObjectType(){ return token; } /** * This method is a convenient shorthand for calling getField(name, true) **/ - public Schema.SObjectField getField(String name){ + @NamespaceAccessible + public Schema.SObjectField getField(String name){ return this.getField(name, true); } /** @@ -99,7 +102,8 @@ public class fflib_SObjectDescribe { * Additionally it handles finding the correct SObjectField for relationship notation, * e.g. getting the Account field on Contact would fail without being referenced as AccountId - both work here. **/ - public Schema.SObjectField getField(String fieldName, Boolean implyNamespace){ + @NamespaceAccessible + public Schema.SObjectField getField(String fieldName, Boolean implyNamespace){ String fieldNameAdjusted = fieldName; if ( fieldName.endsWithIgnoreCase('__r') ) //resolve custom field cross-object (__r) syntax @@ -121,7 +125,8 @@ public class fflib_SObjectDescribe { /** * Returns the field where isNameField() is true (if any); otherwise returns null **/ - public Schema.SObjectField getNameField() + @NamespaceAccessible + public Schema.SObjectField getNameField() { if(nameField == null) { for(Schema.SObjectField field : wrappedFields.values()) { @@ -137,20 +142,24 @@ public class fflib_SObjectDescribe { /** * Returns the raw Schema.DescribeSObjectResult an fflib_SObjectDescribe instance wraps. **/ - public Schema.DescribeSObjectResult getDescribe(){ + @NamespaceAccessible + public Schema.DescribeSObjectResult getDescribe(){ return describe; } /** * This method returns the raw data and provides no namespace handling. * Due to this, __use of this method is discouraged__ in favor of getFields(). **/ - public Map getFieldsMap(){ + @NamespaceAccessible + public Map getFieldsMap(){ return fields; } - public FieldsMap getFields(){ + @NamespaceAccessible + public FieldsMap getFields(){ return wrappedFields; } - public Map getFieldSetsMap(){ + @NamespaceAccessible + public Map getFieldSetsMap(){ return fieldSets; } @@ -185,7 +194,8 @@ public class fflib_SObjectDescribe { } set; } - public static fflib_SObjectDescribe getDescribe(String sObjectName){ + @NamespaceAccessible + public static fflib_SObjectDescribe getDescribe(String sObjectName){ if(String.isBlank(sObjectName)) return null; fflib_SObjectDescribe result = instanceCache.get(sObjectName.toLowerCase()); @@ -198,7 +208,8 @@ public class fflib_SObjectDescribe { } return result; } - public static fflib_SObjectDescribe getDescribe(Schema.SObjectType token){ + @NamespaceAccessible + public static fflib_SObjectDescribe getDescribe(Schema.SObjectType token){ if(token == null) return null; fflib_SObjectDescribe result = instanceCache.get(String.valueOf(token).toLowerCase()); @@ -206,7 +217,8 @@ public class fflib_SObjectDescribe { result = new fflib_SObjectDescribe(token); return result; } - public static fflib_SObjectDescribe getDescribe(Schema.DescribeSObjectResult nativeDescribe){ + @NamespaceAccessible + public static fflib_SObjectDescribe getDescribe(Schema.DescribeSObjectResult nativeDescribe){ if(nativeDescribe == null) return null; fflib_SObjectDescribe result = instanceCache.get(nativeDescribe.getName().toLowerCase()); @@ -214,22 +226,26 @@ public class fflib_SObjectDescribe { result = new fflib_SObjectDescribe(nativeDescribe.getSObjectType()); return result; } - public static fflib_SObjectDescribe getDescribe(SObject instance){ + @NamespaceAccessible + public static fflib_SObjectDescribe getDescribe(SObject instance){ if(instance == null) return null; return getDescribe(instance.getSObjectType()); } //returns the same results as the native method, just with caching built in to avoid limits - public static Map getRawGlobalDescribe(){ + @NamespaceAccessible + public static Map getRawGlobalDescribe(){ return rawGlobalDescribe; } - public static GlobalDescribeMap getGlobalDescribe(){ + @NamespaceAccessible + public static GlobalDescribeMap getGlobalDescribe(){ return wrappedGlobalDescribe; } //Useful when working in heap space constrained environments. //Existing references to SObjectDescribe instances will continue to work. - public static void flushCache(){ + @NamespaceAccessible + public static void flushCache(){ rawGlobalDescribe = null; instanceCache = null; } @@ -278,10 +294,12 @@ public class fflib_SObjectDescribe { return null; } } - public virtual Boolean containsKey(String name){ + @NamespaceAccessible + public virtual Boolean containsKey(String name){ return this.containsKey(name, true); } - public virtual Boolean containsKey(String name, Boolean implyNamespace){ + @NamespaceAccessible + public virtual Boolean containsKey(String name, Boolean implyNamespace){ if(name == null) //short-circuit lookup logic since null can't possibly be a valid field name, and it saves us null checking return null; String preferredValue = ((implyNamespace ? currentNamespace+'__' : '') + name).toLowerCase(); @@ -290,17 +308,20 @@ public class fflib_SObjectDescribe { implyNamespace && values.containsKey(name.toLowerCase()) ); } - public virtual Integer size(){ + @NamespaceAccessible + public virtual Integer size(){ return values.size(); } /** * Returns the key set of the map. * Note: unlike other NamespacedAttributeMap methods keySet defaults implyNamespace to false if not specified. **/ - public virtual Set keySet(){ + @NamespaceAccessible + public virtual Set keySet(){ return this.keySet(false); } - public virtual Set keySet(Boolean implyNamespace){ + @NamespaceAccessible + public virtual Set keySet(Boolean implyNamespace){ if(implyNamespace){ Set result = new Set(); for(String key:values.keySet()){ @@ -318,20 +339,24 @@ public class fflib_SObjectDescribe { /** * A subclass of NamespacedAttributeMap for handling the data returned by #Schema.DescribeSObjectResult.fields.getMap **/ - public class FieldsMap extends NamespacedAttributeMap{ + @NamespaceAccessible + public class FieldsMap extends NamespacedAttributeMap{ @TestVisible private FieldsMap(Map values){ super(values); } - public Schema.SObjectField get(String name){ + @NamespaceAccessible + public Schema.SObjectField get(String name){ return this.get(name, true); } - public Schema.SObjectField get(String name, Boolean implyNamespace){ + @NamespaceAccessible + public Schema.SObjectField get(String name, Boolean implyNamespace){ return (Schema.SObjectField) this.getObject(name, implyNamespace); } - public List values(){ + @NamespaceAccessible + public List values(){ return (List) values.values(); } @@ -339,25 +364,32 @@ public class fflib_SObjectDescribe { /** * A subclass of NamespacedAttributeMap for handling the data returned by #Schema.getGlobalDescribe **/ - public class GlobalDescribeMap extends NamespacedAttributeMap{ + @NamespaceAccessible + public class GlobalDescribeMap extends NamespacedAttributeMap{ @TestVisible private GlobalDescribeMap(Map values){ super(values); } - public Schema.SObjectType get(String name){ + @NamespaceAccessible + public Schema.SObjectType get(String name){ return this.get(name, true); } - public Schema.SObjectType get(String name, Boolean implyNamespace){ + @NamespaceAccessible + public Schema.SObjectType get(String name, Boolean implyNamespace){ return (Schema.SObjectType) this.getObject(name, implyNamespace); } - public List values(){ + @NamespaceAccessible + public List values(){ return (List) values.values(); } } - public abstract class DescribeException extends Exception{} - public class DuplicateDescribeException extends DescribeException{} //Test coverage for this requires APIv28's @testVisible annotation to force exception cases. - public class InvalidDescribeException extends DescribeException{} + @NamespaceAccessible + public abstract class DescribeException extends Exception{} + @NamespaceAccessible + public class DuplicateDescribeException extends DescribeException{} //Test coverage for this requires APIv28's @testVisible annotation to force exception cases. + @NamespaceAccessible + public class InvalidDescribeException extends DescribeException{} } \ No newline at end of file diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectDomain.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectDomain.cls index bd982249d48..da9fa74bdb7 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectDomain.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectDomain.cls @@ -38,6 +38,7 @@ * http://martinfowler.com/eaaCatalog/domainModel.html * **/ +@NamespaceAccessible public virtual with sharing class fflib_SObjectDomain extends fflib_SObjects implements fflib_ISObjectDomain @@ -45,7 +46,8 @@ public virtual with sharing class fflib_SObjectDomain /** * Provides access to the data represented by this domain class **/ - public List Records { + @NamespaceAccessible + public List Records { get { return getRecords(); @@ -57,6 +59,7 @@ public virtual with sharing class fflib_SObjectDomain * Provides access to Trigger.oldMap and allowing it to be mocked in unit-tests **/ @TestVisible + @NamespaceAccessible protected Map ExistingRecords { get @@ -82,17 +85,20 @@ public virtual with sharing class fflib_SObjectDomain /** * Exposes the configuration for this domain class instance **/ - public Configuration Configuration {get; private set;} + @NamespaceAccessible + public Configuration Configuration {get; private set;} /** * DEPRECATED, This property has been moved to fflib_SObjects **/ - public static fflib_SObjectDomain.ErrorFactory Errors {get; private set;} + @NamespaceAccessible + public static fflib_SObjectDomain.ErrorFactory Errors {get; private set;} /** * Useful during unit testing to access mock support for database inserts and updates (testing without DML) **/ - public static TestFactory Test {get; private set;} + @NamespaceAccessible + public static TestFactory Test {get; private set;} /** * Retains instances of domain classes implementing trigger stateful @@ -121,7 +127,8 @@ public virtual with sharing class fflib_SObjectDomain * @param sObjectList A concrete list (e.g. List vs List) of records **/ - public fflib_SObjectDomain(List sObjectList) + @NamespaceAccessible + public fflib_SObjectDomain(List sObjectList) { this(sObjectList, sObjectList.getSObjectType()); } @@ -135,7 +142,8 @@ public virtual with sharing class fflib_SObjectDomain * @remark Will support List but all records in the list will be assumed to be of * the type specified in sObjectType **/ - public fflib_SObjectDomain(List sObjectList, SObjectType sObjectType) + @NamespaceAccessible + public fflib_SObjectDomain(List sObjectList, SObjectType sObjectType) { // Ensure the domain class has its own copy of the data super(sObjectList, sObjectType); @@ -147,56 +155,67 @@ public virtual with sharing class fflib_SObjectDomain /** * Override this to apply defaults to the records, this is called by the handleBeforeInsert method **/ - public virtual void onApplyDefaults() { } + @NamespaceAccessible + public virtual void onApplyDefaults() { } /** * Override this to apply general validation to be performed during insert or update, called by the handleAfterInsert and handleAfterUpdate methods **/ - public virtual void onValidate() { } + @NamespaceAccessible + public virtual void onValidate() { } /** * Override this to apply validation to be performed during insert, called by the handleAfterUpdate method **/ - public virtual void onValidate(Map existingRecords) { } + @NamespaceAccessible + public virtual void onValidate(Map existingRecords) { } /** * Override this to perform processing during the before insert phase, this is called by the handleBeforeInsert method **/ + @NamespaceAccessible public virtual void onBeforeInsert() { } /** * Override this to perform processing during the before update phase, this is called by the handleBeforeUpdate method **/ + @NamespaceAccessible public virtual void onBeforeUpdate(Map existingRecords) { } /** * Override this to perform processing during the before delete phase, this is called by the handleBeforeDelete method **/ + @NamespaceAccessible public virtual void onBeforeDelete() { } /** * Override this to perform processing during the after insert phase, this is called by the handleAfterInsert method **/ + @NamespaceAccessible public virtual void onAfterInsert() { } /** * Override this to perform processing during the after update phase, this is called by the handleAfterUpdate method **/ + @NamespaceAccessible public virtual void onAfterUpdate(Map existingRecords) { } /** * Override this to perform processing during the after delete phase, this is called by the handleAfterDelete method **/ + @NamespaceAccessible public virtual void onAfterDelete() { } /** * Override this to perform processing during the after undelete phase, this is called by the handleAfterDelete method **/ + @NamespaceAccessible public virtual void onAfterUndelete() { } /** * Base handler for the Apex Trigger event Before Insert, calls the onApplyDefaults method, followed by onBeforeInsert **/ + @NamespaceAccessible public virtual void handleBeforeInsert() { onApplyDefaults(); @@ -206,6 +225,7 @@ public virtual with sharing class fflib_SObjectDomain /** * Base handler for the Apex Trigger event Before Update, calls the onBeforeUpdate method **/ + @NamespaceAccessible public virtual void handleBeforeUpdate(Map existingRecords) { onBeforeUpdate(existingRecords); @@ -214,6 +234,7 @@ public virtual with sharing class fflib_SObjectDomain /** * Base handler for the Apex Trigger event Before Delete, calls the onBeforeDelete method **/ + @NamespaceAccessible public virtual void handleBeforeDelete() { onBeforeDelete(); @@ -224,6 +245,7 @@ public virtual with sharing class fflib_SObjectDomain * * @throws DomainException if the current user context is not able to create records **/ + @NamespaceAccessible public virtual void handleAfterInsert() { if(Configuration.EnforcingTriggerCRUDSecurity && !SObjectDescribe.isCreateable()) @@ -238,6 +260,7 @@ public virtual with sharing class fflib_SObjectDomain * * @throws DomainException if the current user context is not able to update records **/ + @NamespaceAccessible public virtual void handleAfterUpdate(Map existingRecords) { if(Configuration.EnforcingTriggerCRUDSecurity && !SObjectDescribe.isUpdateable()) @@ -254,6 +277,7 @@ public virtual with sharing class fflib_SObjectDomain * * @throws DomainException if the current user context is not able to delete records **/ + @NamespaceAccessible public virtual void handleAfterDelete() { if(Configuration.EnforcingTriggerCRUDSecurity && !SObjectDescribe.isDeletable()) @@ -267,6 +291,7 @@ public virtual with sharing class fflib_SObjectDomain * * @throws DomainException if the current user context is not able to delete records **/ + @NamespaceAccessible public virtual void handleAfterUndelete() { if(Configuration.EnforcingTriggerCRUDSecurity && !SObjectDescribe.isUndeletable()) @@ -278,6 +303,7 @@ public virtual with sharing class fflib_SObjectDomain /** * Returns the SObjectType this Domain class represents **/ + @NamespaceAccessible public SObjectType sObjectType() { return getSObjectType(); @@ -287,7 +313,8 @@ public virtual with sharing class fflib_SObjectDomain * Detects whether any values in context records have changed for given fields as strings * Returns list of SObject records that have changes in the specified fields **/ - public List getChangedRecords(Set fieldNames) + @NamespaceAccessible + public List getChangedRecords(Set fieldNames) { List changedRecords = new List(); for (SObject newRecord : Records) @@ -315,7 +342,8 @@ public virtual with sharing class fflib_SObjectDomain * Detects whether any values in context records have changed for given fields as tokens * Returns list of SObject records that have changes in the specified fields **/ - public List getChangedRecords(Set fieldTokens) + @NamespaceAccessible + public List getChangedRecords(Set fieldTokens) { List changedRecords = new List(); for (SObject newRecord : Records) @@ -341,7 +369,8 @@ public virtual with sharing class fflib_SObjectDomain /** * Interface used to aid the triggerHandler in constructing instances of Domain classes **/ - public interface IConstructable + @NamespaceAccessible + public interface IConstructable { fflib_SObjectDomain construct(List sObjectList); } @@ -349,7 +378,8 @@ public virtual with sharing class fflib_SObjectDomain /** * Interface used to aid the triggerHandler in constructing instances of Domain classes **/ - public interface IConstructable2 extends IConstructable + @NamespaceAccessible + public interface IConstructable2 extends IConstructable { fflib_SObjectDomain construct(List sObjectList, SObjectType sObjectType); } @@ -361,7 +391,8 @@ public virtual with sharing class fflib_SObjectDomain * the ITriggerStateful interface. Note this method is sensitive to recursion, meaning * it will return the applicable domain instance for the level of recursion **/ - public static fflib_SObjectDomain getTriggerInstance(Type domainClass) + @NamespaceAccessible + public static fflib_SObjectDomain getTriggerInstance(Type domainClass) { List domains = TriggerStateByClass.get(domainClass); if(domains==null || domains.size()==0) @@ -373,7 +404,8 @@ public virtual with sharing class fflib_SObjectDomain * Method constructs the given Domain class with the current Trigger context * before calling the applicable override methods such as beforeInsert, beforeUpdate etc. **/ - public static void triggerHandler(Type domainClass) + @NamespaceAccessible + public static void triggerHandler(Type domainClass) { // Process the trigger context if(System.Test.isRunningTest() & Test.Database.hasRecords()) @@ -469,7 +501,8 @@ public virtual with sharing class fflib_SObjectDomain return domain; } - public static TriggerEvent getTriggerEvent(Type domainClass) + @NamespaceAccessible + public static TriggerEvent getTriggerEvent(Type domainClass) { if(!TriggerEventByClass.containsKey(domainClass)) { @@ -479,74 +512,104 @@ public virtual with sharing class fflib_SObjectDomain return TriggerEventByClass.get(domainClass); } - public class TriggerEvent + @NamespaceAccessible + public class TriggerEvent { - public boolean BeforeInsertEnabled {get; private set;} - public boolean BeforeUpdateEnabled {get; private set;} - public boolean BeforeDeleteEnabled {get; private set;} - - public boolean AfterInsertEnabled {get; private set;} - public boolean AfterUpdateEnabled {get; private set;} - public boolean AfterDeleteEnabled {get; private set;} - public boolean AfterUndeleteEnabled {get; private set;} - - public TriggerEvent() + @NamespaceAccessible + public boolean BeforeInsertEnabled {get; private set;} + @NamespaceAccessible + public boolean BeforeUpdateEnabled {get; private set;} + @NamespaceAccessible + public boolean BeforeDeleteEnabled {get; private set;} + + @NamespaceAccessible + public boolean AfterInsertEnabled {get; private set;} + @NamespaceAccessible + public boolean AfterUpdateEnabled {get; private set;} + @NamespaceAccessible + public boolean AfterDeleteEnabled {get; private set;} + @NamespaceAccessible + public boolean AfterUndeleteEnabled {get; private set;} + + @NamespaceAccessible + public TriggerEvent() { this.enableAll(); } // befores - public TriggerEvent enableBeforeInsert() {BeforeInsertEnabled = true; return this;} - public TriggerEvent enableBeforeUpdate() {BeforeUpdateEnabled = true; return this;} - public TriggerEvent enableBeforeDelete() {BeforeDeleteEnabled = true; return this;} - - public TriggerEvent disableBeforeInsert() {BeforeInsertEnabled = false; return this;} - public TriggerEvent disableBeforeUpdate() {BeforeUpdateEnabled = false; return this;} - public TriggerEvent disableBeforeDelete() {BeforeDeleteEnabled = false; return this;} + @NamespaceAccessible + public TriggerEvent enableBeforeInsert() {BeforeInsertEnabled = true; return this;} + @NamespaceAccessible + public TriggerEvent enableBeforeUpdate() {BeforeUpdateEnabled = true; return this;} + @NamespaceAccessible + public TriggerEvent enableBeforeDelete() {BeforeDeleteEnabled = true; return this;} + + @NamespaceAccessible + public TriggerEvent disableBeforeInsert() {BeforeInsertEnabled = false; return this;} + @NamespaceAccessible + public TriggerEvent disableBeforeUpdate() {BeforeUpdateEnabled = false; return this;} + @NamespaceAccessible + public TriggerEvent disableBeforeDelete() {BeforeDeleteEnabled = false; return this;} // afters - public TriggerEvent enableAfterInsert() {AfterInsertEnabled = true; return this;} - public TriggerEvent enableAfterUpdate() {AfterUpdateEnabled = true; return this;} - public TriggerEvent enableAfterDelete() {AfterDeleteEnabled = true; return this;} - public TriggerEvent enableAfterUndelete() {AfterUndeleteEnabled = true; return this;} + @NamespaceAccessible + public TriggerEvent enableAfterInsert() {AfterInsertEnabled = true; return this;} + @NamespaceAccessible + public TriggerEvent enableAfterUpdate() {AfterUpdateEnabled = true; return this;} + @NamespaceAccessible + public TriggerEvent enableAfterDelete() {AfterDeleteEnabled = true; return this;} + @NamespaceAccessible + public TriggerEvent enableAfterUndelete() {AfterUndeleteEnabled = true; return this;} - public TriggerEvent disableAfterInsert() {AfterInsertEnabled = false; return this;} - public TriggerEvent disableAfterUpdate() {AfterUpdateEnabled = false; return this;} - public TriggerEvent disableAfterDelete() {AfterDeleteEnabled = false; return this;} - public TriggerEvent disableAfterUndelete(){AfterUndeleteEnabled = false; return this;} - - public TriggerEvent enableAll() + @NamespaceAccessible + public TriggerEvent disableAfterInsert() {AfterInsertEnabled = false; return this;} + @NamespaceAccessible + public TriggerEvent disableAfterUpdate() {AfterUpdateEnabled = false; return this;} + @NamespaceAccessible + public TriggerEvent disableAfterDelete() {AfterDeleteEnabled = false; return this;} + @NamespaceAccessible + public TriggerEvent disableAfterUndelete(){AfterUndeleteEnabled = false; return this;} + + @NamespaceAccessible + public TriggerEvent enableAll() { return this.enableAllBefore().enableAllAfter(); } - public TriggerEvent disableAll() + @NamespaceAccessible + public TriggerEvent disableAll() { return this.disableAllBefore().disableAllAfter(); } - public TriggerEvent enableAllBefore() + @NamespaceAccessible + public TriggerEvent enableAllBefore() { return this.enableBeforeInsert().enableBeforeUpdate().enableBeforeDelete(); } - public TriggerEvent disableAllBefore() + @NamespaceAccessible + public TriggerEvent disableAllBefore() { return this.disableBeforeInsert().disableBeforeUpdate().disableBeforeDelete(); } - public TriggerEvent enableAllAfter() + @NamespaceAccessible + public TriggerEvent enableAllAfter() { return this.enableAfterInsert().enableAfterUpdate().enableAfterDelete().enableAfterUndelete(); } - public TriggerEvent disableAllAfter() + @NamespaceAccessible + public TriggerEvent disableAllAfter() { return this.disableAfterInsert().disableAfterUpdate().disableAfterDelete().disableAfterUndelete(); } - public boolean isEnabled(Boolean isBefore, Boolean isAfter, Boolean isInsert, Boolean isUpdate, Boolean isDelete, Boolean isUndelete) + @NamespaceAccessible + public boolean isEnabled(Boolean isBefore, Boolean isAfter, Boolean isInsert, Boolean isUpdate, Boolean isDelete, Boolean isUndelete) { if(isBefore) { @@ -568,26 +631,31 @@ public virtual with sharing class fflib_SObjectDomain /** * Fluent style Configuration system for Domain class creation **/ - public class Configuration + @NamespaceAccessible + public class Configuration { /** * Backwards compatibility mode for handleAfterUpdate routing to onValidate() **/ - public Boolean OldOnUpdateValidateBehaviour {get; private set;} + @NamespaceAccessible + public Boolean OldOnUpdateValidateBehaviour {get; private set;} /** * True if the base class is checking the users CRUD requirements before invoking trigger methods **/ - public Boolean EnforcingTriggerCRUDSecurity {get; private set;} + @NamespaceAccessible + public Boolean EnforcingTriggerCRUDSecurity {get; private set;} /** * Enables reuse of the same Domain instance between before and after trigger phases (subject to recursive scenarios) **/ - public Boolean TriggerStateEnabled {get; private set;} + @NamespaceAccessible + public Boolean TriggerStateEnabled {get; private set;} /** * Default configuration **/ - public Configuration() + @NamespaceAccessible + public Configuration() { EnforcingTriggerCRUDSecurity = true; // Default is true for backwards compatability TriggerStateEnabled = false; @@ -597,7 +665,8 @@ public virtual with sharing class fflib_SObjectDomain /** * See associated property **/ - public Configuration enableTriggerState() + @NamespaceAccessible + public Configuration enableTriggerState() { TriggerStateEnabled = true; return this; @@ -606,7 +675,8 @@ public virtual with sharing class fflib_SObjectDomain /** * See associated property **/ - public Configuration disableTriggerState() + @NamespaceAccessible + public Configuration disableTriggerState() { TriggerStateEnabled = false; return this; @@ -615,7 +685,8 @@ public virtual with sharing class fflib_SObjectDomain /** * See associated property **/ - public Configuration enforceTriggerCRUDSecurity() + @NamespaceAccessible + public Configuration enforceTriggerCRUDSecurity() { EnforcingTriggerCRUDSecurity = true; return this; @@ -624,7 +695,8 @@ public virtual with sharing class fflib_SObjectDomain /** * See associated property **/ - public Configuration disableTriggerCRUDSecurity() + @NamespaceAccessible + public Configuration disableTriggerCRUDSecurity() { EnforcingTriggerCRUDSecurity = false; return this; @@ -633,7 +705,8 @@ public virtual with sharing class fflib_SObjectDomain /** * See associated property **/ - public Configuration enableOldOnUpdateValidateBehaviour() + @NamespaceAccessible + public Configuration enableOldOnUpdateValidateBehaviour() { OldOnUpdateValidateBehaviour = true; return this; @@ -642,7 +715,8 @@ public virtual with sharing class fflib_SObjectDomain /** * See associated property **/ - public Configuration disableOldOnUpdateValidateBehaviour() + @NamespaceAccessible + public Configuration disableOldOnUpdateValidateBehaviour() { OldOnUpdateValidateBehaviour = false; return this; @@ -652,14 +726,16 @@ public virtual with sharing class fflib_SObjectDomain /** * General exception class for the domain layer **/ - public class DomainException extends Exception + @NamespaceAccessible + public class DomainException extends Exception { } /** * Ensures logging of errors in the Domain context for later assertions in tests **/ - public override String error(String message, SObject record) + @NamespaceAccessible + public override String error(String message, SObject record) { return fflib_SObjectDomain.Errors.error(this, message, record); } @@ -667,7 +743,8 @@ public virtual with sharing class fflib_SObjectDomain /** * Ensures logging of errors in the Domain context for later assertions in tests **/ - public override String error(String message, SObject record, SObjectField field) + @NamespaceAccessible + public override String error(String message, SObject record, SObjectField field) { return fflib_SObjectDomain.Errors.error(this, message, record, field); } @@ -675,7 +752,8 @@ public virtual with sharing class fflib_SObjectDomain /** * DEPRECATED, This class has been moved to fflib_SObjects **/ - public class ErrorFactory + @NamespaceAccessible + public class ErrorFactory { private List errorList = new List(); @@ -684,7 +762,8 @@ public virtual with sharing class fflib_SObjectDomain } - public String error(String message, SObject record) + @NamespaceAccessible + public String error(String message, SObject record) { return error(null, message, record); } @@ -699,7 +778,8 @@ public virtual with sharing class fflib_SObjectDomain return message; } - public String error(String message, SObject record, SObjectField field) + @NamespaceAccessible + public String error(String message, SObject record, SObjectField field) { return error(null, message, record, field); } @@ -715,12 +795,14 @@ public virtual with sharing class fflib_SObjectDomain return message; } - public List getAll() + @NamespaceAccessible + public List getAll() { return errorList.clone(); } - public void clearAll() + @NamespaceAccessible + public void clearAll() { errorList.clear(); } @@ -729,11 +811,14 @@ public virtual with sharing class fflib_SObjectDomain /** * DEPRECATED, This class has been moved to fflib_SObjects **/ - public virtual class FieldError extends ObjectError + @NamespaceAccessible + public virtual class FieldError extends ObjectError { - public SObjectField field; + @NamespaceAccessible + public SObjectField field; - public FieldError() + @NamespaceAccessible + public FieldError() { } @@ -742,11 +827,14 @@ public virtual with sharing class fflib_SObjectDomain /** * DEPRECATED, This class has been moved to fflib_SObjects **/ - public virtual class ObjectError extends Error + @NamespaceAccessible + public virtual class ObjectError extends Error { - public SObject record; + @NamespaceAccessible + public SObject record; - public ObjectError() + @NamespaceAccessible + public ObjectError() { } @@ -755,18 +843,23 @@ public virtual with sharing class fflib_SObjectDomain /** * DEPRECATED, This class has been moved to fflib_SObjects **/ - public abstract class Error + @NamespaceAccessible + public abstract class Error { - public String message; - public fflib_SObjectDomain domain; + @NamespaceAccessible + public String message; + @NamespaceAccessible + public fflib_SObjectDomain domain; } /** * Provides test context mocking facilities to unit tests testing domain classes **/ - public class TestFactory + @NamespaceAccessible + public class TestFactory { - public MockDatabase Database = new MockDatabase(); + @NamespaceAccessible + public MockDatabase Database = new MockDatabase(); private TestFactory() { @@ -777,7 +870,8 @@ public virtual with sharing class fflib_SObjectDomain /** * Class used during Unit testing of Domain classes, can be used (not exclusively) to speed up test execution and focus testing **/ - public class MockDatabase + @NamespaceAccessible + public class MockDatabase { private Boolean isInsert = false; private Boolean isUpdate = false; @@ -800,7 +894,8 @@ public virtual with sharing class fflib_SObjectDomain triggerHandler(domainClass, false, true, isInsert, isUpdate, isDelete, isUndelete, records, oldRecords); } - public void onInsert(List records) + @NamespaceAccessible + public void onInsert(List records) { this.isInsert = true; this.isUpdate = false; @@ -809,7 +904,8 @@ public virtual with sharing class fflib_SObjectDomain this.records = records; } - public void onUpdate(List records, Map oldRecords) + @NamespaceAccessible + public void onUpdate(List records, Map oldRecords) { this.isInsert = false; this.isUpdate = true; @@ -819,7 +915,8 @@ public virtual with sharing class fflib_SObjectDomain this.oldRecords = oldRecords; } - public void onDelete(Map records) + @NamespaceAccessible + public void onDelete(Map records) { this.isInsert = false; this.isUpdate = false; @@ -828,7 +925,8 @@ public virtual with sharing class fflib_SObjectDomain this.oldRecords = records; } - public void onUndelete(List records) + @NamespaceAccessible + public void onUndelete(List records) { this.isInsert = false; this.isUpdate = false; @@ -837,7 +935,8 @@ public virtual with sharing class fflib_SObjectDomain this.records = records; } - public Boolean hasRecords() + @NamespaceAccessible + public Boolean hasRecords() { return records!=null && records.size()>0 || oldRecords!=null && oldRecords.size()>0; } @@ -846,23 +945,27 @@ public virtual with sharing class fflib_SObjectDomain /** * Test domain class (ideally this would be in the test class, however Type.newInstance does not see such classes) **/ - public with sharing class TestSObjectDomain extends fflib_SObjectDomain + @NamespaceAccessible + public with sharing class TestSObjectDomain extends fflib_SObjectDomain { private String someState; - public TestSObjectDomain(List sObjectList) + @NamespaceAccessible + public TestSObjectDomain(List sObjectList) { // Domain classes are initialised with lists to enforce bulkification throughout super(sObjectList); } - public TestSObjectDomain(List sObjectList, SObjectType sObjectType) + @NamespaceAccessible + public TestSObjectDomain(List sObjectList, SObjectType sObjectType) { // Domain classes are initialised with lists to enforce bulkification throughout super(sObjectList, sObjectType); } - public override void onApplyDefaults() + @NamespaceAccessible + public override void onApplyDefaults() { // Not required in production code super.onApplyDefaults(); @@ -874,7 +977,8 @@ public virtual with sharing class fflib_SObjectDomain } } - public override void onValidate() + @NamespaceAccessible + public override void onValidate() { // Not required in production code super.onValidate(); @@ -889,7 +993,8 @@ public virtual with sharing class fflib_SObjectDomain } } - public override void onValidate(Map existingRecords) + @NamespaceAccessible + public override void onValidate(Map existingRecords) { // Not required in production code super.onValidate(existingRecords); @@ -905,7 +1010,8 @@ public virtual with sharing class fflib_SObjectDomain } } - public override void onBeforeDelete() + @NamespaceAccessible + public override void onBeforeDelete() { // Not required in production code super.onBeforeDelete(); @@ -917,19 +1023,22 @@ public virtual with sharing class fflib_SObjectDomain } } - public override void onAfterUndelete() + @NamespaceAccessible + public override void onAfterUndelete() { // Not required in production code super.onAfterUndelete(); } - public override void onBeforeInsert() + @NamespaceAccessible + public override void onBeforeInsert() { // Assert this variable is null in the after insert (since this domain class is stateless) someState = 'This should not survice the trigger after phase'; } - public override void onAfterInsert() + @NamespaceAccessible + public override void onAfterInsert() { // This is a stateless domain class, so should not retain anything betweet before and after System.assertEquals(null, someState); @@ -939,9 +1048,11 @@ public virtual with sharing class fflib_SObjectDomain /** * Typically an inner class to the domain class, supported here for test purposes **/ - public class TestSObjectDomainConstructor implements fflib_SObjectDomain.IConstructable + @NamespaceAccessible + public class TestSObjectDomainConstructor implements fflib_SObjectDomain.IConstructable { - public fflib_SObjectDomain construct(List sObjectList) + @NamespaceAccessible + public fflib_SObjectDomain construct(List sObjectList) { return new TestSObjectDomain(sObjectList); } @@ -950,12 +1061,15 @@ public virtual with sharing class fflib_SObjectDomain /** * Test domain class (ideally this would be in the test class, however Type.newInstance does not see such classes) **/ - public with sharing class TestSObjectStatefulDomain + @NamespaceAccessible + public with sharing class TestSObjectStatefulDomain extends fflib_SObjectDomain { - public String someState; + @NamespaceAccessible + public String someState; - public TestSObjectStatefulDomain(List sObjectList) + @NamespaceAccessible + public TestSObjectStatefulDomain(List sObjectList) { super(sObjectList); @@ -963,7 +1077,8 @@ public virtual with sharing class fflib_SObjectDomain Configuration.enableTriggerState(); } - public override void onBeforeInsert() + @NamespaceAccessible + public override void onBeforeInsert() { // This must always be null, as we do not reuse domain instances within recursive scenarios (different record sets) System.assertEquals(null, someState); @@ -989,7 +1104,8 @@ public virtual with sharing class fflib_SObjectDomain } } - public override void onAfterInsert() + @NamespaceAccessible + public override void onAfterInsert() { // Use the state set in the before insert (since this is a stateful domain class) if(someState!=null) @@ -1001,9 +1117,11 @@ public virtual with sharing class fflib_SObjectDomain /** * Typically an inner class to the domain class, supported here for test purposes **/ - public class TestSObjectStatefulDomainConstructor implements fflib_SObjectDomain.IConstructable + @NamespaceAccessible + public class TestSObjectStatefulDomainConstructor implements fflib_SObjectDomain.IConstructable { - public fflib_SObjectDomain construct(List sObjectList) + @NamespaceAccessible + public fflib_SObjectDomain construct(List sObjectList) { return new TestSObjectStatefulDomain(sObjectList); } @@ -1012,10 +1130,12 @@ public virtual with sharing class fflib_SObjectDomain /** * Test domain class (ideally this would be in the test class, however Type.newInstance does not see such classes) **/ - public with sharing class TestSObjectOnValidateBehaviour + @NamespaceAccessible + public with sharing class TestSObjectOnValidateBehaviour extends fflib_SObjectDomain { - public TestSObjectOnValidateBehaviour(List sObjectList) + @NamespaceAccessible + public TestSObjectOnValidateBehaviour(List sObjectList) { super(sObjectList); @@ -1024,7 +1144,8 @@ public virtual with sharing class fflib_SObjectDomain Configuration.enableOldOnUpdateValidateBehaviour(); } - public override void onValidate() + @NamespaceAccessible + public override void onValidate() { // Throw exception to give the test somethign to assert on throw new DomainException('onValidate called'); @@ -1034,9 +1155,11 @@ public virtual with sharing class fflib_SObjectDomain /** * Typically an inner class to the domain class, supported here for test purposes **/ - public class TestSObjectOnValidateBehaviourConstructor implements fflib_SObjectDomain.IConstructable + @NamespaceAccessible + public class TestSObjectOnValidateBehaviourConstructor implements fflib_SObjectDomain.IConstructable { - public fflib_SObjectDomain construct(List sObjectList) + @NamespaceAccessible + public fflib_SObjectDomain construct(List sObjectList) { return new TestSObjectOnValidateBehaviour(sObjectList); } @@ -1045,10 +1168,12 @@ public virtual with sharing class fflib_SObjectDomain /** * Test domain class (ideally this would be in the test class, however Type.newInstance does not see such classes) **/ - public with sharing class TestSObjectChangedRecords + @NamespaceAccessible + public with sharing class TestSObjectChangedRecords extends fflib_SObjectDomain { - public TestSObjectChangedRecords(List sObjectList) + @NamespaceAccessible + public TestSObjectChangedRecords(List sObjectList) { super(sObjectList); } @@ -1057,9 +1182,11 @@ public virtual with sharing class fflib_SObjectDomain /** * Typically an inner class to the domain class, supported here for test purposes **/ - public class TestSObjectChangedRecordsConstructor implements fflib_SObjectDomain.IConstructable + @NamespaceAccessible + public class TestSObjectChangedRecordsConstructor implements fflib_SObjectDomain.IConstructable { - public fflib_SObjectDomain construct(List sObjectList) + @NamespaceAccessible + public fflib_SObjectDomain construct(List sObjectList) { return new TestSObjectChangedRecords(sObjectList); } @@ -1068,45 +1195,54 @@ public virtual with sharing class fflib_SObjectDomain /** * Test domain class (ideally this would be in the test class, however Type.newInstance does not see such classes) **/ - public with sharing class TestSObjectDisableBehaviour + @NamespaceAccessible + public with sharing class TestSObjectDisableBehaviour extends fflib_SObjectDomain { - public TestSObjectDisableBehaviour(List sObjectList) + @NamespaceAccessible + public TestSObjectDisableBehaviour(List sObjectList) { super(sObjectList); } - public override void onAfterInsert() { + @NamespaceAccessible + public override void onAfterInsert() { // Throw exception to give the test somethign to assert on throw new DomainException('onAfterInsert called'); } - public override void onBeforeInsert() { + @NamespaceAccessible + public override void onBeforeInsert() { // Throw exception to give the test somethign to assert on throw new DomainException('onBeforeInsert called'); } - public override void onAfterUpdate(map existing) { + @NamespaceAccessible + public override void onAfterUpdate(map existing) { // Throw exception to give the test somethign to assert on throw new DomainException('onAfterUpdate called'); } - public override void onBeforeUpdate(map existing) { + @NamespaceAccessible + public override void onBeforeUpdate(map existing) { // Throw exception to give the test somethign to assert on throw new DomainException('onBeforeUpdate called'); } - public override void onAfterDelete() { + @NamespaceAccessible + public override void onAfterDelete() { // Throw exception to give the test somethign to assert on throw new DomainException('onAfterDelete called'); } - public override void onBeforeDelete() { + @NamespaceAccessible + public override void onBeforeDelete() { // Throw exception to give the test somethign to assert on throw new DomainException('onBeforeDelete called'); } - public override void onAfterUndelete() { + @NamespaceAccessible + public override void onAfterUndelete() { // Throw exception to give the test somethign to assert on throw new DomainException('onAfterUndelete called'); } @@ -1115,9 +1251,11 @@ public virtual with sharing class fflib_SObjectDomain /** * Typically an inner class to the domain class, supported here for test purposes **/ - public class TestSObjectDisableBehaviourConstructor implements fflib_SObjectDomain.IConstructable + @NamespaceAccessible + public class TestSObjectDisableBehaviourConstructor implements fflib_SObjectDomain.IConstructable { - public fflib_SObjectDomain construct(List sObjectList) + @NamespaceAccessible + public fflib_SObjectDomain construct(List sObjectList) { return new TestSObjectDisableBehaviour(sObjectList); } diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectSelector.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectSelector.cls index 3abbdc4e380..a5109ace4bc 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectSelector.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectSelector.cls @@ -27,10 +27,12 @@ /** * Class providing common database query support for abstracting and encapsulating query logic **/ -public abstract with sharing class fflib_SObjectSelector +@NamespaceAccessible + public abstract with sharing class fflib_SObjectSelector implements fflib_ISObjectSelector { - public enum DataAccess{LEGACY, USER_MODE, SYSTEM_MODE} + @NamespaceAccessible + public enum DataAccess{LEGACY, USER_MODE, SYSTEM_MODE} /** * Indicates whether the sObject has the currency ISO code field for organisations which have multi-currency @@ -104,19 +106,22 @@ public abstract with sharing class fflib_SObjectSelector /** * Constructs the Selector with the default settings **/ - public fflib_SObjectSelector() { } + @NamespaceAccessible + public fflib_SObjectSelector() { } /** * Constructs the Selector * * @param includeFieldSetFields Set to true if the Selector queries are to include Fieldset fields as well **/ - public fflib_SObjectSelector(Boolean includeFieldSetFields) + @NamespaceAccessible + public fflib_SObjectSelector(Boolean includeFieldSetFields) { this(includeFieldSetFields, true, false); } - public fflib_SObjectSelector(Boolean includeFieldSetFields, DataAccess dataAccess) + @NamespaceAccessible + public fflib_SObjectSelector(Boolean includeFieldSetFields, DataAccess dataAccess) { this(includeFieldSetFields, false, false, false, dataAccess); } @@ -127,7 +132,8 @@ public abstract with sharing class fflib_SObjectSelector * @param includeFieldSetFields Set to true if the Selector queries are to include Fieldset fields as well * @deprecated - consider using dataAccess for native platform enforcement of CRUD and FLS **/ - public fflib_SObjectSelector(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS) + @NamespaceAccessible + public fflib_SObjectSelector(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS) { this(includeFieldSetFields, enforceCRUD, enforceFLS, true); } @@ -141,7 +147,8 @@ public abstract with sharing class fflib_SObjectSelector * @param sortSelectFields Set to false if selecting many columns to skip sorting select fields and improve performance * @deprecated - consider using dataAccess for native platform enforcement of CRUD and FLS **/ - public fflib_SObjectSelector(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS, Boolean sortSelectFields) + @NamespaceAccessible + public fflib_SObjectSelector(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS, Boolean sortSelectFields) { this(includeFieldSetFields,enforceCRUD,enforceFLS,sortSelectFields,DataAccess.LEGACY); } @@ -159,7 +166,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Override this method to provide a list of Fieldsets that can optionally drive inclusion of additional fields in the base queries **/ - public virtual List getSObjectFieldSetList() + @NamespaceAccessible + public virtual List getSObjectFieldSetList() { return null; } @@ -168,7 +176,8 @@ public abstract with sharing class fflib_SObjectSelector * Override this method to control the default ordering of records returned by the base queries, * defaults to the name field of the object if it is not encrypted or CreatedDate if there the object has createdDated or Id **/ - public virtual String getOrderBy() + @NamespaceAccessible + public virtual String getOrderBy() { if (m_orderBy == null) { @@ -199,7 +208,8 @@ public abstract with sharing class fflib_SObjectSelector * @description Set the selector to enforce FLS Security * @deprecated -- consider using setDataAccess to enforce native Apex User Mode Operations instead **/ - public fflib_SObjectSelector enforceFLS() + @NamespaceAccessible + public fflib_SObjectSelector enforceFLS() { m_enforceFLS = true; return this; @@ -208,7 +218,8 @@ public abstract with sharing class fflib_SObjectSelector /** * @description Set the selector to automatically include the FieldSet fields when building queries **/ - public fflib_SObjectSelector includeFieldSetFields() + @NamespaceAccessible + public fflib_SObjectSelector includeFieldSetFields() { this.m_includeFieldSetFields = true; return this; @@ -218,19 +229,22 @@ public abstract with sharing class fflib_SObjectSelector * @description Set the selector to ignore CRUD security * @return */ - public fflib_SObjectSelector ignoreCRUD() + @NamespaceAccessible + public fflib_SObjectSelector ignoreCRUD() { this.m_enforceCRUD = false; return this; } - public fflib_SObjectSelector unsortedSelectFields() + @NamespaceAccessible + public fflib_SObjectSelector unsortedSelectFields() { this.m_sortSelectFields = false; return this; } - public fflib_SObjectSelector setDataAccess(DataAccess access){ + @NamespaceAccessible + public fflib_SObjectSelector setDataAccess(DataAccess access){ this.m_dataAccess = access; //You can't mix and match the legacy enforceFls and assertCRUD with the SYSTEM_MODE or USER_MODE @@ -245,7 +259,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Returns True if this Selector instance has been instructed by the caller to include Field Set fields **/ - public Boolean isIncludeFieldSetFields() + @NamespaceAccessible + public Boolean isIncludeFieldSetFields() { return m_includeFieldSetFields; } @@ -253,7 +268,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Returns True if this Selector is enforcing FLS **/ - public Boolean isEnforcingFLS() + @NamespaceAccessible + public Boolean isEnforcingFLS() { return m_enforceFLS; } @@ -261,12 +277,14 @@ public abstract with sharing class fflib_SObjectSelector /** * Returns True if this Selector is enforcing CRUD Security **/ - public Boolean isEnforcingCRUD() + @NamespaceAccessible + public Boolean isEnforcingCRUD() { return m_enforceCRUD; } - public DataAccess getDataAccess(){ + @NamespaceAccessible + public DataAccess getDataAccess(){ return m_dataAccess; } @@ -276,7 +294,8 @@ public abstract with sharing class fflib_SObjectSelector * * @depricated See newQueryFactory **/ - public fflib_StringBuilder.CommaDelimitedListBuilder getFieldListBuilder() + @NamespaceAccessible + public fflib_StringBuilder.CommaDelimitedListBuilder getFieldListBuilder() { return new fflib_StringBuilder.CommaDelimitedListBuilder( @@ -289,7 +308,8 @@ public abstract with sharing class fflib_SObjectSelector * * @depricated See newQueryFactory **/ - public void setFieldListBuilder(fflib_StringBuilder.FieldListBuilder fieldListBuilder) + @NamespaceAccessible + public void setFieldListBuilder(fflib_StringBuilder.FieldListBuilder fieldListBuilder) { // TODO: Consider if given the known use cases for this (dynamic selector optimisation) if it's OK to leave this as a null operation } @@ -299,7 +319,8 @@ public abstract with sharing class fflib_SObjectSelector * * @deprecated See newQueryFactory **/ - public String getFieldListString() + @NamespaceAccessible + public String getFieldListString() { return getFieldListBuilder().getStringValue(); } @@ -310,7 +331,8 @@ public abstract with sharing class fflib_SObjectSelector * * @depricated See newQueryFactory **/ - public String getRelatedFieldListString(String relation) + @NamespaceAccessible + public String getRelatedFieldListString(String relation) { return getFieldListBuilder().getStringValue(relation + '.'); } @@ -318,7 +340,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Returns the string representation of the SObject this selector represents **/ - public String getSObjectName() + @NamespaceAccessible + public String getSObjectName() { return describeWrapper.getDescribe().getName(); } @@ -331,7 +354,8 @@ public abstract with sharing class fflib_SObjectSelector * - Ordered by the fields returned via getOrderBy * @returns A list of SObject's **/ - public virtual List selectSObjectsById(Set idSet) + @NamespaceAccessible + public virtual List selectSObjectsById(Set idSet) { return Database.query(buildQuerySObjectById()); } @@ -344,7 +368,8 @@ public abstract with sharing class fflib_SObjectSelector * - Ordered by the fields returned via getOrderBy * @returns A QueryLocator (typically for use in a Batch Apex job) **/ - public virtual Database.QueryLocator queryLocatorById(Set idSet) + @NamespaceAccessible + public virtual Database.QueryLocator queryLocatorById(Set idSet) { return Database.getQueryLocator(buildQuerySObjectById()); } @@ -354,7 +379,8 @@ public abstract with sharing class fflib_SObjectSelector * * @deprecated If you utilise the newQueryFactory method this is automatically done for you (unless disabled by the selector) **/ - public void assertIsAccessible() + @NamespaceAccessible + public void assertIsAccessible() { if(!getSObjectType().getDescribe().isAccessible()) throw new fflib_SObjectDomain.DomainException( @@ -362,19 +388,25 @@ public abstract with sharing class fflib_SObjectSelector } /** - * Public access for the getSObjectType during Mock registration - * (adding public to the existing method broken base class API backwards compatibility) + * @NamespaceAccessible + public access for the getSObjectType during Mock registration + * (adding @NamespaceAccessible + public to the existing method broken base class API backwards compatibility) **/ - public SObjectType getSObjectType2() + @NamespaceAccessible + public SObjectType getSObjectType2() { return getSObjectType(); } /** - * Public access for the getSObjectType during Mock registration - * (adding public to the existing method broken base class API backwards compatibility1) + * @NamespaceAccessible + public access for the getSObjectType during Mock registration + * (adding @NamespaceAccessible + public to the existing method broken base class API backwards compatibility1) **/ - public SObjectType sObjectType() + @NamespaceAccessible + public SObjectType sObjectType() { return getSObjectType(); } @@ -382,7 +414,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Returns a QueryFactory configured with the Selectors object, fields, fieldsets and default order by **/ - public fflib_QueryFactory newQueryFactory() + @NamespaceAccessible + public fflib_QueryFactory newQueryFactory() { return newQueryFactory(m_enforceCRUD, m_enforceFLS, true, m_DataAccess); } @@ -390,7 +423,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Returns a QueryFactory configured with the Selectors object, fields, fieldsets and default order by **/ - public fflib_QueryFactory newQueryFactory(Boolean includeSelectorFields) + @NamespaceAccessible + public fflib_QueryFactory newQueryFactory(Boolean includeSelectorFields) { return newQueryFactory(m_enforceCRUD, m_enforceFLS, includeSelectorFields, m_DataAccess); } @@ -399,7 +433,8 @@ public abstract with sharing class fflib_SObjectSelector * Returns a QueryFactory configured with the Selectors object, fields, fieldsets and default order by * CRUD and FLS read security will be checked if the corresponding inputs are true (overrides that defined in the selector). **/ - public fflib_QueryFactory newQueryFactory(Boolean assertCRUD, Boolean enforceFLS, Boolean includeSelectorFields) + @NamespaceAccessible + public fflib_QueryFactory newQueryFactory(Boolean assertCRUD, Boolean enforceFLS, Boolean includeSelectorFields) { // Construct QueryFactory around the given SObject return newQueryFactory( @@ -425,7 +460,8 @@ public abstract with sharing class fflib_SObjectSelector * * // TODO: This should be consistent (ideally) with configureQueryFactory below **/ - public void configureQueryFactoryFields(fflib_QueryFactory queryFactory, String relationshipFieldPath) + @NamespaceAccessible + public void configureQueryFactoryFields(fflib_QueryFactory queryFactory, String relationshipFieldPath) { // Add fields from selector prefixing the relationship path for(SObjectField field : getSObjectFieldList()) { @@ -440,7 +476,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Adds a subselect QueryFactory based on this selector to the given QueryFactor, returns the child QueryFactory **/ - public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory) + @NamespaceAccessible + public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory) { return addQueryFactorySubselect(parentQueryFactory, true); } @@ -448,7 +485,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Adds a subselect QueryFactory based on this selector to the given QueryFactor **/ - public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, Boolean includeSelectorFields) + @NamespaceAccessible + public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, Boolean includeSelectorFields) { fflib_QueryFactory subSelectQueryFactory = parentQueryFactory.subselectQuery(getSObjectType2()); @@ -463,7 +501,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Adds a subselect QueryFactory based on this selector to the given QueryFactor, returns the child QueryFactory **/ - public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, String relationshipName) + @NamespaceAccessible + public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, String relationshipName) { return addQueryFactorySubselect(parentQueryFactory, relationshipName, TRUE); } @@ -471,7 +510,8 @@ public abstract with sharing class fflib_SObjectSelector /** * Adds a subselect QueryFactory based on this selector to the given QueryFactor **/ - public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, String relationshipName, Boolean includeSelectorFields) + @NamespaceAccessible + public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, String relationshipName, Boolean includeSelectorFields) { fflib_QueryFactory subSelectQueryFactory = parentQueryFactory.subselectQuery(relationshipName); return configureQueryFactory(subSelectQueryFactory, m_enforceCRUD, m_enforceFLS, includeSelectorFields, m_dataAccess); diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls index 537bf3ed78f..6685b8cc326 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls @@ -51,7 +51,8 @@ * TODO: Need to add some more test methods for more complex use cases and some unexpected (e.g. registerDirty and then registerDeleted) * **/ -public virtual class fflib_SObjectUnitOfWork +@NamespaceAccessible +public virtual class fflib_SObjectUnitOfWork implements fflib_ISObjectUnitOfWork { protected List m_sObjectTypes = new List(); @@ -79,12 +80,14 @@ public virtual class fflib_SObjectUnitOfWork /** * Interface describes work to be performed during the commitWork method **/ - public interface IDoWork + @NamespaceAccessible + public interface IDoWork { void doWork(); } - public interface IDML + @NamespaceAccessible + public interface IDML { void dmlInsert(List objList); void dmlUpdate(List objList); @@ -93,21 +96,26 @@ public virtual class fflib_SObjectUnitOfWork void emptyRecycleBin(List objList); } - public virtual class SimpleDML implements IDML + @NamespaceAccessible + public virtual class SimpleDML implements IDML { - public virtual void dmlInsert(List objList) + @NamespaceAccessible + public virtual void dmlInsert(List objList) { insert objList; } - public virtual void dmlUpdate(List objList) + @NamespaceAccessible + public virtual void dmlUpdate(List objList) { update objList; } - public virtual void dmlDelete(List objList) + @NamespaceAccessible + public virtual void dmlDelete(List objList) { delete objList; } - public virtual void eventPublish(List objList) + @NamespaceAccessible + public virtual void eventPublish(List objList) { if (objList.isEmpty()) { @@ -116,7 +124,8 @@ public virtual class fflib_SObjectUnitOfWork EventBus.publish(objList); } - public virtual void emptyRecycleBin(List objList) + @NamespaceAccessible + public virtual void emptyRecycleBin(List objList) { if (objList.isEmpty()) { @@ -127,26 +136,32 @@ public virtual class fflib_SObjectUnitOfWork } } - public virtual class UserModeDML extends SimpleDML{ + @NamespaceAccessible + public virtual class UserModeDML extends SimpleDML{ @TestVisible private AccessLevel m_accessLevel; - public UserModeDML(){ + @NamespaceAccessible + public UserModeDML(){ this(AccessLevel.USER_MODE); } /** Supply the AccessLevel explicitly (UserModeDML uses AccessMode.USER_MODE, by default) */ - public UserModeDML(AccessLevel access){ + @NamespaceAccessible + public UserModeDML(AccessLevel access){ m_accessLevel = access; } - public virtual override void dmlInsert(List objList){ + @NamespaceAccessible + public virtual override void dmlInsert(List objList){ Database.insert(objList,m_accessLevel); } - public virtual override void dmlUpdate(List objList){ + @NamespaceAccessible + public virtual override void dmlUpdate(List objList){ Database.update(objList,m_accessLevel); } - public virtual override void dmlDelete(List objList){ + @NamespaceAccessible + public virtual override void dmlDelete(List objList){ Database.delete(objList,m_accessLevel); } } @@ -157,12 +172,14 @@ public virtual class fflib_SObjectUnitOfWork * * @param sObjectTypes A list of objects given in dependency order (least dependent first) */ - public fflib_SObjectUnitOfWork(List sObjectTypes) + @NamespaceAccessible + public fflib_SObjectUnitOfWork(List sObjectTypes) { this(sObjectTypes,new SimpleDML()); } - public fflib_SObjectUnitOfWork(List sObjectTypes, IDML dml) + @NamespaceAccessible + public fflib_SObjectUnitOfWork(List sObjectTypes, IDML dml) { m_sObjectTypes = sObjectTypes.clone(); @@ -178,26 +195,40 @@ public virtual class fflib_SObjectUnitOfWork } // default implementations for commitWork events - public virtual void onRegisterType(Schema.SObjectType sObjectType) {} - public virtual void onCommitWorkStarting() {} - - public virtual void onPublishBeforeEventsStarting() {} - public virtual void onPublishBeforeEventsFinished() {} - - public virtual void onDMLStarting() {} - public virtual void onDMLFinished() {} - - public virtual void onDoWorkStarting() {} - public virtual void onDoWorkFinished() {} - - public virtual void onPublishAfterSuccessEventsStarting() {} - public virtual void onPublishAfterSuccessEventsFinished() {} - - public virtual void onPublishAfterFailureEventsStarting() {} - public virtual void onPublishAfterFailureEventsFinished() {} - - public virtual void onCommitWorkFinishing() {} - public virtual void onCommitWorkFinished(Boolean wasSuccessful) {} + @NamespaceAccessible + public virtual void onRegisterType(Schema.SObjectType sObjectType) {} + @NamespaceAccessible + public virtual void onCommitWorkStarting() {} + + @NamespaceAccessible + public virtual void onPublishBeforeEventsStarting() {} + @NamespaceAccessible + public virtual void onPublishBeforeEventsFinished() {} + + @NamespaceAccessible + public virtual void onDMLStarting() {} + @NamespaceAccessible + public virtual void onDMLFinished() {} + + @NamespaceAccessible + public virtual void onDoWorkStarting() {} + @NamespaceAccessible + public virtual void onDoWorkFinished() {} + + @NamespaceAccessible + public virtual void onPublishAfterSuccessEventsStarting() {} + @NamespaceAccessible + public virtual void onPublishAfterSuccessEventsFinished() {} + + @NamespaceAccessible + public virtual void onPublishAfterFailureEventsStarting() {} + @NamespaceAccessible + public virtual void onPublishAfterFailureEventsFinished() {} + + @NamespaceAccessible + public virtual void onCommitWorkFinishing() {} + @NamespaceAccessible + public virtual void onCommitWorkFinished(Boolean wasSuccessful) {} /** * Registers the type to be used for DML operations @@ -227,7 +258,8 @@ public virtual class fflib_SObjectUnitOfWork /** * Register a generic piece of work to be invoked during the commitWork phase **/ - public void registerWork(IDoWork work) + @NamespaceAccessible + public void registerWork(IDoWork work) { m_workList.add(work); } @@ -235,7 +267,8 @@ public virtual class fflib_SObjectUnitOfWork /** * Registers the given email to be sent during the commitWork **/ - public void registerEmail(Messaging.Email email) + @NamespaceAccessible + public void registerEmail(Messaging.Email email) { m_emailWork.registerEmail(email); } @@ -245,7 +278,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record An deleted record **/ - public void registerEmptyRecycleBin(SObject record) + @NamespaceAccessible + public void registerEmptyRecycleBin(SObject record) { String sObjectType = record.getSObjectType().getDescribe().getName(); assertForSupportedSObjectType(m_emptyRecycleBinMapByType, sObjectType); @@ -258,7 +292,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records Deleted records **/ - public void registerEmptyRecycleBin(List records) + @NamespaceAccessible + public void registerEmptyRecycleBin(List records) { for (SObject record : records) { @@ -271,7 +306,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record A newly created SObject instance to be inserted during commitWork **/ - public void registerNew(SObject record) + @NamespaceAccessible + public void registerNew(SObject record) { registerNew(record, null, null); } @@ -281,7 +317,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of newly created SObject instances to be inserted during commitWork **/ - public void registerNew(List records) + @NamespaceAccessible + public void registerNew(List records) { for (SObject record : records) { @@ -297,7 +334,8 @@ public virtual class fflib_SObjectUnitOfWork * @param relatedToParentField A SObjectField reference to the child field that associates the child record with its parent * @param relatedToParentRecord A SObject instance of the parent record (should also be registered as new separately) **/ - public void registerNew(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord) + @NamespaceAccessible + public void registerNew(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord) { if (record.Id != null) throw new UnitOfWorkException('Only new records can be registered as new'); @@ -319,7 +357,8 @@ public virtual class fflib_SObjectUnitOfWork * @param relatedToField A SObjectField reference to the lookup field that relates the two records together * @param relatedTo A SObject instance (yet to be committed to the database) */ - public void registerRelationship(SObject record, Schema.SObjectField relatedToField, SObject relatedTo) + @NamespaceAccessible + public void registerRelationship(SObject record, Schema.SObjectField relatedToField, SObject relatedTo) { String sObjectType = record.getSObjectType().getDescribe().getName(); @@ -337,7 +376,8 @@ public virtual class fflib_SObjectUnitOfWork * @param email a single email message instance * @param relatedTo A SObject instance (yet to be committed to the database) */ - public void registerRelationship( Messaging.SingleEmailMessage email, SObject relatedTo ) + @NamespaceAccessible + public void registerRelationship( Messaging.SingleEmailMessage email, SObject relatedTo ) { m_relationships.get( Messaging.SingleEmailMessage.class.getName() ).add(email, relatedTo); } @@ -355,7 +395,8 @@ public virtual class fflib_SObjectUnitOfWork * * Wraps putSObject, creating a new instance of the lookup sobject using the external id field and value. */ - public void registerRelationship(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId) + @NamespaceAccessible + public void registerRelationship(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId) { // NOTE: Due to the lack of ExternalID references on Standard Objects, this method can not be provided a standardized Unit Test. - Rick Parker String sObjectType = record.getSObjectType().getDescribe().getName(); @@ -369,7 +410,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record An existing record **/ - public void registerDirty(SObject record) + @NamespaceAccessible + public void registerDirty(SObject record) { registerDirty(record, new List()); } @@ -380,7 +422,8 @@ public virtual class fflib_SObjectUnitOfWork * @param records SObjects to register as dirty * @param dirtyFields A list of modified fields */ - public void registerDirty(List records, List dirtyFields) + @NamespaceAccessible + public void registerDirty(List records, List dirtyFields) { for (SObject record : records) { @@ -394,7 +437,8 @@ public virtual class fflib_SObjectUnitOfWork * @param record SObject to register as dirty * @param dirtyFields A list of modified fields */ - public void registerDirty(SObject record, List dirtyFields) + @NamespaceAccessible + public void registerDirty(SObject record, List dirtyFields) { if (record.Id == null) throw new UnitOfWorkException('New records cannot be registered as dirty'); @@ -430,7 +474,8 @@ public virtual class fflib_SObjectUnitOfWork * @param relatedToParentField A SObjectField reference to the child field that associates the child record with its parent * @param relatedToParentRecord A SObject instance of the parent record (should also be registered as new separately) **/ - public void registerDirty(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord) + @NamespaceAccessible + public void registerDirty(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord) { registerDirty(record); if (relatedToParentRecord!=null && relatedToParentField!=null) @@ -442,7 +487,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of existing records **/ - public void registerDirty(List records) + @NamespaceAccessible + public void registerDirty(List records) { for (SObject record : records) { @@ -455,7 +501,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record A new or existing record **/ - public void registerUpsert(SObject record) + @NamespaceAccessible + public void registerUpsert(SObject record) { if (record.Id == null) { @@ -472,7 +519,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of mix of new and existing records **/ - public void registerUpsert(List records) + @NamespaceAccessible + public void registerUpsert(List records) { for (SObject record : records) { @@ -485,7 +533,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record An existing record **/ - public void registerDeleted(SObject record) + @NamespaceAccessible + public void registerDeleted(SObject record) { if (record.Id == null) throw new UnitOfWorkException('New records cannot be registered for deletion'); @@ -502,7 +551,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of existing records **/ - public void registerDeleted(List records) + @NamespaceAccessible + public void registerDeleted(List records) { for (SObject record : records) { @@ -515,7 +565,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of existing records **/ - public void registerPermanentlyDeleted(List records) + @NamespaceAccessible + public void registerPermanentlyDeleted(List records) { this.registerEmptyRecycleBin(records); this.registerDeleted(records); @@ -526,7 +577,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record A list of existing records **/ - public void registerPermanentlyDeleted(SObject record) + @NamespaceAccessible + public void registerPermanentlyDeleted(SObject record) { this.registerEmptyRecycleBin(record); this.registerDeleted(record); @@ -537,7 +589,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record A newly created SObject (Platform Event) instance to be inserted during commitWork **/ - public void registerPublishBeforeTransaction(SObject record) + @NamespaceAccessible + public void registerPublishBeforeTransaction(SObject record) { String sObjectType = record.getSObjectType().getDescribe().getName(); @@ -552,7 +605,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of existing records **/ - public void registerPublishBeforeTransaction(List records) + @NamespaceAccessible + public void registerPublishBeforeTransaction(List records) { for (SObject record : records) { @@ -565,7 +619,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record A newly created SObject (Platform Event) instance to be inserted during commitWork **/ - public void registerPublishAfterSuccessTransaction(SObject record) + @NamespaceAccessible + public void registerPublishAfterSuccessTransaction(SObject record) { String sObjectType = record.getSObjectType().getDescribe().getName(); @@ -580,7 +635,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of existing records **/ - public void registerPublishAfterSuccessTransaction(List records) + @NamespaceAccessible + public void registerPublishAfterSuccessTransaction(List records) { for (SObject record : records) { @@ -592,7 +648,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param record A newly created SObject (Platform Event) instance to be inserted during commitWork **/ - public void registerPublishAfterFailureTransaction(SObject record) + @NamespaceAccessible + public void registerPublishAfterFailureTransaction(SObject record) { String sObjectType = record.getSObjectType().getDescribe().getName(); @@ -607,7 +664,8 @@ public virtual class fflib_SObjectUnitOfWork * * @param records A list of existing records **/ - public void registerPublishAfterFailureTransaction(List records) + @NamespaceAccessible + public void registerPublishAfterFailureTransaction(List records) { for (SObject record : records) { @@ -618,7 +676,8 @@ public virtual class fflib_SObjectUnitOfWork /** * Takes all the work that has been registered with the UnitOfWork and commits it to the database **/ - public void commitWork() + @NamespaceAccessible + public void commitWork() { Savepoint sp = Database.setSavepoint(); Boolean wasSuccessful = false; @@ -806,7 +865,8 @@ public virtual class fflib_SObjectUnitOfWork { private List m_relationships = new List(); - public void resolve() + @NamespaceAccessible + public void resolve() { // Resolve relationships for (IRelationship relationship : m_relationships) @@ -817,7 +877,8 @@ public virtual class fflib_SObjectUnitOfWork } - public void add(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId) + @NamespaceAccessible + public void add(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId) { if (relatedToField == null) { throw new UnitOfWorkException('Invalid argument: relatedToField.'); @@ -853,7 +914,8 @@ public virtual class fflib_SObjectUnitOfWork m_relationships.add(relationship); } - public void add(SObject record, Schema.SObjectField relatedToField, SObject relatedTo) + @NamespaceAccessible + public void add(SObject record, Schema.SObjectField relatedToField, SObject relatedTo) { // Relationship to resolve Relationship relationship = new Relationship(); @@ -863,7 +925,8 @@ public virtual class fflib_SObjectUnitOfWork m_relationships.add(relationship); } - public void add(Messaging.SingleEmailMessage email, SObject relatedTo) + @NamespaceAccessible + public void add(Messaging.SingleEmailMessage email, SObject relatedTo) { EmailRelationship emailRelationship = new EmailRelationship(); emailRelationship.email = email; @@ -879,14 +942,21 @@ public virtual class fflib_SObjectUnitOfWork private class RelationshipByExternalId implements IRelationship { - public SObject Record; - public Schema.SObjectField RelatedToField; - public Schema.SObjectType RelatedTo; - public String RelationshipName; - public Schema.SObjectField ExternalIdField; - public Object ExternalId; - - public void resolve() + @NamespaceAccessible + public SObject Record; + @NamespaceAccessible + public Schema.SObjectField RelatedToField; + @NamespaceAccessible + public Schema.SObjectType RelatedTo; + @NamespaceAccessible + public String RelationshipName; + @NamespaceAccessible + public Schema.SObjectField ExternalIdField; + @NamespaceAccessible + public Object ExternalId; + + @NamespaceAccessible + public void resolve() { SObject relationshipObject = this.RelatedTo.newSObject(); relationshipObject.put( ExternalIdField.getDescribe().getName(), this.ExternalId ); @@ -896,11 +966,15 @@ public virtual class fflib_SObjectUnitOfWork private class Relationship implements IRelationship { - public SObject Record; - public Schema.SObjectField RelatedToField; - public SObject RelatedTo; - - public void resolve() + @NamespaceAccessible + public SObject Record; + @NamespaceAccessible + public Schema.SObjectField RelatedToField; + @NamespaceAccessible + public SObject RelatedTo; + + @NamespaceAccessible + public void resolve() { this.Record.put( this.RelatedToField, this.RelatedTo.Id); } @@ -908,10 +982,13 @@ public virtual class fflib_SObjectUnitOfWork private class EmailRelationship implements IRelationship { - public Messaging.SingleEmailMessage email; - public SObject relatedTo; + @NamespaceAccessible + public Messaging.SingleEmailMessage email; + @NamespaceAccessible + public SObject relatedTo; - public void resolve() + @NamespaceAccessible + public void resolve() { this.email.setWhatId( this.relatedTo.Id ); } @@ -920,12 +997,14 @@ public virtual class fflib_SObjectUnitOfWork /** * UnitOfWork Exception **/ - public class UnitOfWorkException extends Exception {} + @NamespaceAccessible + public class UnitOfWorkException extends Exception {} /** * Internal implementation of Messaging.sendEmail, see outer class registerEmail method **/ - public interface IEmailWork extends IDoWork + @NamespaceAccessible + public interface IEmailWork extends IDoWork { void registerEmail(Messaging.Email email); } @@ -934,17 +1013,20 @@ public virtual class fflib_SObjectUnitOfWork { private List emails; - public SendEmailWork() + @NamespaceAccessible + public SendEmailWork() { this.emails = new List(); } - public void registerEmail(Messaging.Email email) + @NamespaceAccessible + public void registerEmail(Messaging.Email email) { this.emails.add(email); } - public void doWork() + @NamespaceAccessible + public void doWork() { if (emails.size() > 0) Messaging.sendEmail(emails); } diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjects.cls b/sfdx-source/apex-common/main/classes/fflib_SObjects.cls index 95c48ccf017..834f3049a52 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjects.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjects.cls @@ -23,17 +23,20 @@ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ +@NamespaceAccessible public virtual class fflib_SObjects extends fflib_Objects implements fflib_ISObjects { - public Schema.DescribeSObjectResult SObjectDescribe {get; private set;} + @NamespaceAccessible + public Schema.DescribeSObjectResult SObjectDescribe {get; private set;} /** * Useful during unit testing to assert at a more granular and robust level for errors raised during the various trigger events **/ - public static ErrorFactory Errors {get; private set;} + @NamespaceAccessible + public static ErrorFactory Errors {get; private set;} static { @@ -43,33 +46,39 @@ public virtual class fflib_SObjects /** * Class constructor */ - public fflib_SObjects(List records) + @NamespaceAccessible + public fflib_SObjects(List records) { super(records); } - public fflib_SObjects(List records, Schema.SObjectType sObjectType) + @NamespaceAccessible + public fflib_SObjects(List records, Schema.SObjectType sObjectType) { super(records); SObjectDescribe = sObjectType.getDescribe(); } - public virtual List getRecords() + @NamespaceAccessible + public virtual List getRecords() { return (List) getObjects(); } - public virtual Set getRecordIds() + @NamespaceAccessible + public virtual Set getRecordIds() { return new Map(getRecords()).keySet(); } - public virtual override Object getType() + @NamespaceAccessible + public virtual override Object getType() { return getSObjectType(); } - public virtual SObjectType getSObjectType() + @NamespaceAccessible + public virtual SObjectType getSObjectType() { return SObjectDescribe.getSObjectType(); } @@ -79,7 +88,8 @@ public virtual class fflib_SObjects * * @param message The error message to add to each record */ - protected void addError(String message) + @NamespaceAccessible + protected void addError(String message) { for (SObject record : getRecords()) { @@ -94,7 +104,8 @@ public virtual class fflib_SObjects * @param message The error message to add to the given field on each record */ @TestVisible - protected virtual void addError(Schema.SObjectField field, String message) + @NamespaceAccessible + protected virtual void addError(Schema.SObjectField field, String message) { for (SObject record : getRecords()) { @@ -107,7 +118,8 @@ public virtual class fflib_SObjects * @param field The field to nullify */ @TestVisible - protected virtual void clearField(Schema.SObjectField field) + @NamespaceAccessible + protected virtual void clearField(Schema.SObjectField field) { clearFields(new Set{ field }); } @@ -117,7 +129,8 @@ public virtual class fflib_SObjects * @param fields The fields to nullify */ @TestVisible - protected virtual void clearFields(Set fields) + @NamespaceAccessible + protected virtual void clearFields(Set fields) { for (SObject record : getRecords()) { @@ -136,7 +149,8 @@ public virtual class fflib_SObjects * * @return Returns the Error message **/ - protected virtual String error(String message, SObject record) + @NamespaceAccessible + protected virtual String error(String message, SObject record) { return Errors.error(this, message, record); } @@ -150,7 +164,8 @@ public virtual class fflib_SObjects * * @return Returns the Error message **/ - protected virtual String error(String message, SObject record, Schema.SObjectField field) + @NamespaceAccessible + protected virtual String error(String message, SObject record, Schema.SObjectField field) { return fflib_SObjects.Errors.error(this, message, record, field); } @@ -161,7 +176,8 @@ public virtual class fflib_SObjects * @return Return a set with all the Id values of the given field */ @TestVisible - protected Set getIdFieldValues(Schema.SObjectField field) + @NamespaceAccessible + protected Set getIdFieldValues(Schema.SObjectField field) { Set result = new Set(); for (SObject record : getRecords()) @@ -177,7 +193,8 @@ public virtual class fflib_SObjects * @return Return a set with all the String values of the given field */ @TestVisible - protected Set getStringFieldValues(Schema.SObjectField field) + @NamespaceAccessible + protected Set getStringFieldValues(Schema.SObjectField field) { Set result = new Set(); for (SObject record : getRecords()) @@ -193,7 +210,8 @@ public virtual class fflib_SObjects * @return Return a set with all the values of the given field */ @TestVisible - protected virtual Set getFieldValues(Schema.SObjectField field) + @NamespaceAccessible + protected virtual Set getFieldValues(Schema.SObjectField field) { Set result = new Set(); for (SObject record : getRecords()) @@ -209,7 +227,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where the given field has the provided value */ - protected virtual List getRecordsByFieldValue(Schema.SObjectField field, Object value) + @NamespaceAccessible + protected virtual List getRecordsByFieldValue(Schema.SObjectField field, Object value) { return getRecordsByFieldValues(field, new Set{value}); } @@ -220,7 +239,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where the given field value is part of the provided values */ - protected virtual List getRecordsByFieldValues(Schema.SObjectField field, Set values) + @NamespaceAccessible + protected virtual List getRecordsByFieldValues(Schema.SObjectField field, Set values) { List result = new List(); for (SObject record : getRecords()) @@ -238,7 +258,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where the given field value is either null or '') */ - protected virtual List getRecordsWithBlankFieldValues(Schema.SObjectField field) + @NamespaceAccessible + protected virtual List getRecordsWithBlankFieldValues(Schema.SObjectField field) { return getRecordsWithBlankFieldValues( new Set {field} @@ -250,7 +271,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where the at least one given field value is either null or '') */ - protected virtual List getRecordsWithBlankFieldValues(Set fields) + @NamespaceAccessible + protected virtual List getRecordsWithBlankFieldValues(Set fields) { List result = new List(); for (SObject record : getRecords()) @@ -271,7 +293,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where all given field values are either null or '' */ - protected virtual List getRecordsWithAllBlankFieldValues(Set fields) + @NamespaceAccessible + protected virtual List getRecordsWithAllBlankFieldValues(Set fields) { List result = new List(); for (SObject record : getRecords()) @@ -295,7 +318,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where the given field value is not null or '' */ - protected virtual List getRecordsWithNotBlankFieldValues(Schema.SObjectField field) + @NamespaceAccessible + protected virtual List getRecordsWithNotBlankFieldValues(Schema.SObjectField field) { return getRecordsWithNotBlankFieldValues( new Set {field} @@ -307,7 +331,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where the at least one given field value not null or '' */ - protected virtual List getRecordsWithNotBlankFieldValues(Set fields) + @NamespaceAccessible + protected virtual List getRecordsWithNotBlankFieldValues(Set fields) { List result = new List(); for (SObject record : getRecords()) @@ -329,7 +354,8 @@ public virtual class fflib_SObjects * * @return A list with only the SObjects where all given field values are not null or '' */ - protected virtual List getRecordsWithAllNotBlankFieldValues(Set fields) + @NamespaceAccessible + protected virtual List getRecordsWithAllNotBlankFieldValues(Set fields) { List result = new List(); for (SObject record : getRecords()) @@ -354,7 +380,8 @@ public virtual class fflib_SObjects * @param field The reference to the SObjectField to be modified * @param value The value to store in the given SObjectField */ - protected virtual void setFieldValue(Schema.SObjectField field, Object value) + @NamespaceAccessible + protected virtual void setFieldValue(Schema.SObjectField field, Object value) { for (SObject record : getRecords()) { @@ -367,7 +394,8 @@ public virtual class fflib_SObjects * @param fieldToUpdate The SObjectField to store the mapped value when the key matches the value in the fieldToUpdate field * @param values Map of values to store by the fieldToCheck fields value */ - protected virtual void setFieldValueByMap( + @NamespaceAccessible + protected virtual void setFieldValueByMap( Schema.SObjectField fieldToCheck, Schema.SObjectField fieldToUpdate, Map values) @@ -385,18 +413,21 @@ public virtual class fflib_SObjects /** * Ensures logging of errors in the Domain context for later assertions in tests **/ - public virtual class ErrorFactory + @NamespaceAccessible + public virtual class ErrorFactory { private List errorList = new List(); private ErrorFactory() { } - public String error(String message, SObject record) + @NamespaceAccessible + public String error(String message, SObject record) { return error(null, message, record); } - public String error(fflib_SObjects domain, String message, SObject record) + @NamespaceAccessible + public String error(fflib_SObjects domain, String message, SObject record) { ObjectError objectError = new ObjectError(); objectError.domain = domain; @@ -406,12 +437,14 @@ public virtual class fflib_SObjects return message; } - public String error(String message, SObject record, SObjectField field) + @NamespaceAccessible + public String error(String message, SObject record, SObjectField field) { return error(null, message, record, field); } - public String error(fflib_ISObjects domain, String message, SObject record, SObjectField field) + @NamespaceAccessible + public String error(fflib_ISObjects domain, String message, SObject record, SObjectField field) { FieldError fieldError = new FieldError(); fieldError.domain = domain; @@ -422,12 +455,14 @@ public virtual class fflib_SObjects return message; } - public List getAll() + @NamespaceAccessible + public List getAll() { return errorList.clone(); } - public void clearAll() + @NamespaceAccessible + public void clearAll() { errorList.clear(); } @@ -436,29 +471,38 @@ public virtual class fflib_SObjects /** * Ensures logging of errors in the Domain context for later assertions in tests **/ - public virtual class FieldError extends ObjectError + @NamespaceAccessible + public virtual class FieldError extends ObjectError { - public SObjectField field; + @NamespaceAccessible + public SObjectField field; - public FieldError() { } + @NamespaceAccessible + public FieldError() { } } /** * Ensures logging of errors in the Domain context for later assertions in tests **/ - public virtual class ObjectError extends Error + @NamespaceAccessible + public virtual class ObjectError extends Error { - public SObject record; + @NamespaceAccessible + public SObject record; - public ObjectError() { } + @NamespaceAccessible + public ObjectError() { } } /** * Ensures logging of errors in the Domain context for later assertions in tests **/ - public abstract class Error + @NamespaceAccessible + public abstract class Error { - public String message; - public fflib_ISObjects domain; + @NamespaceAccessible + public String message; + @NamespaceAccessible + public fflib_ISObjects domain; } } \ No newline at end of file diff --git a/sfdx-source/apex-common/main/classes/fflib_SecurityUtils.cls b/sfdx-source/apex-common/main/classes/fflib_SecurityUtils.cls index eaa84cc032b..329013473f4 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SecurityUtils.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SecurityUtils.cls @@ -28,6 +28,7 @@ * Utility class for checking FLS/CRUD. NOTE: all "check" methods will throw a SecurityException (or subclass) if the * user does not have the proper security granted. **/ +@NamespaceAccessible public class fflib_SecurityUtils { @TestVisible @@ -38,8 +39,11 @@ public class fflib_SecurityUtils * forms of CRUD and FLD violations throw subclasses of it. It is provided as a convenience * in the event you wish to handle CRUD and FLS violations the same way (e.g. die and display an error) **/ + @NamespaceAccessible public virtual class SecurityException extends Exception { + @NamespaceAccessible protected OperationType m_operation; + @NamespaceAccessible protected Schema.SObjectType m_objectType; } @@ -47,6 +51,7 @@ public class fflib_SecurityUtils * CrudException represents a running user's lack of read/create/update/delete access at a profile (or permission set) * level. Sharing and field level security issues will never cause this. **/ + @NamespaceAccessible public class CrudException extends SecurityException{ private CrudException(OperationType operation, Schema.SObjectType objectType){ @@ -75,6 +80,7 @@ public class fflib_SecurityUtils * FlsException represents a running user's lack of field level security to a specific field at a profile (or permission set) level * Sharing and CRUD security issues will never cause this to be thrown. **/ + @NamespaceAccessible public class FlsException extends SecurityException{ private Schema.SObjectField m_fieldToken; @@ -107,6 +113,7 @@ public class fflib_SecurityUtils * FLS and CRUD checks exists and is enabled. * Per security best practices setting BYPASS should be an a opt-in, and not the default behavior. **/ + @NamespaceAccessible public static Boolean BYPASS_INTERNAL_FLS_AND_CRUD = false; /** @@ -118,6 +125,7 @@ public class fflib_SecurityUtils * @exception FlsException if the running user does not have insert rights to any fields in {@code fieldNames}. * @exception CrudException if the running user does not have insert rights to {@code objType} **/ + @NamespaceAccessible public static void checkInsert(SObjectType objType, List fieldNames) { checkObjectIsInsertable(objType); @@ -132,6 +140,7 @@ public class fflib_SecurityUtils * @exception FlsException if the running user does not have insert rights to any fields in {@code fieldTokens}. * @exception CrudException if the running user does not have insert rights to {@code objType} **/ + @NamespaceAccessible public static void checkInsert(SObjectType objType, List fieldTokens) { checkObjectIsInsertable(objType); @@ -146,6 +155,7 @@ public class fflib_SecurityUtils * @exception FlsException if the running user does not have read rights to any fields in {@code fieldNames}. * @exception CrudException if the running user does not have read rights to {@code objType} **/ + @NamespaceAccessible public static void checkRead(SObjectType objType, List fieldNames) { checkObjectIsReadable(objType); @@ -160,6 +170,7 @@ public class fflib_SecurityUtils * @exception FlsException if the running user does not have read rights to any fields in {@code fieldTokens}. * @exception CrudException if the running user does not have read rights to {@code objType} **/ + @NamespaceAccessible public static void checkRead(SObjectType objType, List fieldTokens) { checkObjectIsReadable(objType); @@ -174,6 +185,7 @@ public class fflib_SecurityUtils * @exception FlsException if the running user does not have update rights to any fields in {@code fieldNames}. * @exception CrudException if the running user does not have update rights to {@code objType} **/ + @NamespaceAccessible public static void checkUpdate(SObjectType objType, List fieldNames) { checkObjectIsUpdateable(objType); @@ -188,6 +200,7 @@ public class fflib_SecurityUtils * @exception FlsException if the running user does not have update rights to any fields in {@code fieldTokens}. * @exception CrudException if the running user does not have update rights to {@code objType} **/ + @NamespaceAccessible public static void checkUpdate(SObjectType objType, List fieldTokens) { checkObjectIsUpdateable(objType); @@ -205,6 +218,7 @@ public class fflib_SecurityUtils * Checks insert field level security only (no CRUD) for the specified fields on {@code objType} * @exception FlsException if the running user does not have insert rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsInsertable(SObjectType objType, String fieldName) { checkFieldIsInsertable(objType, fflib_SObjectDescribe.getDescribe(objType).getField(fieldName)); @@ -214,6 +228,7 @@ public class fflib_SecurityUtils * Identical to {@link #checkFieldIsInsertable(SObjectType,String)}, except with SObjectField instead of String field reference. * @exception FlsException if the running user does not have insert rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsInsertable(SObjectType objType, SObjectField fieldToken) { checkFieldIsInsertable(objType, fieldToken.getDescribe()); @@ -223,6 +238,7 @@ public class fflib_SecurityUtils * Identical to {@link #checkFieldIsInsertable(SObjectType,String)}, except with DescribeFieldResult instead of String field reference. * @exception FlsException if the running user does not have insert rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsInsertable(SObjectType objType, DescribeFieldResult fieldDescribe) { if (BYPASS_INTERNAL_FLS_AND_CRUD) @@ -235,6 +251,7 @@ public class fflib_SecurityUtils * Checks read field level security only (no CRUD) for the specified fields on {@code objType} * @exception FlsException if the running user does not have read rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsReadable(SObjectType objType, String fieldName) { checkFieldIsReadable(objType, fflib_SObjectDescribe.getDescribe(objType).getField(fieldName)); @@ -244,6 +261,7 @@ public class fflib_SecurityUtils * Identical to {@link #checkFieldIsReadable(SObjectType,String)}, except with SObjectField instead of String field reference. * @exception FlsException if the running user does not have read rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsReadable(SObjectType objType, SObjectField fieldToken) { checkFieldIsReadable(objType, fieldToken.getDescribe()); @@ -253,6 +271,7 @@ public class fflib_SecurityUtils * Identical to {@link #checkFieldIsReadable(SObjectType,String)}, except with DescribeFieldResult instead of String field reference. * @exception FlsException if the running user does not have read rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsReadable(SObjectType objType, DescribeFieldResult fieldDescribe) { if (BYPASS_INTERNAL_FLS_AND_CRUD) @@ -266,6 +285,7 @@ public class fflib_SecurityUtils * Checks update field level security only (no CRUD) for the specified fields on {@code objType} * @exception FlsException if the running user does not have update rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsUpdateable(SObjectType objType, String fieldName) { checkFieldIsUpdateable(objType, fflib_SObjectDescribe.getDescribe(objType).getField(fieldName)); @@ -275,6 +295,7 @@ public class fflib_SecurityUtils * Identical to {@link #checkFieldIsUpdateable(SObjectType,String)}, except with SObjectField instead of String field reference. * @exception FlsException if the running user does not have update rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsUpdateable(SObjectType objType, SObjectField fieldToken) { checkFieldIsUpdateable(objType, fieldToken.getDescribe()); @@ -284,6 +305,7 @@ public class fflib_SecurityUtils * Identical to {@link #checkFieldIsUpdateable(SObjectType,String)}, except with DescribeFieldResult instead of String field reference. * @exception FlsException if the running user does not have update rights to the {@code fieldName} field. **/ + @NamespaceAccessible public static void checkFieldIsUpdateable(SObjectType objType, DescribeFieldResult fieldDescribe) { if (BYPASS_INTERNAL_FLS_AND_CRUD) @@ -300,6 +322,7 @@ public class fflib_SecurityUtils * Checks insert CRUD for the specified object type. * @exception CrudException if the running user does not have insert rights to the {@code objType} SObject. **/ + @NamespaceAccessible public static void checkObjectIsInsertable(SObjectType objType) { if (BYPASS_INTERNAL_FLS_AND_CRUD) @@ -314,6 +337,7 @@ public class fflib_SecurityUtils * Checks read CRUD for the specified object type. * @exception CrudException if the running user does not have read rights to the {@code objType} SObject. **/ + @NamespaceAccessible public static void checkObjectIsReadable(SObjectType objType) { if (BYPASS_INTERNAL_FLS_AND_CRUD) @@ -326,6 +350,7 @@ public class fflib_SecurityUtils * Checks update CRUD for the specified object type. * @exception CrudException if the running user does not have update rights to the {@code objType} SObject. **/ + @NamespaceAccessible public static void checkObjectIsUpdateable(SObjectType objType) { if (BYPASS_INTERNAL_FLS_AND_CRUD) @@ -338,6 +363,7 @@ public class fflib_SecurityUtils * Checks delete CRUD for the specified object type. * @exception CrudException if the running user does not have delete rights to the {@code objType} SObject. **/ + @NamespaceAccessible public static void checkObjectIsDeletable(SObjectType objType) { if (BYPASS_INTERNAL_FLS_AND_CRUD) diff --git a/sfdx-source/apex-common/main/classes/fflib_StringBuilder.cls b/sfdx-source/apex-common/main/classes/fflib_StringBuilder.cls index 5bb97f3b719..65cf9748901 100644 --- a/sfdx-source/apex-common/main/classes/fflib_StringBuilder.cls +++ b/sfdx-source/apex-common/main/classes/fflib_StringBuilder.cls @@ -29,19 +29,22 @@ * * NOTE: Aspects of this were developed before recent improvements to String handling, as such could likely be enhanced at this stage. **/ -public virtual class fflib_StringBuilder +@NamespaceAccessible +public virtual class fflib_StringBuilder { protected List buffer = new List(); /** * Construct an empty StringBuilder **/ - public fflib_StringBuilder() {} + @NamespaceAccessible + public fflib_StringBuilder() {} /** * Construct a StringBuilder with the given values **/ - public fflib_StringBuilder(List values) + @NamespaceAccessible + public fflib_StringBuilder(List values) { add(values); } @@ -49,7 +52,8 @@ public virtual class fflib_StringBuilder /** * Add the given values to the StringBuilder **/ - public virtual void add(List values) + @NamespaceAccessible + public virtual void add(List values) { buffer.addAll(values); } @@ -57,12 +61,14 @@ public virtual class fflib_StringBuilder /** * Add the given value to the StringBuilder **/ - public virtual void add(String value) + @NamespaceAccessible + public virtual void add(String value) { buffer.add(value); } - public virtual override String toString() + @NamespaceAccessible + public virtual override String toString() { return String.join(buffer, ''); } @@ -70,7 +76,8 @@ public virtual class fflib_StringBuilder /** * Return the state of the StringBuilder **/ - public virtual String getStringValue() + @NamespaceAccessible + public virtual String getStringValue() { return toString(); } @@ -78,35 +85,42 @@ public virtual class fflib_StringBuilder /** * Subclasses the StringBuilder to produce a comma delimited concatenation of strings **/ - public virtual with sharing class CommaDelimitedListBuilder extends fflib_StringBuilder + @NamespaceAccessible + public virtual with sharing class CommaDelimitedListBuilder extends fflib_StringBuilder { String itemPrefix = ''; String delimiter = ','; - public CommaDelimitedListBuilder() {} + @NamespaceAccessible + public CommaDelimitedListBuilder() {} - public CommaDelimitedListBuilder(List values) + @NamespaceAccessible + public CommaDelimitedListBuilder(List values) { super(values); } - public void setItemPrefix(String itemPrefix) + @NamespaceAccessible + public void setItemPrefix(String itemPrefix) { this.itemPrefix = itemPrefix; } - public void setDelimiter(String delimiter) + @NamespaceAccessible + public void setDelimiter(String delimiter) { this.delimiter = delimiter; } - public String getStringValue(String itemPrefix) + @NamespaceAccessible + public String getStringValue(String itemPrefix) { setItemPrefix(itemPrefix); return toString(); } - public override String toString() + @NamespaceAccessible + public override String toString() { return itemPrefix + String.join(buffer, delimiter + itemPrefix); } @@ -115,14 +129,17 @@ public virtual class fflib_StringBuilder /** * Subclasses the StringCommaDelimitedBuilder to accept native SObjectField tokens and optional FieldSet definitions to concatinate when building queries **/ - public virtual with sharing class FieldListBuilder extends CommaDelimitedListBuilder + @NamespaceAccessible + public virtual with sharing class FieldListBuilder extends CommaDelimitedListBuilder { - public FieldListBuilder(List values) + @NamespaceAccessible + public FieldListBuilder(List values) { this(values, null); } - public FieldListBuilder(List values, List fieldSets) + @NamespaceAccessible + public FieldListBuilder(List values, List fieldSets) { // Create a distinct set of fields (or field paths) to select for(Schema.SObjectField value : values) @@ -138,14 +155,17 @@ public virtual class fflib_StringBuilder /** * Subclasses the FieldListBuilder to auto sense and include when needed the CurrencyIsoCode field in the field list **/ - public with sharing class MultiCurrencyFieldListBuilder extends FieldListBuilder + @NamespaceAccessible + public with sharing class MultiCurrencyFieldListBuilder extends FieldListBuilder { - public MultiCurrencyFieldListBuilder(List values) + @NamespaceAccessible + public MultiCurrencyFieldListBuilder(List values) { this(values, null); } - public MultiCurrencyFieldListBuilder(List values, List fieldSets) + @NamespaceAccessible + public MultiCurrencyFieldListBuilder(List values, List fieldSets) { super(values, fieldSets); From 7a278f39c1135d17e16ae20697ea22dde7c5ff39 Mon Sep 17 00:00:00 2001 From: nwcm <111259588+nwcm@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:57:49 +1100 Subject: [PATCH 2/2] fix deployment failures --- .../main/classes/fflib_SObjectDescribe.cls | 7 ++--- .../main/classes/fflib_SObjectUnitOfWork.cls | 29 +++---------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls index 627f48b1a85..9afd158bf7c 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls @@ -294,11 +294,11 @@ public class fflib_SObjectDescribe { return null; } } - @NamespaceAccessible + public virtual Boolean containsKey(String name){ return this.containsKey(name, true); } - @NamespaceAccessible + public virtual Boolean containsKey(String name, Boolean implyNamespace){ if(name == null) //short-circuit lookup logic since null can't possibly be a valid field name, and it saves us null checking return null; @@ -308,7 +308,6 @@ public class fflib_SObjectDescribe { implyNamespace && values.containsKey(name.toLowerCase()) ); } - @NamespaceAccessible public virtual Integer size(){ return values.size(); } @@ -316,11 +315,9 @@ public class fflib_SObjectDescribe { * Returns the key set of the map. * Note: unlike other NamespacedAttributeMap methods keySet defaults implyNamespace to false if not specified. **/ - @NamespaceAccessible public virtual Set keySet(){ return this.keySet(false); } - @NamespaceAccessible public virtual Set keySet(Boolean implyNamespace){ if(implyNamespace){ Set result = new Set(); diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls index 6685b8cc326..509833bc389 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls @@ -865,8 +865,7 @@ public virtual class fflib_SObjectUnitOfWork { private List m_relationships = new List(); - @NamespaceAccessible - public void resolve() + public void resolve() { // Resolve relationships for (IRelationship relationship : m_relationships) @@ -877,8 +876,7 @@ public virtual class fflib_SObjectUnitOfWork } - @NamespaceAccessible - public void add(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId) + public void add(SObject record, Schema.SObjectField relatedToField, Schema.SObjectField externalIdField, Object externalId) { if (relatedToField == null) { throw new UnitOfWorkException('Invalid argument: relatedToField.'); @@ -914,8 +912,7 @@ public virtual class fflib_SObjectUnitOfWork m_relationships.add(relationship); } - @NamespaceAccessible - public void add(SObject record, Schema.SObjectField relatedToField, SObject relatedTo) + public void add(SObject record, Schema.SObjectField relatedToField, SObject relatedTo) { // Relationship to resolve Relationship relationship = new Relationship(); @@ -925,8 +922,7 @@ public virtual class fflib_SObjectUnitOfWork m_relationships.add(relationship); } - @NamespaceAccessible - public void add(Messaging.SingleEmailMessage email, SObject relatedTo) + public void add(Messaging.SingleEmailMessage email, SObject relatedTo) { EmailRelationship emailRelationship = new EmailRelationship(); emailRelationship.email = email; @@ -942,20 +938,13 @@ public virtual class fflib_SObjectUnitOfWork private class RelationshipByExternalId implements IRelationship { - @NamespaceAccessible public SObject Record; - @NamespaceAccessible public Schema.SObjectField RelatedToField; - @NamespaceAccessible public Schema.SObjectType RelatedTo; - @NamespaceAccessible public String RelationshipName; - @NamespaceAccessible public Schema.SObjectField ExternalIdField; - @NamespaceAccessible public Object ExternalId; - @NamespaceAccessible public void resolve() { SObject relationshipObject = this.RelatedTo.newSObject(); @@ -966,14 +955,10 @@ public virtual class fflib_SObjectUnitOfWork private class Relationship implements IRelationship { - @NamespaceAccessible public SObject Record; - @NamespaceAccessible public Schema.SObjectField RelatedToField; - @NamespaceAccessible public SObject RelatedTo; - @NamespaceAccessible public void resolve() { this.Record.put( this.RelatedToField, this.RelatedTo.Id); @@ -982,12 +967,9 @@ public virtual class fflib_SObjectUnitOfWork private class EmailRelationship implements IRelationship { - @NamespaceAccessible public Messaging.SingleEmailMessage email; - @NamespaceAccessible public SObject relatedTo; - @NamespaceAccessible public void resolve() { this.email.setWhatId( this.relatedTo.Id ); @@ -1013,19 +995,16 @@ public virtual class fflib_SObjectUnitOfWork { private List emails; - @NamespaceAccessible public SendEmailWork() { this.emails = new List(); } - @NamespaceAccessible public void registerEmail(Messaging.Email email) { this.emails.add(email); } - @NamespaceAccessible public void doWork() { if (emails.size() > 0) Messaging.sendEmail(emails);