コード例 #1
0
  /**
   * @param restResponse
   * @param servletContextUrl
   * @return
   */
  private String getGradleProperties(RestResponse restResponse, String servletContextUrl) {
    AddonsManager addonsManager = ContextHelper.get().beanForType(AddonsManager.class);
    FilteredResourcesAddon filteredResourcesWebAddon =
        addonsManager.addonByType(FilteredResourcesAddon.class);

    java.util.Properties credentialProperties = new java.util.Properties();
    credentialProperties.setProperty(
        "auth.username", filteredResourcesWebAddon.getGeneratedSettingsUsernameTemplate());

    credentialProperties.setProperty(
        "auth.password",
        filteredResourcesWebAddon.getGeneratedSettingsUserCredentialsTemplate(false));

    credentialProperties.setProperty("auth.contextUrl", servletContextUrl);

    String content =
        replaceValuesAndGetTemplateValue(
            "/gradle.properties.template", credentialProperties, restResponse);
    try {
      String filtered =
          filteredResourcesWebAddon.filterResource(
              null,
              (org.artifactory.md.Properties) InfoFactoryHolder.get().createProperties(),
              new StringReader(content));
      return filtered;
    } catch (Exception e) {
      log.error("Unable to filter gradle build properties file: " + e.getMessage());
      restResponse.error(e.getMessage());
    }
    return content;
  }
コード例 #2
0
  public EditableSettingsModalPanel(final DownloadModalSettings settings) {
    contentTextArea = new TextArea<String>("content", Model.<String>of(settings.getContent()));
    contentTextArea.setOutputMarkupId(true);

    FilteredResourcesWebAddon filteredResourcesWebAddon =
        addonsManager.addonByType(FilteredResourcesWebAddon.class);
    String saveToFileName = settings.getSaveToFileName();
    form.add(
        filteredResourcesWebAddon.getSettingsProvisioningBorder(
            "settingsProvisioning", form, contentTextArea, saveToFileName));

    final AjaxSettingsDownloadBehavior ajaxSettingsDownloadBehavior =
        new AjaxSettingsDownloadBehavior(saveToFileName) {

          @Override
          protected StringResourceStream getResourceStream() {
            FilteredResourcesWebAddon filteredResourcesWebAddon =
                addonsManager.addonByType(FilteredResourcesWebAddon.class);
            try {
              String filtered =
                  filteredResourcesWebAddon.filterResource(
                      null,
                      (Properties) InfoFactoryHolder.get().createProperties(),
                      new StringReader(contentTextArea.getModelObject()));
              return new StringResourceStream(filtered, settings.getSettingsMimeType());
            } catch (Exception e) {
              log.error("Unable to filter settings: " + e.getMessage());
              return new StringResourceStream(
                  contentTextArea.getModelObject(), settings.getSettingsMimeType());
            }
          }
        };

    form.add(ajaxSettingsDownloadBehavior);

    Component exportLink =
        new TitledAjaxSubmitLink("export", settings.getDownloadButtonTitle(), form) {
          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            ajaxSettingsDownloadBehavior.initiate(target);
          }
        };
    exportLink.add(new CssClass(new DefaultButtonStyleModel(exportLink)));
    add(exportLink);

    setWidth(700);
    add(new ModalCloseLink("cancel", "Cancel"));

    addContentToBorder();
  }
コード例 #3
0
 /**
  * update remote Properties
  *
  * @param resource - repo resource
  * @param properties - properties
  */
 private void updateRemoteProperties(RepoResource resource, Properties properties) {
   AddonsManager addonsManager = ContextHelper.get().beanForType(AddonsManager.class);
   PropertiesAddon propertiesAddon = addonsManager.addonByType(PropertiesAddon.class);
   propertiesAddon.setProperties(resource.getRepoPath(), properties);
 }