If available, makes a call to update the cache with the provided result

@param response the new result to update the cache with
@throws BoxException thrown if there was an issue updating cache for given response.
962214
protected void handleUpdateCache(BoxResponse<T> response) throws BoxException {
        BoxCache cache = BoxConfig.getCache();
        if (cache != null) {
            cache.put(response);
        }
    }
1123347
public void setCache(String cacheName, String cacheKey, Object object) {
        Cache cache = cacheManager.getCache(cacheName);
        if (cache == null) {
            return;
        }
        cache.put(new Element(cacheKey, object));
    }
1098307
public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
        return new Response<T>(result, cacheEntry);
    }
123509
public void refresh() {
        this.refreshLock.writeLock().lock();

        if (!this.canRefresh()) {
            this.refreshLock.writeLock().unlock();
            throw new IllegalStateException("The BoxAPIConnection cannot be refreshed because it doesn't have a "
                + "refresh token.");
        }

        URL url = null;
        try {
            url = new URL(this.tokenURL);
        } catch (MalformedURLException e) {
            this.refreshLock.writeLock().unlock();
            assert false : "An invalid refresh URL indicates a bug in the SDK.";
            throw new RuntimeException("An invalid refresh URL indicates a bug in the SDK.", e);
        }

        String urlParameters = String.format("grant_type=refresh_token&refresh_token=%s&client_id=%s&client_secret=%s",
            this.refreshToken, this.clientID, this.clientSecret);

        BoxAPIRequest request = new BoxAPIRequest(this, url, "POST");
        request.shouldAuthenticate(false);
        request.setBody(urlParameters);

        String json;
        try {
            BoxJSONResponse response = (BoxJSONResponse) request.send();
            json = response.getJSON();
        } catch (BoxAPIException e) {
            this.notifyError(e);
            this.refreshLock.writeLock().unlock();
            throw e;
        }

        JsonObject jsonObject = JsonObject.readFrom(json);
        this.accessToken = jsonObject.get("access_token").asString();
        this.refreshToken = jsonObject.get("refresh_token").asString();
        this.lastRefresh = System.currentTimeMillis();
        this.expires = jsonObject.get("expires_in").asLong() * 1000;

        this.notifyRefresh();

        this.refreshLock.writeLock().unlock();
    }
425481
private void processReturnOperations(final ResponseMessage response) {
    final List<OperationMessage> ops = response.getOperations();

    // If there are no observable effects, this will be null
    if (ops == null) {
      return;
    }

    for (final OperationMessage op : ops) {
      final SimpleProxyId<?> id = this.getId(op);
      WriteOperation[] toPropagate = null;

      // May be null if the server is returning an unpersisted object
      final WriteOperation effect = op.getOperation();
      if (effect != null) {
        switch (effect) {
          case DELETE:
            toPropagate = DELETE_ONLY;
            break;
          case PERSIST:
            toPropagate = PERSIST_AND_UPDATE;
            break;
          case UPDATE:
            toPropagate = UPDATE_ONLY;
            break;
          default:
            // Should never reach here
            throw new RuntimeException(effect.toString());
        }
      }
      this.processReturnOperation(id, op, toPropagate);
    }

    assert this.state.returnedProxies.size() == ops.size();
  }
837869
@SneakyThrows
    public static void render(final HttpServletResponse response) {
        val map = new HashMap<String, Object>();
        response.setStatus(HttpServletResponse.SC_OK);
        render(map, response);
    }
1052632
public static base_response update(nitro_service client, cacheparameter resource) throws Exception {
		cacheparameter updateresource = new cacheparameter();
		updateresource.memlimit = resource.memlimit;
		updateresource.via = resource.via;
		updateresource.verifyusing = resource.verifyusing;
		updateresource.maxpostlen = resource.maxpostlen;
		updateresource.prefetchmaxpending = resource.prefetchmaxpending;
		updateresource.enablebypass = resource.enablebypass;
		updateresource.undefaction = resource.undefaction;
		updateresource.enablediskcache = resource.enablediskcache;
		return updateresource.update_resource(client);
	}
1200587
@PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public Response put(@PathParam("cacheName") String cacheName, Cache cache) {

        if (!cacheService.isPresent(cacheName)) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        cacheService.update(cacheName, cache);

        return Response.ok().build();
    }
953252
@Override
    public void onSuccess(final DMRResponse response) {
        ModelNode result = response.get();
        if (!result.hasDefined(OUTCOME) || result.isFailure()) {
            onFailedOutcome(result);
            abort();
        } else {
            onSuccess(result);
            proceed();
        }
    }
409607
public static base_response update(nitro_service client, cacheselector resource) throws Exception {
		cacheselector updateresource = new cacheselector();
		updateresource.selectorname = resource.selectorname;
		updateresource.rule = resource.rule;
		return updateresource.update_resource(client);
	}
905036
@Override
	public CacheEntry updateCacheValues(final HttpResponse response) {
		transferFirstHeader("Date", response, this.response);
		transferFirstHeader("ETag", response, this.response);
		transferFirstHeader("Last-Modified", response, this.response);
		transferFirstHeader("Cache-Control", response, this.response);
		transferFirstHeader("Expires", response, this.response);
		return this;
	}
1176629
public static void setNonCachingHeaders(@NotNull HttpServletResponse response) {
    response.setHeader(HEADER_PRAGMA, "no-cache");
    response.setHeader(HEADER_CACHE_CONTROL, "no-cache");
    response.setHeader(HEADER_EXPIRES, "0");
    response.setHeader(HEADER_DISPATCHER, "no-cache");
  }
1363340
public static void disableCaching(HttpServletResponse response) {
        response.addHeader(PRAGMA_HEADER_NAME, "no-cache");
        response.addHeader(CACHE_CONTROL_HEADER_NAME, "no-cache, no-store, max-age=0");
        response.addDateHeader(EXPIRES_HEADER_NAME, 1L);
    }
824903
private void setResponeHeaders(HttpServletResponse response) {

        response.setHeader("Cache-Control", "no-store, no-cache");
        response.setHeader("Pragma", "no-cache");
        response.setDateHeader("Expires", System.currentTimeMillis());
        response.setContentType("text/plain; charset=utf-8");
        response.setCharacterEncoding("utf-8");
    }
704437
@RequestMapping
    public void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);

        // create the redirect URL, adding fname and args parameters if necessary
        String redirectTarget = null;

        final String refUrl = request.getParameter(REFERER_URL_PARAM);
        final URL redirectLocation = parseLocalRefUrl(request, refUrl);
        if (redirectLocation != null) {
            redirectTarget = redirectLocation.toString();
        }

        if (redirectTarget == null) {
            /* Grab the target functional name, if any, off the login request.
             * Also any arguments for the target. We will pass them  along after authentication.
             */
            String targetFname = request.getParameter("uP_fname");

            if (targetFname == null) {
                final IPortalUrlBuilder defaultUrl = this.portalUrlProvider.getDefaultUrl(request);
                redirectTarget = defaultUrl.getUrlString();
            } else {
                try {
                    final IPortalUrlBuilder urlBuilder =
                            this.portalUrlProvider.getPortalUrlBuilderByPortletFName(
                                    request, targetFname, UrlType.RENDER);

                    Enumeration<String> e = request.getParameterNames();
                    while (e.hasMoreElements()) {
                        String paramName = e.nextElement();
                        if (!paramName.equals("uP_fname")) {
                            urlBuilder.addParameter(
                                    paramName, request.getParameterValues(paramName));
                        }
                    }

                    redirectTarget = urlBuilder.getUrlString();
                } catch (IllegalArgumentException e) {
                    final IPortalUrlBuilder defaultUrl =
                            this.portalUrlProvider.getDefaultUrl(request);
                    redirectTarget = defaultUrl.getUrlString();
                }
            }
        }

        IPerson person = null;

        final Object authError =
                request.getSession(false).getAttribute(LoginController.AUTH_ERROR_KEY);
        if (authError == null || !((Boolean) authError)) {
            person = this.personManager.getPerson(request);
        }

        if (person == null || !person.getSecurityContext().isAuthenticated()) {
            if (request.getMethod().equals("POST"))
                request.getSession(false).setAttribute(AUTH_ATTEMPTED_KEY, "true");
            // Preserve the attempted username so it can be redisplayed to the user
            String attemptedUserName = request.getParameter("userName");
            if (attemptedUserName != null)
                request.getSession(false)
                        .setAttribute(ATTEMPTED_USERNAME_KEY, request.getParameter("userName"));
        }

        final String encodedRedirectURL = response.encodeRedirectURL(redirectTarget);

        if (log.isDebugEnabled()) {
            log.debug("Redirecting to " + redirectTarget);
        }

        response.sendRedirect(encodedRedirectURL);
    }
605850
@SuppressWarnings("unchecked")
    @Override
    protected void afterHandle(final Request request, final Response response)
    {
        super.afterHandle(request, response);
        
        final ConcurrentMap<String, Object> responseAttributes = response.getAttributes();
        
        Series<Header> responseHeaders = (Series<Header>)responseAttributes.get(HeaderConstants.ATTRIBUTE_HEADERS);
        
        if(responseHeaders == null)
        {
            responseHeaders = new Series<Header>(Header.class);
            final Series<Header> putIfAbsent =
                    (Series<Header>)responseAttributes.putIfAbsent(HeaderConstants.ATTRIBUTE_HEADERS, responseHeaders);
            
            if(putIfAbsent != null)
            {
                responseHeaders = putIfAbsent;
            }
        }
        
        // Allow all origins
        responseHeaders.add("Access-Control-Allow-Origin", "*");
    }
962815
public static base_response update(nitro_service client, cachecontentgroup resource) throws Exception {
		cachecontentgroup updateresource = new cachecontentgroup();
		updateresource.name = resource.name;
		updateresource.weakposrelexpiry = resource.weakposrelexpiry;
		updateresource.heurexpiryparam = resource.heurexpiryparam;
		updateresource.relexpiry = resource.relexpiry;
		updateresource.relexpirymillisec = resource.relexpirymillisec;
		updateresource.absexpiry = resource.absexpiry;
		updateresource.absexpirygmt = resource.absexpirygmt;
		updateresource.weaknegrelexpiry = resource.weaknegrelexpiry;
		updateresource.hitparams = resource.hitparams;
		updateresource.invalparams = resource.invalparams;
		updateresource.ignoreparamvaluecase = resource.ignoreparamvaluecase;
		updateresource.matchcookies = resource.matchcookies;
		updateresource.invalrestrictedtohost = resource.invalrestrictedtohost;
		updateresource.polleverytime = resource.polleverytime;
		updateresource.ignorereloadreq = resource.ignorereloadreq;
		updateresource.removecookies = resource.removecookies;
		updateresource.prefetch = resource.prefetch;
		updateresource.prefetchperiod = resource.prefetchperiod;
		updateresource.prefetchperiodmillisec = resource.prefetchperiodmillisec;
		updateresource.prefetchmaxpending = resource.prefetchmaxpending;
		updateresource.flashcache = resource.flashcache;
		updateresource.expireatlastbyte = resource.expireatlastbyte;
		updateresource.insertvia = resource.insertvia;
		updateresource.insertage = resource.insertage;
		updateresource.insertetag = resource.insertetag;
		updateresource.cachecontrol = resource.cachecontrol;
		updateresource.quickabortsize = resource.quickabortsize;
		updateresource.minressize = resource.minressize;
		updateresource.maxressize = resource.maxressize;
		updateresource.memlimit = resource.memlimit;
		updateresource.ignorereqcachinghdrs = resource.ignorereqcachinghdrs;
		updateresource.minhits = resource.minhits;
		updateresource.alwaysevalpolicies = resource.alwaysevalpolicies;
		updateresource.persist = resource.persist;
		updateresource.pinned = resource.pinned;
		updateresource.lazydnsresolve = resource.lazydnsresolve;
		updateresource.hitselector = resource.hitselector;
		updateresource.invalselector = resource.invalselector;
		return updateresource.update_resource(client);
	}