Examples of ShouldNeverHappenException


Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

    public CryptoEngineImpl() {
        try {
            this.secureRandom = SecureRandom.getInstance("SHA1PRNG");
        }
        catch (NoSuchAlgorithmException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] result = digest.digest(data);
            return result;
        }
        catch (NoSuchAlgorithmException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

            KeyGenerator keyGenerator = KeyGenerator.getInstance(ENCRYPTION_ALGORITHM);
            keyGenerator.init(KEY_SIZE_IN_BITS, secureRandom);
            return keyGenerator.generateKey();
        }
        catch (NoSuchAlgorithmException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

        }
        try {
            return s.getBytes("UTF-8");
        }
        catch (UnsupportedEncodingException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

            byte[] encrypted = cipher.doFinal(data);
            return encrypted;
        }
        catch (GeneralSecurityException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

        }
        try {
            return new String(bytes, "UTF-8");
        }
        catch (UnsupportedEncodingException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.googlecode.memwords.domain.ShouldNeverHappenException

                firstLine = false;
            }
            return builder.toString();
        }
        catch (IOException e) {
            throw new ShouldNeverHappenException(e);
        }
    }
View Full Code Here

Examples of com.serotonin.ShouldNeverHappenException

  @Override
  public TranslatableMessage getConfigurationDescription() {
    ChangeTypeVO changeType = getChangeType();
    if (changeType == null)
      throw new ShouldNeverHappenException("unknown change type");
    return changeType.getDescription();
  }
View Full Code Here

Examples of com.serotonin.ShouldNeverHappenException

                    return new CronTimerTrigger(vo.getActiveCron());
                return new CronTimerTrigger(vo.getInactiveCron());
            }
            catch (ParseException e) {
                // Should never happen, so wrap and rethrow
                throw new ShouldNeverHappenException(e);
            }
        }

        if (vo.getScheduleType() == ScheduledEventVO.TYPE_ONCE) {
            DateTime dt;
            if (activeTrigger)
                dt = new DateTime(vo.getActiveYear(), vo.getActiveMonth(), vo.getActiveDay(), vo.getActiveHour(),
                        vo.getActiveMinute(), vo.getActiveSecond(), 0);
            else
                dt = new DateTime(vo.getInactiveYear(), vo.getInactiveMonth(), vo.getInactiveDay(),
                        vo.getInactiveHour(), vo.getInactiveMinute(), vo.getInactiveSecond(), 0);
            return new OneTimeTrigger(new Date(dt.getMillis()));
        }

        int month = vo.getActiveMonth();
        int day = vo.getActiveDay();
        int hour = vo.getActiveHour();
        int minute = vo.getActiveMinute();
        int second = vo.getActiveSecond();
        if (!activeTrigger) {
            month = vo.getInactiveMonth();
            day = vo.getInactiveDay();
            hour = vo.getInactiveHour();
            minute = vo.getInactiveMinute();
            second = vo.getInactiveSecond();
        }

        StringBuilder expression = new StringBuilder();
        expression.append(second).append(' ');
        expression.append(minute).append(' ');
        if (vo.getScheduleType() == ScheduledEventVO.TYPE_HOURLY)
            expression.append("* * * ?");
        else {
            expression.append(hour).append(' ');
            if (vo.getScheduleType() == ScheduledEventVO.TYPE_DAILY)
                expression.append("* * ?");
            else if (vo.getScheduleType() == ScheduledEventVO.TYPE_WEEKLY)
                expression.append("? * ").append(weekdays[day]);
            else {
                if (day > 0)
                    expression.append(day);
                else if (day == -1)
                    expression.append('L');
                else
                    expression.append(-day).append('L');

                if (vo.getScheduleType() == ScheduledEventVO.TYPE_MONTHLY)
                    expression.append(" * ?");
                else
                    expression.append(' ').append(month).append(" ?");
            }
        }

        CronTimerTrigger cronTrigger;
        try {
            cronTrigger = new CronTimerTrigger(expression.toString());
        }
        catch (ParseException e) {
            // Should never happen, so wrap and rethrow
            throw new ShouldNeverHappenException(e);
        }
        return cronTrigger;
    }
View Full Code Here

Examples of com.serotonin.ShouldNeverHappenException

                message = new TranslatableMessage("event.schedule.cronUntil", activeCron, inactiveCron);
            else
                message = new TranslatableMessage("event.schedule.cronAt", activeCron);
        }
        else
            throw new ShouldNeverHappenException("Unknown schedule type: " + scheduleType);

        return message;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.