Skip to content

Commit

Permalink
resolve requested changes in PR (#2275)
Browse files Browse the repository at this point in the history
Signed-off-by: CT\pgoran <goran.palibrk@comtrade.com>
  • Loading branch information
ct-goranpalibrk authored and Coduz committed Jan 15, 2019
1 parent c5db86f commit ae517fc
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 81 deletions.
Expand Up @@ -41,5 +41,7 @@ public enum GwtKapuaErrorCode {
ENTITY_ALREADY_EXIST_IN_ANOTHER_ACCOUNT,
SELF_LIMIT_EXCEEDED_IN_CONFIG,
MAX_NUMBER_OF_ITEMS_REACHED,
OPERATION_NOT_ALLOWED_ON_ADMIN_USER
OPERATION_NOT_ALLOWED_ON_ADMIN_USER,
RETRY_AND_CRON_BOTH_SELECTED,
SAME_START_AND_DATE
}
Expand Up @@ -131,6 +131,10 @@ public static void handle(Throwable t) throws GwtKapuaException {
throw new GwtKapuaException(GwtKapuaErrorCode.MAX_NUMBER_OF_ITEMS_REACHED, t, ((KapuaMaxNumberOfItemsReachedException) t).getArgValue());
} else if (t instanceof DeviceMenagementException) {
throw new GwtKapuaException(GwtKapuaErrorCode.valueOf(((DeviceMenagementException)t).getCode().name()), t, t.getLocalizedMessage());
} else if (t instanceof KapuaException && ((KapuaException) t).getCode() == (KapuaErrorCodes.SAME_START_AND_DATE)){
throw new GwtKapuaException(GwtKapuaErrorCode.SAME_START_AND_DATE, t, t.getLocalizedMessage());
} else if (t instanceof KapuaException && ((KapuaException) t).getCode() == (KapuaErrorCodes.RETRY_AND_CRON_BOTH_SELECTED)){
throw new GwtKapuaException(GwtKapuaErrorCode.RETRY_AND_CRON_BOTH_SELECTED, t, t.getLocalizedMessage());
} else {
// all others => log and throw internal error code
logger.warn("RPC service non-application error", t);
Expand Down
Expand Up @@ -83,6 +83,8 @@ OPERATION_NOT_ALLOWED_ON_ADMIN_USER=Operation not allowed on admin user. It cann
DEVICE_NEVER_CONNECTED=The device was never connected.
DEVICE_NOT_CONNECTED=The device is not connected.
REQUEST_BAD_METHOD=The requested method is not valid.
SAME_START_AND_DATE=Start and end time cannot be at the same point in time. Please change the parameters.
RETRY_AND_CRON_BOTH_SELECTED=There should only be one scheduling parameter - either Retry interval or Cron schedule.

text=Text
textTooltip=Text Tooltip
Expand Down
Expand Up @@ -323,9 +323,14 @@ public void onFailure(Throwable cause) {
GwtKapuaException gwtCause = (GwtKapuaException) cause;
if (gwtCause.getCode().equals(GwtKapuaErrorCode.DUPLICATE_NAME)) {
triggerName.markInvalid(gwtCause.getMessage());
} else if (gwtCause.getCode().equals(GwtKapuaErrorCode.INTERNAL_ERROR)) {
cronExpression.markInvalid(cause.getMessage());
retryInterval.markInvalid(cause.getMessage());
} else if (gwtCause.getCode().equals(GwtKapuaErrorCode.RETRY_AND_CRON_BOTH_SELECTED)) {
cronExpression.markInvalid(gwtCause.getMessage());
retryInterval.markInvalid(gwtCause.getMessage());
} else if (gwtCause.getCode().equals(GwtKapuaErrorCode.SAME_START_AND_DATE)) {
startsOn.markInvalid(gwtCause.getMessage());
startsOnTime.markInvalid(gwtCause.getMessage());
endsOn.markInvalid(gwtCause.getMessage());
endsOnTime.markInvalid(gwtCause.getMessage());
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions service/api/src/main/java/org/eclipse/kapua/KapuaErrorCodes.java
Expand Up @@ -97,4 +97,14 @@ public enum KapuaErrorCodes implements KapuaErrorCode {
*/
MAX_NUMBER_OF_ITEMS_REACHED,

/**
* Same values start and end date and time
*/
SAME_START_AND_DATE,

/**
* retry interval and cron expression both selected
*/
RETRY_AND_CRON_BOTH_SELECTED;

}
Expand Up @@ -26,4 +26,5 @@ BUNDLE_START_ERROR=Bundle could not be started. Please check the device log for
BUNDLE_STOP_ERROR=Bundle could not be stopped. Please check the device log for errors.
MAX_NUMBER_OF_ITEMS_REACHED=Max number of {0} reached. Please increase the number or set InfiniteChild{0} parameter to True.
USER_ALREADY_RESERVED_BY_ANOTHER_CONNECTION=This user is already reserved for another connection. Please select different user for this connection.
RETRY_OR_CRON_INTERVAL=There should only be one scheduling parameter - either Retry interval or Cron schedule.
RETRY_AND_CRON_BOTH_SELECTED=There should only be one scheduling parameter - either Retry interval or Cron schedule.
SAME_START_AND_DATE=Start and end time cannot be at the same point in time. Please change the parameters.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -13,6 +13,7 @@

import org.eclipse.kapua.KapuaDuplicateNameException;
import org.eclipse.kapua.KapuaEntityNotFoundException;
import org.eclipse.kapua.KapuaErrorCodes;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.commons.configuration.AbstractKapuaConfigurableResourceLimitedService;
import org.eclipse.kapua.commons.model.id.KapuaEid;
Expand All @@ -28,7 +29,6 @@
import org.eclipse.kapua.service.authorization.AuthorizationService;
import org.eclipse.kapua.service.authorization.permission.PermissionFactory;
import org.eclipse.kapua.service.scheduler.SchedulerDomains;
import org.eclipse.kapua.service.scheduler.trigger.RetryIntervalAndCronSelectedException;
import org.eclipse.kapua.service.scheduler.trigger.Trigger;
import org.eclipse.kapua.service.scheduler.trigger.TriggerAttributes;
import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator;
Expand Down Expand Up @@ -98,7 +98,11 @@ public Trigger create(TriggerCreator triggerCreator) throws KapuaException {
}

if (triggerCreator.getRetryInterval() != null && triggerCreator.getCronScheduling() != null) {
throw new RetryIntervalAndCronSelectedException(triggerCreator.getScopeId());
throw new KapuaException(KapuaErrorCodes.RETRY_AND_CRON_BOTH_SELECTED);
}

if (triggerCreator.getStartsOn().equals(triggerCreator.getEndsOn()) && triggerCreator.getStartsOn().getTime() == (triggerCreator.getEndsOn().getTime())) {
throw new KapuaException(KapuaErrorCodes.SAME_START_AND_DATE);
}

//
Expand Down

0 comments on commit ae517fc

Please sign in to comment.