diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index b7b160f..11b0386 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -13,13 +13,13 @@ jobs: java-version: "17" distribution: "temurin" server-id: central - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD + server-username: CENTRAL_PORTAL_USERNAME + server-password: CENTRAL_PORTAL_PASSWORD gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} gpg-passphrase: MAVEN_GPG_PASSPHRASE - name: Publish to Central Repository env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + CENTRAL_PORTAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }} + CENTRAL_PORTAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} run: mvn --batch-mode deploy diff --git a/.gitignore b/.gitignore index 14e2f07..390e3b9 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,4 @@ target/ .idea # MacOS -.DS_Store +.DS_Store \ No newline at end of file diff --git a/.metals/.reports/metals-full/2026-03-04/r_empty-definition_13-04-12-679.md b/.metals/.reports/metals-full/2026-03-04/r_empty-definition_13-04-12-679.md new file mode 100644 index 0000000..c815593 --- /dev/null +++ b/.metals/.reports/metals-full/2026-03-04/r_empty-definition_13-04-12-679.md @@ -0,0 +1,143 @@ +error id: file:///Desktop/Trabajo/Te%CC%81cnico%202023%20(corto)/feature-toggling-java/src/main/java/io/github/isagroup/annotations/PricingPlanAwareAspect.java: +file:///Desktop/Trabajo/Te%CC%81cnico%202023%20(corto)/feature-toggling-java/src/main/java/io/github/isagroup/annotations/PricingPlanAwareAspect.java +empty definition using pc, found symbol in pc: +empty definition using semanticdb +empty definition using fallback +non-local guesses: + +offset: 1071 +uri: file:///Desktop/Trabajo/Te%CC%81cnico%202023%20(corto)/feature-toggling-java/src/main/java/io/github/isagroup/annotations/PricingPlanAwareAspect.java +text: +```scala +package io.github.isagroup.annotations; + +import java.util.Map; +import java.util.Optional; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import io.github.isagroup.PricingContext; +import io.github.isagroup.exceptions.PricingPlanEvaluationException; +import io.github.isagroup.models.Feature; +import io.github.isagroup.models.FeatureStatus; +import io.github.isagroup.models.PlanContextManager; +import io.github.isagroup.models.PricingManager; + +@Aspect +@Component +public class PricingPlanAwareAspect { + + @Autowired + private PricingContext pricingContext; + + @Around("@annotation(pricingPlanAware)") + @Transactional(rollbackFor = PricingPlanEvaluationException.class) + public Object validatePricingPlan(ProceedingJoinPoint joinPoint, PricingPlanAware pricingPlanAware) + throws Throwable, PricingPlanEvaluationException { + + Object@@ proceed = joinPoint.proceed(); + + String featureId = pricingPlanAware.featureName(); + + // Realizar la evaluación del contexto utilizando el valor de "featureId" + Boolean contextEvaluation = evaluateContext(featureId); + + if (contextEvaluation == null) { + contextEvaluation = false; + } + + if (!contextEvaluation) { + throw new PricingPlanEvaluationException("You have reached the limit of the feature: " + featureId); + } + + return proceed; + } + + private Boolean evaluateContext(String featureName) { + + PlanContextManager planContextManager = new PlanContextManager(); + + try{ + planContextManager.setUserContext(pricingContext.getUserContext()); + planContextManager.setPlanContext(pricingContext.getPlanContext()); + }catch(NullPointerException e){ + throw new PricingPlanEvaluationException("The pricing context is null. Please, chech the path to the configuration file."); + } + + PricingManager pricingManager = pricingContext.getPricingManager(); + + Map features = pricingManager.getFeatures(); + Feature feature = features.get(featureName); + + if (feature == null) { + throw new PricingPlanEvaluationException("The feature " + featureName + " does not exist in the current pricing configuration"); + } + + FeatureStatus featureStatus = new FeatureStatus(); + + String expression; + + if (feature.getServerExpression() != null) { + expression = feature.getServerExpression(); + } else { + expression = feature.getExpression(); + } + + Boolean eval = FeatureStatus.computeFeatureEvaluation(expression, planContextManager) + .orElseThrow(() -> new PricingPlanEvaluationException("Evaluation was null")); + featureStatus.setEval(eval); + + Optional userContextKey = FeatureStatus.computeUserContextVariable(expression); + + if (!userContextKey.isPresent()) { + featureStatus.setUsed(null); + featureStatus.setLimit(null); + } else { + featureStatus.setUsed(planContextManager.getUserContext().get(userContextKey.get())); + featureStatus.setLimit(planContextManager.getPlanContext().get(featureName)); + } + + return featureStatus.getEval(); + + // Map userContext = pricingContext.getUserContext(); + // Map planContext = pricingContext.getPlanContext(); + // Map evaluationContext = pricingContext.getFeatures(); + + // PlanContextManager planContextManager = new PlanContextManager(); + + // planContextManager.setUserContext(userContext); + // planContextManager.setPlanContext(planContext); + + // try { + // String expression = evaluationContext.get(featureId).getServerExpression(); + + // if (expression == null) { + // expression = evaluationContext.get(featureId).getExpression(); + // } + + // if (!expression.trim().equals("")) { + + // ExpressionParser parser = new SpelExpressionParser(); + // EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build(); + + // return parser.parseExpression(expression).getValue(context, planContextManager, Boolean.class); + // } else { + // return false; + // } + // } catch (NullPointerException e) { + // throw new PricingPlanEvaluationException( + // "The feature " + featureId + " does not exist in the current pricing configuration"); + // } + + } +} +``` + + +#### Short summary: + +empty definition using pc, found symbol in pc: \ No newline at end of file diff --git a/.metals/.reports/metals-full/2026-03-04/r_empty-definition_13-04-12-684.md b/.metals/.reports/metals-full/2026-03-04/r_empty-definition_13-04-12-684.md new file mode 100644 index 0000000..d192d7d --- /dev/null +++ b/.metals/.reports/metals-full/2026-03-04/r_empty-definition_13-04-12-684.md @@ -0,0 +1,143 @@ +error id: file:///Desktop/Trabajo/Te%CC%81cnico%202023%20(corto)/feature-toggling-java/src/main/java/io/github/isagroup/annotations/PricingPlanAwareAspect.java:java/lang/Object# +file:///Desktop/Trabajo/Te%CC%81cnico%202023%20(corto)/feature-toggling-java/src/main/java/io/github/isagroup/annotations/PricingPlanAwareAspect.java +empty definition using pc, found symbol in pc: java/lang/Object# +empty definition using semanticdb +empty definition using fallback +non-local guesses: + +offset: 1065 +uri: file:///Desktop/Trabajo/Te%CC%81cnico%202023%20(corto)/feature-toggling-java/src/main/java/io/github/isagroup/annotations/PricingPlanAwareAspect.java +text: +```scala +package io.github.isagroup.annotations; + +import java.util.Map; +import java.util.Optional; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import io.github.isagroup.PricingContext; +import io.github.isagroup.exceptions.PricingPlanEvaluationException; +import io.github.isagroup.models.Feature; +import io.github.isagroup.models.FeatureStatus; +import io.github.isagroup.models.PlanContextManager; +import io.github.isagroup.models.PricingManager; + +@Aspect +@Component +public class PricingPlanAwareAspect { + + @Autowired + private PricingContext pricingContext; + + @Around("@annotation(pricingPlanAware)") + @Transactional(rollbackFor = PricingPlanEvaluationException.class) + public Object validatePricingPlan(ProceedingJoinPoint joinPoint, PricingPlanAware pricingPlanAware) + throws Throwable, PricingPlanEvaluationException { + + @@Object proceed = joinPoint.proceed(); + + String featureId = pricingPlanAware.featureName(); + + // Realizar la evaluación del contexto utilizando el valor de "featureId" + Boolean contextEvaluation = evaluateContext(featureId); + + if (contextEvaluation == null) { + contextEvaluation = false; + } + + if (!contextEvaluation) { + throw new PricingPlanEvaluationException("You have reached the limit of the feature: " + featureId); + } + + return proceed; + } + + private Boolean evaluateContext(String featureName) { + + PlanContextManager planContextManager = new PlanContextManager(); + + try{ + planContextManager.setUserContext(pricingContext.getUserContext()); + planContextManager.setPlanContext(pricingContext.getPlanContext()); + }catch(NullPointerException e){ + throw new PricingPlanEvaluationException("The pricing context is null. Please, chech the path to the configuration file."); + } + + PricingManager pricingManager = pricingContext.getPricingManager(); + + Map features = pricingManager.getFeatures(); + Feature feature = features.get(featureName); + + if (feature == null) { + throw new PricingPlanEvaluationException("The feature " + featureName + " does not exist in the current pricing configuration"); + } + + FeatureStatus featureStatus = new FeatureStatus(); + + String expression; + + if (feature.getServerExpression() != null) { + expression = feature.getServerExpression(); + } else { + expression = feature.getExpression(); + } + + Boolean eval = FeatureStatus.computeFeatureEvaluation(expression, planContextManager) + .orElseThrow(() -> new PricingPlanEvaluationException("Evaluation was null")); + featureStatus.setEval(eval); + + Optional userContextKey = FeatureStatus.computeUserContextVariable(expression); + + if (!userContextKey.isPresent()) { + featureStatus.setUsed(null); + featureStatus.setLimit(null); + } else { + featureStatus.setUsed(planContextManager.getUserContext().get(userContextKey.get())); + featureStatus.setLimit(planContextManager.getPlanContext().get(featureName)); + } + + return featureStatus.getEval(); + + // Map userContext = pricingContext.getUserContext(); + // Map planContext = pricingContext.getPlanContext(); + // Map evaluationContext = pricingContext.getFeatures(); + + // PlanContextManager planContextManager = new PlanContextManager(); + + // planContextManager.setUserContext(userContext); + // planContextManager.setPlanContext(planContext); + + // try { + // String expression = evaluationContext.get(featureId).getServerExpression(); + + // if (expression == null) { + // expression = evaluationContext.get(featureId).getExpression(); + // } + + // if (!expression.trim().equals("")) { + + // ExpressionParser parser = new SpelExpressionParser(); + // EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build(); + + // return parser.parseExpression(expression).getValue(context, planContextManager, Boolean.class); + // } else { + // return false; + // } + // } catch (NullPointerException e) { + // throw new PricingPlanEvaluationException( + // "The feature " + featureId + " does not exist in the current pricing configuration"); + // } + + } +} +``` + + +#### Short summary: + +empty definition using pc, found symbol in pc: java/lang/Object# \ No newline at end of file diff --git a/.metals/metals.lock.db b/.metals/metals.lock.db new file mode 100644 index 0000000..9841037 --- /dev/null +++ b/.metals/metals.lock.db @@ -0,0 +1,6 @@ +#FileLock +#Wed Mar 04 12:48:52 CET 2026 +hostName=localhost +id=19cb8aded380c6d8d40c3013006ee896531aa3dc8cb +method=file +server=localhost\:56039 diff --git a/.metals/metals.mv.db b/.metals/metals.mv.db new file mode 100644 index 0000000..ddd5ffd Binary files /dev/null and b/.metals/metals.mv.db differ