示例#1
0
文件: View.java 项目: zlosch/jenkins
 public Object getDynamic(String token) {
   for (Action a : getActions()) {
     String url = a.getUrlName();
     if (url == null) continue;
     if (a.getUrlName().equals(token)) return a;
   }
   return null;
 }
示例#2
0
文件: User.java 项目: nahi/jenkins
 public Object getDynamic(String token) {
   for (UserProperty property : getProperties().values()) {
     if (property instanceof Action) {
       Action a = (Action) property;
       if (a.getUrlName().equals(token) || a.getUrlName().equals('/' + token)) return a;
     }
   }
   return null;
 }
  public void actions(Item item, int uriStart, Request request, Response response)
      throws ActionHandlerException {

    int i = uriStart;
    int l = request.getRequestParts().length;
    Action action = null;
    Item lastItem = item;
    String urlName = "index";
    for (; i < l; i++) {
      urlName = request.getRequestParts()[i];
      logger.debug("Url name is " + urlName);

      lastItem = item;
      action = null;

      if (item instanceof Actionable) {
        for (Action a : ((Actionable) item).getActions()) {
          logger.debug("Action is " + a);
          if (a.getUrlName().equals(urlName)) {
            action = a;
            break;
          }
        }
        item = (Item) action;
      } else {
        i++;
        break;
      }

      if (action == null) {
        logger.debug("Action was null, breaking");
        i++;
        break;
      }
    }

    logger.debug("[Action method] " + urlName + " -> " + action + "/" + lastItem);

    if (action != null) {
      /* Last sub space was an action, do its index method */
      logger.debug("Action was NOT null");
      executeThing(request, response, action, "index");
    } else {
      // i:3  l:3
      // if( i == l - 1 ) {
      if (i == l) {
        /* We came to an end */
        logger.debug("Action was null");
        executeThing(request, response, lastItem, urlName);

      } else {
        throw new ActionHandlerException(urlName + " not defined for " + lastItem);
      }
    }
  }