コード例 #1
0
ファイル: Character.java プロジェクト: JNVgames/Betrayal
 public String getTrait(Trait trait) {
   switch (trait) {
     case GENDER:
       return preview.gender.getInitial();
     case HAIR_STYLE:
       if (preview.gender == Gender.MALE) return Integer.toString(preview.maleHair);
       else return Integer.toString(preview.femaleHair);
     case HAIR_COLOR:
       if (preview.gender == Gender.MALE) return Integer.toString(preview.hairColor);
       else return Integer.toString(preview.hairColor);
     case JOB:
       return job.getJob().getInitial();
     default:
       return null;
   }
 }
コード例 #2
0
ファイル: PutFileRequest.java プロジェクト: tiggi/dcache
    @Override
    public void run() {
      try {
        PutFileRequest fr = Job.getJob(fileRequestJobId, PutFileRequest.class);

        try {
          String fileId = future.checkedGet();

          State state = fr.getState();
          switch (state) {
            case INPROGRESS:
              logger.trace("Storage info arrived for file {}.", fr.getSurlString());
              fr.setFileId(fileId);
              fr.saveJob(true);
              Scheduler.getScheduler(fr.getSchedulerId()).execute(fr);
              break;
            case CANCELED:
            case FAILED:
              fr.getStorage().abortPut(fr.getUser(), fileId, fr.getSurl(), fr.getErrorMessage());
              break;
            default:
              logger.error("Put request is in an unexpected state in callback: {}", state);
              fr.getStorage().abortPut(fr.getUser(), fileId, fr.getSurl(), fr.getErrorMessage());
              break;
          }
        } catch (SRMException e) {
          fr.setStateAndStatusCode(State.FAILED, e.getMessage(), e.getStatusCode());
        }
      } catch (IllegalStateTransition ist) {
        if (!ist.getFromState().isFinal()) {
          logger.error(ist.getMessage());
        }
      } catch (SRMInvalidRequestException e) {
        try {
          String fileId = future.checkedGet();
          SRM.getSRM()
              .getStorage()
              .abortPut(user, fileId, surl, "Request was aborted while being prepared.");
        } catch (SRMException ignored) {
        }
      }
    }