Gets the {@link UpdateSite} from which we receive updates for {@code jenkins.war}.

@return
{@code null} if no such update center is provided.
548976
@CheckForNull
    public UpdateSite getCoreSource() {
        for (UpdateSite s : sites) {
            Data data = s.getData();
            if (data!=null && data.core!=null)
                return s;
        }
        return null;
    }
619557
public void updateSite(String siteRoot) {

        try {
            CmsObject cloneCms = OpenCms.initCmsObject(m_cms);
            if (siteRoot == null) {
                siteRoot = "/system";
            }
            cloneCms.getRequestContext().setSiteRoot(siteRoot);
            m_cms = cloneCms;
        } catch (CmsException e1) {
            LOG.error(e1.getLocalizedMessage(), e1);
        }
        updateValidation();
    }
228289
@Nonnull
    public static UpdateCenter createUpdateCenter(@CheckForNull UpdateCenterConfiguration config) {
        String requiredClassName = SystemProperties.getString(UpdateCenter.class.getName()+".className", null);
        if (requiredClassName == null) {
            // Use the default Update Center
            LOGGER.log(Level.FINE, "Using the default Update Center implementation");
            return createDefaultUpdateCenter(config);
        }
        
        LOGGER.log(Level.FINE, "Using the custom update center: {0}", requiredClassName);
        try {
            final Class<?> clazz = Class.forName(requiredClassName).asSubclass(UpdateCenter.class);
            if (!UpdateCenter.class.isAssignableFrom(clazz)) {
                LOGGER.log(Level.SEVERE, "The specified custom Update Center {0} is not an instance of {1}. Falling back to default.",
                        new Object[] {requiredClassName, UpdateCenter.class.getName()});
                return createDefaultUpdateCenter(config);
            }
            final Class<? extends UpdateCenter> ucClazz = clazz.asSubclass(UpdateCenter.class);
            final Constructor<? extends UpdateCenter> defaultConstructor = ucClazz.getConstructor();
            final Constructor<? extends UpdateCenter> configConstructor = ucClazz.getConstructor(UpdateCenterConfiguration.class);
            LOGGER.log(Level.FINE, "Using the constructor {0} Update Center configuration for {1}",
                    new Object[] {config != null ? "with" : "without", requiredClassName});
            return config != null ? configConstructor.newInstance(config) : defaultConstructor.newInstance();
        } catch(ClassCastException e) {
            // Should never happen
            LOGGER.log(WARNING, "UpdateCenter class {0} does not extend hudson.model.UpdateCenter. Using default.", requiredClassName);
        } catch(NoSuchMethodException e) {
            LOGGER.log(WARNING, String.format("UpdateCenter class %s does not define one of the required constructors. Using default", requiredClassName), e);
        } catch(Exception e) {
            LOGGER.log(WARNING, String.format("Unable to instantiate custom plugin manager [%s]. Using default.", requiredClassName), e);
        }
        return createDefaultUpdateCenter(config);
    }
921129
@RequestMapping(value = GET_PENDING_DEPLOYMENTS_URL, method = RequestMethod.GET)
    public ResponseEntity<Collection<Deployment>> getPendingDeployments(@PathVariable(ENV_PATH_VAR_NAME) String env,
                                                                        @PathVariable(SITE_NAME_PATH_VAR_NAME) String siteName)
        throws DeployerException {
        Target target = targetService.getTarget(env, siteName);
        Collection<Deployment> deployments = target.getPendingDeployments();

        return new ResponseEntity<>(deployments,
                                    RestServiceUtils.setLocationHeader(new HttpHeaders(), BASE_URL +GET_PENDING_DEPLOYMENTS_URL,
                                                                       env, siteName),
                                    HttpStatus.OK);
    }
356261
I_CmsSerialDateServiceAsync getService() {

        if (SERVICE == null) {
            SERVICE = GWT.create(I_CmsSerialDateService.class);
            String serviceUrl = CmsCoreProvider.get().link("org.opencms.ade.contenteditor.CmsSerialDateService.gwt");
            ((ServiceDefTarget)SERVICE).setServiceEntryPoint(serviceUrl);
        }
        return SERVICE;
    }
1280519
@CheckForNull
    public Node getNode() {
        Jenkins j = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance()
        if (j == null) {
            return null;
        }
        if (nodeName == null) {
            return j;
        }
        return j.getNode(nodeName);
    }
1311311
public com.google.appengine.v1.UpdateServiceMethodOrBuilder getUpdateServiceOrBuilder() {
    if (methodCase_ == 1) {
       return (com.google.appengine.v1.UpdateServiceMethod) method_;
    }
    return com.google.appengine.v1.UpdateServiceMethod.getDefaultInstance();
  }
1108842
@Override
  public Map<SocketAddress, String> getVersions() {
    final Map<SocketAddress, String> rv =
        new ConcurrentHashMap<SocketAddress, String>();

    CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
      @Override
      public Operation newOp(final MemcachedNode n,
          final CountDownLatch latch) {
        final SocketAddress sa = n.getSocketAddress();
        return opFact.version(new OperationCallback() {
          @Override
          public void receivedStatus(OperationStatus s) {
            rv.put(sa, s.getMessage());
          }

          @Override
          public void complete() {
            latch.countDown();
          }
        });
      }
    });
    try {
      blatch.await(operationTimeout, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
      throw new RuntimeException("Interrupted waiting for versions", e);
    }
    return rv;
  }
230030
public @CheckForNull Plugin getPlugin(String artifactId, @CheckForNull VersionNumber minVersion) {
        if (minVersion == null) {
            return getPlugin(artifactId);
        }
        for (UpdateSite s : sites) {
            Plugin p = s.getPlugin(artifactId);
            if (p!=null) {
                if (minVersion.isNewerThan(new VersionNumber(p.version))) continue;
                return p;
            }
        }
        return null;
    }
1167717
@CheckForNull
    public JSONArray getPlatformPluginUpdates() {
        final VersionNumber version = getCurrentLevel();
        if (version == null) {
            return null;
        }
        return getPlatformPluginsForUpdate(version, Jenkins.getVersion());
    }
92882
public File getHudsonWar() {
        String war = SystemProperties.getString("executable-war");
        if(war!=null && new File(war).exists())
            return new File(war);
        return null;
    }
1220332
private void updateSiteInfo(final String siteRoot) {

        String top = "";
        String bottom = "";

        if (m_new) {
            top = CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_RESINFO_NEW_MODULE_0);
        } else {
            top = m_module.getName();
        }

        if (siteRoot == null) {
            bottom = CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_MODULE_SITE_NOT_SET_0);
        } else {
            CmsSiteManagerImpl siteManager = OpenCms.getSiteManager();
            CmsSite site = siteManager.getSiteForSiteRoot(siteRoot);
            if (site != null) {
                bottom = CmsVaadinUtils.getMessageText(
                    Messages.GUI_MODULES_MODULE_SITE_1,
                    site.getTitle() + " (" + siteRoot + ")");
            } else if (siteRoot.equals("") || siteRoot.equals("/")) {
                bottom = CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_MODULE_SITE_ROOT_FOLDER_0);
            } else {
                bottom = CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_MODULE_SITE_1, siteRoot);
            }
        }
        m_info.get().getTopLine().setValue(top);
        m_info.get().getBottomLine().setValue(bottom);

        for (Component c : Arrays.asList(m_moduleResources, m_excludedResources)) {
            CmsVaadinUtils.visitDescendants(c, new Predicate<Component>() {

                public boolean apply(Component comp) {

                    if (comp instanceof CmsModuleResourceSelectField) {
                        ((CmsModuleResourceSelectField)comp).updateSite(siteRoot);
                    }
                    return true;
                }
            });
        }

    }
485505
@Patch("/status")
    @Consumes("application/json-patch+json")
    @RequiresAdministrator
    public CompletableFuture<ServerStatus> updateStatus(ServiceRequestContext ctx,
                                                        JsonNode patch) throws Exception {
        // TODO(trustin): Consider extracting this into common utility or Armeria.
        final ServerStatus oldStatus = status();
        final JsonNode oldValue = Jackson.valueToTree(oldStatus);
        final JsonNode newValue;
        try {
            newValue = JsonPatch.fromJson(patch).apply(oldValue);
        } catch (JsonPatchException e) {
            // Failed to apply the given JSON patch.
            return rejectStatusPatch(patch);
        }

        if (!newValue.isObject()) {
            return rejectStatusPatch(patch);
        }

        final JsonNode writableNode = newValue.get("writable");
        final JsonNode replicatingNode = newValue.get("replicating");
        if (!writableNode.isBoolean() || !replicatingNode.isBoolean()) {
            return rejectStatusPatch(patch);
        }

        final boolean writable = writableNode.asBoolean();
        final boolean replicating = replicatingNode.asBoolean();
        if (writable && !replicating) {
            return HttpApiUtil.throwResponse(ctx, HttpStatus.BAD_REQUEST,
                                             "'replicating' must be 'true' if 'writable' is 'true'.");
        }

        if (oldStatus.writable) {
            if (!writable) { // writable -> unwritable
                executor().setWritable(false);
                if (replicating) {
                    logger.warn("Entered read-only mode with replication enabled");
                    return CompletableFuture.completedFuture(status());
                } else {
                    logger.warn("Entering read-only mode with replication disabled ..");
                    return executor().stop().handle((unused, cause) -> {
                        if (cause != null) {
                            logger.warn("Failed to stop the command executor:", cause);
                        } else {
                            logger.info("Entered read-only mode with replication disabled");
                        }
                        return status();
                    });
                }
            }
        } else if (writable) { // unwritable -> writable
            logger.warn("Leaving read-only mode ..");
            executor().setWritable(true);
            return executor().start().handle((unused, cause) -> {
                if (cause != null) {
                    logger.warn("Failed to leave read-only mode:", cause);
                } else {
                    logger.info("Left read-only mode");
                }
                return status();
            });
        }

        throw HttpStatusException.of(HttpStatus.NOT_MODIFIED);
    }
26808
@SuppressWarnings("unchecked")
	public JSONObject getStatusUpdate() {
		JSONObject statusUpdate = null;
		try {
			statusUpdate = (JSONObject) JSON_PARSER
					.parse((String) this.nextStatusUpdateNode
							.getProperty(Properties.StatusUpdate.CONTENT));
		} catch (final ParseException e) {
			e.printStackTrace();
		}

		// (create and) add user object
		if (this.userJSON == null) {
			final User user = new User(this.userNode);
			this.userJSON = user.toActorJSON();
		}
		statusUpdate.put("actor", this.userJSON);

		this.nextStatusUpdate();
		return statusUpdate;
	}
702103
private static File getWarLocation() {
        URL resource = JettyConsoleBootstrapMainClass.class.getResource("/META-INF/jettyconsole/jettyconsole.properties");
        String file = resource.getFile();
        file = file.substring("file:".length(), file.indexOf("!"));
        try {
            file = URLDecoder.decode(file, "utf-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        return new File(file);
    }
219801
@Exported
    public boolean hasUpdates() {
        Data data = getData();
        if(data==null)      return false;
        
        for (PluginWrapper pw : Jenkins.getInstance().getPluginManager().getPlugins()) {
            if(!pw.isBundled() && pw.getUpdateInfo()!=null)
                // do not advertize updates to bundled plugins, since we generally want users to get them
                // as a part of jenkins.war updates. This also avoids unnecessary pinning of plugins. 
                return true;
        }
        return false;
    }
317174
ProjectBuildingResult getProjectBuildingResult(MavenModelResource pomResource) throws ProjectBuildingException
   {
      ProjectBuildingResult result = cacheProject.get(pomResource.getFullyQualifiedName());
      if (result == null)
      {
         try
         {
            ProjectBuildingRequest request = getProjectBuildingRequest();
            Assert.notNull(request, "Project building request was null");
            request.setResolveDependencies(true);
            boolean inTransaction = !pomResource.getUnderlyingResourceObject().exists();
            // FORGE-1287
            if (inTransaction)
            {
               result = getProjectBuilder().build(new FileResourceModelSource(pomResource), request);
               // If under a transaction, don't start monitoring
            }
            else
            {
               result = getProjectBuilder().build(pomResource.getUnderlyingResourceObject(), request);
               monitorResource(pomResource);
            }
         }
         catch (ProjectBuildingException pbe)
         {
            List<ProjectBuildingResult> results = pbe.getResults();
            if (results != null && results.size() > 0)
               result = results.get(0);
            throw pbe;
         }
         finally
         {
            if (result != null && !Projects.isCacheDisabled())
               cacheProject.put(pomResource.getFullyQualifiedName(), result);
         }
      }
      return result;
   }