com.smartling.maven.plugins.smartlingapi.mojo.DeleteFileMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smartling-api-maven-plugin Show documentation
Show all versions of smartling-api-maven-plugin Show documentation
Maven plugin for accessing Smartling API.
The newest version!
package com.smartling.maven.plugins.smartlingapi.mojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import com.smartling.api.sdk.dto.ApiResponse;
import com.smartling.api.sdk.dto.EmptyResponse;
import com.smartling.api.sdk.exceptions.ApiException;
import com.smartling.maven.plugins.smartlingapi.SmartlingApiMavenPluginUtils;
/**
* Deletes a file in Smartling TMS.
*
* @version $Id$
* @since 1.0.0
*/
@Mojo(name = "deleteFile", requiresOnline = true, threadSafe = true)
class DeleteFileMojo extends AbstractSmartlingFileApiMojo
{
private static final String DELETE_FILE_INFO_MESSAGE =
SmartlingApiMavenPluginUtils.SMARTLING_API_PLUGIN_NAME + " deleting file; fileUri=%s";
private static final String DELETE_FILE_FAILED_ERROR_MESSAGE =
SmartlingApiMavenPluginUtils.SMARTLING_API_PLUGIN_NAME + " failed deleting file; fileUri=%s";
/**
* Target file.
*/
@Parameter(required = true)
private String fileUri;
@Override
public String getGoalName()
{
return "deleteFile";
}
@Override
public void doExecute() throws MojoExecutionException, MojoFailureException
{
deleteFile(fileUri);
}
private void deleteFile(final String fileUri) throws MojoFailureException
{
getLog().info(String.format(DELETE_FILE_INFO_MESSAGE, fileUri));
try
{
final ApiResponse deleteFileResponse = getFileApiClientAdapter().deleteFile(fileUri);
checkApiResponseSuccess(deleteFileResponse);
}
catch (final ApiException e)
{
handleError(String.format(DELETE_FILE_FAILED_ERROR_MESSAGE, fileUri), e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy