-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-26900-pass-field-variables-binary-fi…
…eld-monaco
- Loading branch information
Showing
29 changed files
with
1,039 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
dotCMS/src/main/java/com/dotcms/business/bytebuddy/EnterpriseFeatureAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.dotcms.business.bytebuddy; | ||
|
||
import com.dotcms.enterprise.LicenseUtil; | ||
import com.dotcms.enterprise.license.DotInvalidLicenseException; | ||
import com.dotcms.enterprise.license.LicenseLevel; | ||
import com.dotcms.util.EnterpriseFeature; | ||
import net.bytebuddy.asm.Advice; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* This Advice class handles the behavior of the @{@link EnterpriseFeature} Annotation. | ||
* | ||
* @author Jose Castro | ||
* @since Jan 23rd, 2024 | ||
*/ | ||
public class EnterpriseFeatureAdvice { | ||
|
||
/** | ||
* Checks that the specified Enterprise License level requirement is met. It allows for all | ||
* License levels that are equal or greater than the one set in the Annotation. | ||
* | ||
* @param method The method that has been annotated with @{@link EnterpriseFeature} | ||
*/ | ||
@Advice.OnMethodEnter | ||
static void enter(final @Advice.Origin Method method) { | ||
final LicenseLevel licenseLevel = | ||
method.getAnnotation(EnterpriseFeature.class).licenseLevel(); | ||
final String errorMsg = method.getAnnotation(EnterpriseFeature.class).errorMsg(); | ||
final int currenLicenseLevel = LicenseUtil.getLevel(); | ||
if (currenLicenseLevel < licenseLevel.level) { | ||
throw new DotInvalidLicenseException(errorMsg); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.