Skip to content

Commit

Permalink
Merge pull request jenkinsci#75 from mavlyutov/master
Browse files Browse the repository at this point in the history
reformat code, spaces instead of tabs
  • Loading branch information
mavlyutov committed Nov 19, 2014
2 parents 3452b84 + 4837a1e commit 9e8f35a
Show file tree
Hide file tree
Showing 31 changed files with 2,709 additions and 2,733 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
@Extension
public class PluginImpl extends Plugin implements Describable<PluginImpl> {

@Override
public void start() throws Exception {
load();
}
@Override
public void start() throws Exception {
load();
}

public Descriptor<PluginImpl> getDescriptor() {
return (DescriptorImpl) Hudson.getInstance().getDescriptorOrDie(getClass());
}
public Descriptor<PluginImpl> getDescriptor() {
return (DescriptorImpl) Hudson.getInstance().getDescriptorOrDie(getClass());
}

public static PluginImpl get() {
return Hudson.getInstance().getPlugin(PluginImpl.class);
}
public static PluginImpl get() {
return Hudson.getInstance().getPlugin(PluginImpl.class);
}

@Extension
public static final class DescriptorImpl extends Descriptor<PluginImpl> {
@Override
public String getDisplayName() {
return "JClouds PluginImpl";
}
}
@Extension
public static final class DescriptorImpl extends Descriptor<PluginImpl> {
@Override
public String getDisplayName() {
return "JClouds PluginImpl";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@

/**
* A simple "bean" for blobstore entries.
*
*
* @author Vijay Kiran
*/
public final class BlobStoreEntry extends AbstractDescribableImpl<BlobStoreEntry> {
/**
* The container where the file is saved. See http://www.jclouds.org/documentation/userguide/blobstore-guide#container
*/
public String container;
/**
* The sub path under the container where the file is saved.
*/
public String path;
/**
* The source file relative to the workspace directory, which needs to be uploaded to the container.
*/
public String sourceFile;
/**
* Whether or not the sourceFile's path relative to the workspace should be preserved upon upload to the Blobstore.
*/
public boolean keepHierarchy;
/**
* The container where the file is saved. See http://www.jclouds.org/documentation/userguide/blobstore-guide#container
*/
public String container;
/**
* The sub path under the container where the file is saved.
*/
public String path;
/**
* The source file relative to the workspace directory, which needs to be uploaded to the container.
*/
public String sourceFile;
/**
* Whether or not the sourceFile's path relative to the workspace should be preserved upon upload to the Blobstore.
*/
public boolean keepHierarchy;

@DataBoundConstructor
public BlobStoreEntry(String container, String path, String sourceFile, boolean keepHierarchy) {
this.container = container;
this.path = path;
this.sourceFile = sourceFile;
this.keepHierarchy = keepHierarchy;
}
@DataBoundConstructor
public BlobStoreEntry(String container, String path, String sourceFile, boolean keepHierarchy) {
this.container = container;
this.path = path;
this.sourceFile = sourceFile;
this.keepHierarchy = keepHierarchy;
}

@Extension
public static class DescriptorImpl extends Descriptor<BlobStoreEntry> {
@Override
public String getDisplayName() {
return "";
}
}
@Extension
public static class DescriptorImpl extends Descriptor<BlobStoreEntry> {
@Override
public String getDisplayName() {
return "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,112 +17,107 @@

/**
* Model class for Blobstore profile. User can configure multiple profiles to upload artifacts to different providers.
*
*
* @author Vijay Kiran
*/
public class BlobStoreProfile {

private static final Logger LOGGER = Logger.getLogger(BlobStoreProfile.class.getName());
private static final Logger LOGGER = Logger.getLogger(BlobStoreProfile.class.getName());

private String profileName;
private String providerName;
private String identity;
private String credential;
private String profileName;
private String providerName;
private String identity;
private String credential;

@DataBoundConstructor
public BlobStoreProfile(final String profileName, final String providerName, final String identity, final String credential) {
this.profileName = profileName;
this.providerName = providerName;
this.identity = identity;
this.credential = credential;
}
@DataBoundConstructor
public BlobStoreProfile(final String profileName, final String providerName, final String identity, final String credential) {
this.profileName = profileName;
this.providerName = providerName;
this.identity = identity;
this.credential = credential;
}

/**
* Configured profile.
*
* @return - name of the profile.
*/
public String getProfileName() {
return profileName;
}
/**
* Configured profile.
*
* @return - name of the profile.
*/
public String getProfileName() {
return profileName;
}

/**
* Provider Name as per the JClouds Blobstore supported providers.
*
* @return - providerName String
*/
public String getProviderName() {
return providerName;
}
/**
* Provider Name as per the JClouds Blobstore supported providers.
*
* @return - providerName String
*/
public String getProviderName() {
return providerName;
}

/**
* Cloud provider identity.
*
* @return
*/
public String getIdentity() {
return identity;
}
/**
* Cloud provider identity.
*
* @return
*/
public String getIdentity() {
return identity;
}

/**
* Cloud provider credential.
*
* @return
*/
public String getCredential() {
return credential;
}
/**
* Cloud provider credential.
*
* @return
*/
public String getCredential() {
return credential;
}

static final Iterable<Module> MODULES = ImmutableSet.<Module> of(new EnterpriseConfigurationModule());
static final Iterable<Module> MODULES = ImmutableSet.<Module>of(new EnterpriseConfigurationModule());

static BlobStoreContext ctx(String providerName, String identity, String credential, Properties overrides) {
return ContextBuilder.newBuilder(providerName).credentials(identity, credential).overrides(overrides).modules(MODULES)
.buildView(BlobStoreContext.class);
}
static BlobStoreContext ctx(String providerName, String identity, String credential, Properties overrides) {
return ContextBuilder.newBuilder(providerName).credentials(identity, credential).overrides(overrides).modules(MODULES)
.buildView(BlobStoreContext.class);
}

/**
* Upload the specified file from the
*
* @param filePath
* to container
*
* @param container
* - The container where the file needs to be uploaded.
* @param path
* - The path in container where the file needs to be uploaded.
* @param filePath
* - the {@link FilePath} of the file which needs to be uploaded.
* @throws IOException
* @throws InterruptedException
*/
public void upload(String container, String path, FilePath filePath) throws IOException, InterruptedException {
if (filePath.isDirectory()) {
throw new IOException(filePath + " is a directory");
}
// correct the classloader so that extensions can be found
Thread.currentThread().setContextClassLoader(Apis.class.getClassLoader());
// TODO: endpoint
final BlobStoreContext context = ctx(this.providerName, this.identity, this.credential, new Properties());
try {
final BlobStore blobStore = context.getBlobStore();
if (!blobStore.containerExists(container)) {
blobStore.createContainerInLocation(null, container);
}
if (!path.equals("") && !blobStore.directoryExists(container, path)) {
blobStore.createDirectory(container, path);
}
String destPath;
if (path.equals("")) {
destPath = filePath.getName();
} else {
destPath = path + "/" + filePath.getName();
}
LOGGER.info("Publishing now to container: " + container + " path: " + destPath);
/**
* Upload the specified file from the
*
* @param filePath to container
* @param container - The container where the file needs to be uploaded.
* @param path - The path in container where the file needs to be uploaded.
* @param filePath - the {@link FilePath} of the file which needs to be uploaded.
* @throws IOException
* @throws InterruptedException
*/
public void upload(String container, String path, FilePath filePath) throws IOException, InterruptedException {
if (filePath.isDirectory()) {
throw new IOException(filePath + " is a directory");
}
// correct the classloader so that extensions can be found
Thread.currentThread().setContextClassLoader(Apis.class.getClassLoader());
// TODO: endpoint
final BlobStoreContext context = ctx(this.providerName, this.identity, this.credential, new Properties());
try {
final BlobStore blobStore = context.getBlobStore();
if (!blobStore.containerExists(container)) {
blobStore.createContainerInLocation(null, container);
}
if (!path.equals("") && !blobStore.directoryExists(container, path)) {
blobStore.createDirectory(container, path);
}
String destPath;
if (path.equals("")) {
destPath = filePath.getName();
} else {
destPath = path + "/" + filePath.getName();
}
LOGGER.info("Publishing now to container: " + container + " path: " + destPath);
Blob blob = context.getBlobStore().blobBuilder(destPath).payload(filePath.read()).build();
context.getBlobStore().putBlob(container, blob);
LOGGER.info("Published " + destPath + " to container " + container + " with profile " + this.profileName);
} finally {
context.close();
}
}
LOGGER.info("Published " + destPath + " to container " + container + " with profile " + this.profileName);
} finally {
context.close();
}
}
}
Loading

0 comments on commit 9e8f35a

Please sign in to comment.