private ObjectAction getAction(
     final List<ObjectAction> availableActions, final ActionType type, final String id) {
   if (id == null) {
     return null;
   }
   outer:
   for (int i = 0; i < availableActions.size(); i++) {
     final ObjectAction action = availableActions.get(i);
     if (action.getActions().size() > 0) {
       // deal with action set
       final ObjectAction a = getAction(action.getActions(), type, id);
       if (a != null) {
         return a;
       }
     } else {
       // regular action
       if (!type.matchesTypeOf(action)) {
         continue outer;
       }
       if (id.equals(action.getIdentifier().toNameParmsIdentityString())) {
         return action;
       }
       if (id.equals(action.getIdentifier().toNameIdentityString())) {
         return action;
       }
       continue outer;
     }
   }
   return null;
 }
 private static Map<ActionType, List<ObjectAction>> createObjectActionsByType() {
   final Map<ActionType, List<ObjectAction>> map = Maps.newHashMap();
   for (final ActionType type : ActionType.values()) {
     map.put(type, Lists.<ObjectAction>newArrayList());
   }
   return map;
 }
 @Override
 public ObjectAction getObjectAction(final String id) {
   for (final ActionType type : ActionType.values()) {
     final ObjectAction action = getObjectAction(type, id);
     if (action != null) {
       return action;
     }
   }
   return null;
 }
  protected void sortCacheAndUpdateActions(final List<ObjectAction> objectActions) {
    final List<ObjectAction> orderedActions = sortActions(objectActions);
    synchronized (this.objectActions) {
      this.objectActions.clear();
      this.objectActions.addAll(orderedActions);

      for (final ActionType type : ActionType.values()) {
        final List<ObjectAction> objectActionForType = objectActionsByType.get(type);
        objectActionForType.clear();
        objectActionForType.addAll(
            Collections2.filter(objectActions, ObjectAction.Predicates.ofType(type)));
      }
    }
  }