
org.rundeck.api.domain.BaseKeyResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rundeck-api-java-client Show documentation
Show all versions of rundeck-api-java-client Show documentation
Java client for the Rundeck REST API
package org.rundeck.api.domain;
import java.util.ArrayList;
import java.util.List;
/**
* BaseKeyResource is ...
*
* @author Greg Schueler
* @since 2014-04-04
*/
public class BaseKeyResource extends BaseStorageResource implements KeyResource {
private boolean privateKey;
public BaseKeyResource() {
}
public boolean isPrivateKey() {
return privateKey;
}
public void setPrivateKey(boolean privateKey) {
this.privateKey = privateKey;
}
ArrayList keyResources = new ArrayList();
@Override
public void setDirectoryContents(List extends StorageResource> directoryContents) {
for (StorageResource directoryContent : directoryContents) {
keyResources.add(from(directoryContent));
}
}
@Override
public List getDirectoryContents() {
return keyResources;
}
public static BaseKeyResource from(final StorageResource source) {
final BaseKeyResource baseSshKeyResource = new BaseKeyResource();
baseSshKeyResource.setDirectory(source.isDirectory());
baseSshKeyResource.setPath(source.getPath());
baseSshKeyResource.setName(source.getName());
baseSshKeyResource.setMetadata(source.getMetadata());
baseSshKeyResource.setUrl(source.getUrl());
if (!baseSshKeyResource.isDirectory()) {
baseSshKeyResource.setPrivateKey(
null != baseSshKeyResource.getMetadata() && "private".equals(baseSshKeyResource.getMetadata().get
("Rundeck-key-type"))
);
} else if (null != source.getDirectoryContents()) {
baseSshKeyResource.setDirectoryContents(source.getDirectoryContents());
}
return baseSshKeyResource;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy