Exemplo n.º 1
0
  public static Client valueOf(OrcidClient orcidClient) {
    Client client = new Client();
    client.setClientId(Text.valueOf(orcidClient.getClientId()));
    client.setClientSecret(Text.valueOf(orcidClient.getClientSecret()));
    client.setDisplayName(Text.valueOf(orcidClient.getDisplayName()));
    client.setShortDescription(Text.valueOf(orcidClient.getShortDescription()));
    if (orcidClient.getType() != null) client.setType(Text.valueOf(orcidClient.getType().value()));
    client.setWebsite(Text.valueOf(orcidClient.getWebsite()));

    Checkbox persistentTokenEnabled = new Checkbox();
    persistentTokenEnabled.setValue(orcidClient.isPersistentTokenEnabled());
    client.setPersistentTokenEnabled(persistentTokenEnabled);

    List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
    RedirectUris orcidRedirectUris = orcidClient.getRedirectUris();
    if (orcidRedirectUris != null && orcidRedirectUris.getRedirectUri() != null) {
      for (org.orcid.jaxb.model.clientgroup.RedirectUri orcidRedirectUri :
          orcidRedirectUris.getRedirectUri()) {
        redirectUris.add(RedirectUri.toRedirectUri(orcidRedirectUri));
      }
    }

    client.setRedirectUris(redirectUris);

    return client;
  }
Exemplo n.º 2
0
  public OrcidClient toOrcidClient() {
    OrcidClient orcidClient = new OrcidClient();
    orcidClient.setDisplayName(this.displayName.getValue());
    orcidClient.setWebsite(this.website.getValue());
    orcidClient.setShortDescription(this.shortDescription.getValue());
    orcidClient.setClientId(this.clientId.getValue());
    if (!PojoUtil.isEmpty(this.clientSecret))
      orcidClient.setClientSecret(this.clientSecret.getValue());
    if (!PojoUtil.isEmpty(this.type))
      orcidClient.setType(ClientType.fromValue(this.type.getValue()));

    RedirectUris redirectUris = new RedirectUris();

    for (RedirectUri redirectUri : this.redirectUris) {
      redirectUris.getRedirectUri().add(redirectUri.toRedirectUri());
    }

    orcidClient.setRedirectUris(redirectUris);

    if (persistentTokenEnabled != null)
      orcidClient.setPersistentTokenEnabled(persistentTokenEnabled.getValue());

    return orcidClient;
  }