private void performStagingAction( final StageRepository repo, final String actionSubpath, final List<Element> extraData) throws RESTLightClientException { if (repo == null) { throw new RESTLightClientException( "No staging-repository details specified. Please provide a valid StageRepository instance."); } Map<String, String> params = new HashMap<String, String>(); params.put(STAGE_REPO_ID_PARAM, repo.getRepositoryId()); String rootElement = getVocabulary().getProperty(VocabularyKeys.PROMOTE_STAGE_REPO_ROOT_ELEMENT); Document body = new Document().setRootElement(new Element(rootElement)); Element data = new Element("data"); body.getRootElement().addContent(data); data.addContent(new Element("stagedRepositoryId").setText(repo.getRepositoryId())); if (extraData != null && !extraData.isEmpty()) { for (Element extra : extraData) { data.addContent(extra); } } post(PROFILES_PATH + "/" + repo.getProfileId() + actionSubpath, null, body); }
@SuppressWarnings("unchecked") private void parseStageRepositoryDetails( final String profileId, final Map<String, StageRepository> repoStubs, boolean filterUser) throws RESTLightClientException { // System.out.println( repoStubs ); Document doc = get(PROFILE_REPOS_PATH_PREFIX + profileId); // System.out.println( new XMLOutputter().outputString( doc ) ); XPath repoXPath = newXPath(STAGE_REPO_DETAIL_XPATH); List<Element> repoDetails; try { repoDetails = repoXPath.selectNodes(doc.getRootElement()); } catch (JDOMException e) { throw new RESTLightClientException( "Failed to select detail sections for staging-profile repositories.", e); } if (repoDetails != null && !repoDetails.isEmpty()) { for (Element detail : repoDetails) { String repoId = detail.getChild(REPO_ID_ELEMENT).getText(); String key = profileId + "/" + repoId; StageRepository repo = repoStubs.get(key); if (repo == null) { continue; } Element uid = detail.getChild(USER_ID_ELEMENT); if (uid != null && getUser() != null && getUser().equals(uid.getText().trim())) { repo.setUser(uid.getText().trim()); } else { if (filterUser) { repoStubs.remove(key); } } Element url = detail.getChild(REPO_URI_ELEMENT); if (url != null) { repo.setUrl(url.getText()); } Element desc = detail.getChild(REPO_DESCRIPTION_ELEMENT); if (desc != null) { repo.setDescription(desc.getText()); } } } }