Example usage for org.apache.commons.lang StringUtils remove

List of usage examples for org.apache.commons.lang StringUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils remove.

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:nz.co.senanque.schemabuilder.ForeignKey.java

public void duplicateName(String ref) {
    m_name = m_foreignTable + "_" + StringUtils.remove(m_localColumn, "_ID");//+"_"+ref;
}

From source file:nz.co.senanque.schemabuilder.NameHandler.java

public static String translateToJavaCollection(String name) {
    return pluralize(initialLowerCase(fixCase(StringUtils.remove(name, "_ID"))));
}

From source file:opennlp.tools.similarity.apps.utils.Utils.java

public static String removeHTMLTagsFromStr(String inputStr) {
    String[] removeTags = StringUtils.substringsBetween(inputStr, "<", ">");

    if (removeTags != null && removeTags.length > 0) {
        for (String tag : removeTags) {
            inputStr = StringUtils.remove(inputStr, "<" + tag + ">");
        }/*from ww  w .  ja  va 2 s  . c o  m*/
    }

    return inputStr;
}

From source file:org.apache.archiva.dependency.tree.maven2.Maven3DependencyTreeBuilder.java

private ManagedRepository findArtifactInRepositories(List<String> repositoryIds, Artifact projectArtifact)
        throws RepositoryAdminException {
    for (String repoId : repositoryIds) {
        ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository(repoId);

        File repoDir = new File(managedRepository.getLocation());
        File file = pathTranslator.toFile(repoDir, projectArtifact.getGroupId(),
                projectArtifact.getArtifactId(), projectArtifact.getBaseVersion(),
                projectArtifact.getArtifactId() + "-" + projectArtifact.getVersion() + ".pom");

        if (file.exists()) {
            return managedRepository;
        }/*from w  ww.j  ava2s . c  o m*/
        // try with snapshot version
        if (StringUtils.endsWith(projectArtifact.getBaseVersion(), VersionUtil.SNAPSHOT)) {
            File metadataFile = new File(file.getParent(), MetadataTools.MAVEN_METADATA);
            if (metadataFile.exists()) {
                try {
                    ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader
                            .read(metadataFile);
                    int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
                    String timeStamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
                    // rebuild file name with timestamped version and build number
                    String timeStampFileName = new StringBuilder(projectArtifact.getArtifactId()).append('-')
                            .append(StringUtils.remove(projectArtifact.getBaseVersion(),
                                    "-" + VersionUtil.SNAPSHOT))
                            .append('-').append(timeStamp).append('-').append(Integer.toString(buildNumber))
                            .append(".pom").toString();
                    File timeStampFile = new File(file.getParent(), timeStampFileName);
                    log.debug("try to find timestamped snapshot version file: {}", timeStampFile.getPath());
                    if (timeStampFile.exists()) {
                        return managedRepository;
                    }
                } catch (XMLException e) {
                    log.warn("skip fail to find timestamped snapshot pom: {}", e.getMessage());
                }
            }
        }
    }
    return null;
}

From source file:org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryStorage.java

@Override
public String getFilePathWithVersion(final String requestPath,
        ManagedRepositoryContent managedRepositoryContent) throws XMLException, RelocationException {

    if (StringUtils.endsWith(requestPath, METADATA_FILENAME)) {
        return getFilePath(requestPath, managedRepositoryContent.getRepository());
    }//w  w w . j  av  a 2 s.  c o  m

    String filePath = getFilePath(requestPath, managedRepositoryContent.getRepository());

    ArtifactReference artifactReference = null;
    try {
        artifactReference = pathParser.toArtifactReference(filePath);
    } catch (LayoutException e) {
        return filePath;
    }

    if (StringUtils.endsWith(artifactReference.getVersion(), VersionUtil.SNAPSHOT)) {
        // read maven metadata to get last timestamp
        File metadataDir = new File(managedRepositoryContent.getRepoRoot(), filePath).getParentFile();
        if (!metadataDir.exists()) {
            return filePath;
        }
        File metadataFile = new File(metadataDir, METADATA_FILENAME);
        if (!metadataFile.exists()) {
            return filePath;
        }
        ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read(metadataFile);
        int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
        String timestamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();

        // MRM-1846
        if (buildNumber < 1 && timestamp == null) {
            return filePath;
        }

        // org/apache/archiva/archiva-checksum/1.4-M4-SNAPSHOT/archiva-checksum-1.4-M4-SNAPSHOT.jar
        // ->  archiva-checksum-1.4-M4-20130425.081822-1.jar

        filePath = StringUtils.replace(filePath, //
                artifactReference.getArtifactId() //
                        + "-" + artifactReference.getVersion(), //
                artifactReference.getArtifactId() //
                        + "-" + StringUtils.remove(artifactReference.getVersion(), "-" + VersionUtil.SNAPSHOT) //
                        + "-" + timestamp //
                        + "-" + buildNumber);

        throw new RelocationException(
                "/repository/" + managedRepositoryContent.getRepository().getId()
                        + (StringUtils.startsWith(filePath, "/") ? "" : "/") + filePath,
                RelocationException.RelocationType.TEMPORARY);

    }

    return filePath;
}

From source file:org.apache.archiva.metadata.repository.storage.maven2.RepositoryModelResolver.java

protected File findTimeStampedSnapshotPom(String groupId, String artifactId, String version,
        String parentDirectory) {

    // reading metadata if there
    File mavenMetadata = new File(parentDirectory, METADATA_FILENAME);
    if (mavenMetadata.exists()) {
        try {//from www  .j  ava 2 s .  c o  m
            ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read(mavenMetadata);
            SnapshotVersion snapshotVersion = archivaRepositoryMetadata.getSnapshotVersion();
            if (snapshotVersion != null) {
                String lastVersion = snapshotVersion.getTimestamp();
                int buildNumber = snapshotVersion.getBuildNumber();
                String snapshotPath = StringUtils.replaceChars(groupId, '.', '/') + '/' + artifactId + '/'
                        + version + '/' + artifactId + '-'
                        + StringUtils.remove(version, "-" + VersionUtil.SNAPSHOT) + '-' + lastVersion + '-'
                        + buildNumber + ".pom";

                log.debug("use snapshot path {} for maven coordinate {}:{}:{}", snapshotPath, groupId,
                        artifactId, version);

                File model = new File(basedir, snapshotPath);
                //model = pathTranslator.toFile( basedir, groupId, artifactId, lastVersion, filename );
                if (model.exists()) {
                    return model;
                }
            }
        } catch (XMLException e) {
            log.warn("fail to read {}, {}", mavenMetadata.getAbsolutePath(), e.getCause());
        }
    }

    return null;
}

From source file:org.apache.archiva.rest.services.DefaultBrowseService.java

@Override
public Boolean artifactAvailable(String groupId, String artifactId, String version, String classifier,
        String repositoryId) throws ArchivaRestServiceException {
    List<String> selectedRepos = getSelectedRepos(repositoryId);

    boolean snapshot = VersionUtil.isSnapshot(version);

    try {/*  ww  w.j a  v  a2 s.co m*/
        for (String repoId : selectedRepos) {

            ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository(repoId);

            if ((snapshot && !managedRepository.isSnapshots())
                    || (!snapshot && managedRepository.isSnapshots())) {
                continue;
            }
            ManagedRepositoryContent managedRepositoryContent = repositoryContentFactory
                    .getManagedRepositoryContent(repoId);
            // FIXME default to jar which can be wrong for war zip etc....
            ArchivaArtifact archivaArtifact = new ArchivaArtifact(groupId, artifactId, version,
                    StringUtils.isEmpty(classifier) ? "" : classifier, "jar", repoId);
            File file = managedRepositoryContent.toFile(archivaArtifact);

            if (file != null && file.exists()) {
                return true;
            }

            // in case of SNAPSHOT we can have timestamped version locally !
            if (StringUtils.endsWith(version, VersionUtil.SNAPSHOT)) {
                File metadataFile = new File(file.getParent(), MetadataTools.MAVEN_METADATA);
                if (metadataFile.exists()) {
                    try {
                        ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader
                                .read(metadataFile);
                        int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
                        String timeStamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
                        // rebuild file name with timestamped version and build number
                        String timeStampFileName = new StringBuilder(artifactId).append('-') //
                                .append(StringUtils.remove(version, "-" + VersionUtil.SNAPSHOT)) //
                                .append('-').append(timeStamp) //
                                .append('-').append(Integer.toString(buildNumber)) //
                                .append((StringUtils.isEmpty(classifier) ? "" : "-" + classifier)) //
                                .append(".jar").toString();

                        File timeStampFile = new File(file.getParent(), timeStampFileName);
                        log.debug("try to find timestamped snapshot version file: {}", timeStampFile.getPath());
                        if (timeStampFile.exists()) {
                            return true;
                        }
                    } catch (XMLException e) {
                        log.warn("skip fail to find timestamped snapshot file: {}", e.getMessage());
                    }
                }
            }

            String path = managedRepositoryContent.toPath(archivaArtifact);

            file = connectors.fetchFromProxies(managedRepositoryContent, path);

            if (file != null && file.exists()) {
                // download pom now
                String pomPath = StringUtils.substringBeforeLast(path, ".jar") + ".pom";
                connectors.fetchFromProxies(managedRepositoryContent, pomPath);
                return true;
            }
        }
    } catch (RepositoryAdminException e) {
        log.error(e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
    } catch (RepositoryException e) {
        log.error(e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
    }

    return false;
}

From source file:org.apache.archiva.rest.services.DefaultRepositoriesService.java

@Override
public Boolean copyArtifact(ArtifactTransferRequest artifactTransferRequest)
        throws ArchivaRestServiceException {
    // check parameters
    String userName = getAuditInformation().getUser().getUsername();
    if (StringUtils.isBlank(userName)) {
        throw new ArchivaRestServiceException("copyArtifact call: userName not found", null);
    }/*from   www. j a  va  2s .  co m*/

    if (StringUtils.isBlank(artifactTransferRequest.getRepositoryId())) {
        throw new ArchivaRestServiceException("copyArtifact call: sourceRepositoryId cannot be null", null);
    }

    if (StringUtils.isBlank(artifactTransferRequest.getTargetRepositoryId())) {
        throw new ArchivaRestServiceException("copyArtifact call: targetRepositoryId cannot be null", null);
    }

    ManagedRepository source = null;
    try {
        source = managedRepositoryAdmin.getManagedRepository(artifactTransferRequest.getRepositoryId());
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }

    if (source == null) {
        throw new ArchivaRestServiceException(
                "cannot find repository with id " + artifactTransferRequest.getRepositoryId(), null);
    }

    ManagedRepository target = null;
    try {
        target = managedRepositoryAdmin.getManagedRepository(artifactTransferRequest.getTargetRepositoryId());
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }

    if (target == null) {
        throw new ArchivaRestServiceException(
                "cannot find repository with id " + artifactTransferRequest.getTargetRepositoryId(), null);
    }

    if (StringUtils.isBlank(artifactTransferRequest.getGroupId())) {
        throw new ArchivaRestServiceException("groupId is mandatory", null);
    }

    if (StringUtils.isBlank(artifactTransferRequest.getArtifactId())) {
        throw new ArchivaRestServiceException("artifactId is mandatory", null);
    }

    if (StringUtils.isBlank(artifactTransferRequest.getVersion())) {
        throw new ArchivaRestServiceException("version is mandatory", null);
    }

    if (VersionUtil.isSnapshot(artifactTransferRequest.getVersion())) {
        throw new ArchivaRestServiceException("copy of SNAPSHOT not supported", null);
    }

    // end check parameters

    User user = null;
    try {
        user = securitySystem.getUserManager().findUser(userName);
    } catch (UserNotFoundException e) {
        throw new ArchivaRestServiceException("user " + userName + " not found", e);
    } catch (UserManagerException e) {
        throw new ArchivaRestServiceException("ArchivaRestServiceException:" + e.getMessage(), e);
    }

    // check karma on source : read
    AuthenticationResult authn = new AuthenticationResult(true, userName, null);
    SecuritySession securitySession = new DefaultSecuritySession(authn, user);
    try {
        boolean authz = securitySystem.isAuthorized(securitySession,
                ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, artifactTransferRequest.getRepositoryId());
        if (!authz) {
            throw new ArchivaRestServiceException(
                    "not authorized to access repo:" + artifactTransferRequest.getRepositoryId(), null);
        }
    } catch (AuthorizationException e) {
        log.error("error reading permission: " + e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }

    // check karma on target: write
    try {
        boolean authz = securitySystem.isAuthorized(securitySession,
                ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD,
                artifactTransferRequest.getTargetRepositoryId());
        if (!authz) {
            throw new ArchivaRestServiceException(
                    "not authorized to write to repo:" + artifactTransferRequest.getTargetRepositoryId(), null);
        }
    } catch (AuthorizationException e) {
        log.error("error reading permission: " + e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }

    // sounds good we can continue !

    ArtifactReference artifactReference = new ArtifactReference();
    artifactReference.setArtifactId(artifactTransferRequest.getArtifactId());
    artifactReference.setGroupId(artifactTransferRequest.getGroupId());
    artifactReference.setVersion(artifactTransferRequest.getVersion());
    artifactReference.setClassifier(artifactTransferRequest.getClassifier());
    String packaging = StringUtils.trim(artifactTransferRequest.getPackaging());
    artifactReference.setType(StringUtils.isEmpty(packaging) ? "jar" : packaging);

    try {

        ManagedRepositoryContent sourceRepository = repositoryFactory
                .getManagedRepositoryContent(artifactTransferRequest.getRepositoryId());

        String artifactSourcePath = sourceRepository.toPath(artifactReference);

        if (StringUtils.isEmpty(artifactSourcePath)) {
            log.error("cannot find artifact " + artifactTransferRequest.toString());
            throw new ArchivaRestServiceException("cannot find artifact " + artifactTransferRequest.toString(),
                    null);
        }

        File artifactFile = new File(source.getLocation(), artifactSourcePath);

        if (!artifactFile.exists()) {
            log.error("cannot find artifact " + artifactTransferRequest.toString());
            throw new ArchivaRestServiceException("cannot find artifact " + artifactTransferRequest.toString(),
                    null);
        }

        ManagedRepositoryContent targetRepository = repositoryFactory
                .getManagedRepositoryContent(artifactTransferRequest.getTargetRepositoryId());

        String artifactPath = targetRepository.toPath(artifactReference);

        int lastIndex = artifactPath.lastIndexOf('/');

        String path = artifactPath.substring(0, lastIndex);
        File targetPath = new File(target.getLocation(), path);

        Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
        int newBuildNumber = 1;
        String timestamp = null;

        File versionMetadataFile = new File(targetPath, MetadataTools.MAVEN_METADATA);
        /* unused */ getMetadata(versionMetadataFile);

        if (!targetPath.exists()) {
            targetPath.mkdirs();
        }

        String filename = artifactPath.substring(lastIndex + 1);

        boolean fixChecksums = !(archivaAdministration.getKnownContentConsumers()
                .contains("create-missing-checksums"));

        File targetFile = new File(targetPath, filename);
        if (targetFile.exists() && target.isBlockRedeployments()) {
            throw new ArchivaRestServiceException("artifact already exists in target repo: "
                    + artifactTransferRequest.getTargetRepositoryId() + " and redeployment blocked", null);
        } else {
            copyFile(artifactFile, targetPath, filename, fixChecksums);
            queueRepositoryTask(target.getId(), targetFile);
        }

        // copy source pom to target repo
        String pomFilename = filename;
        if (StringUtils.isNotBlank(artifactTransferRequest.getClassifier())) {
            pomFilename = StringUtils.remove(pomFilename, "-" + artifactTransferRequest.getClassifier());
        }
        pomFilename = FilenameUtils.removeExtension(pomFilename) + ".pom";

        File pomFile = new File(
                new File(source.getLocation(), artifactSourcePath.substring(0, artifactPath.lastIndexOf('/'))),
                pomFilename);

        if (pomFile != null && pomFile.length() > 0) {
            copyFile(pomFile, targetPath, pomFilename, fixChecksums);
            queueRepositoryTask(target.getId(), new File(targetPath, pomFilename));

        }

        // explicitly update only if metadata-updater consumer is not enabled!
        if (!archivaAdministration.getKnownContentConsumers().contains("metadata-updater")) {
            updateProjectMetadata(targetPath.getAbsolutePath(), lastUpdatedTimestamp, timestamp, newBuildNumber,
                    fixChecksums, artifactTransferRequest);

        }

        String msg = "Artifact \'" + artifactTransferRequest.getGroupId() + ":"
                + artifactTransferRequest.getArtifactId() + ":" + artifactTransferRequest.getVersion()
                + "\' was successfully deployed to repository \'"
                + artifactTransferRequest.getTargetRepositoryId() + "\'";
        log.debug("copyArtifact {}", msg);

    } catch (RepositoryException e) {
        log.error("RepositoryException: " + e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(), e);
    } catch (RepositoryAdminException e) {
        log.error("RepositoryAdminException: " + e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(), e);
    } catch (IOException e) {
        log.error("IOException: " + e.getMessage(), e);
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }
    return true;
}

From source file:org.apache.archiva.web.api.DefaultFileUploadService.java

protected void savePomFile(String repositoryId, FileMetadata fileMetadata, String groupId, String artifactId,
        String version, String packaging) throws ArchivaRestServiceException {

    try {//from  www .java2s .  co m
        boolean fixChecksums = !(archivaAdministration.getKnownContentConsumers()
                .contains("create-missing-checksums"));

        ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository(repositoryId);

        ArtifactReference artifactReference = new ArtifactReference();
        artifactReference.setArtifactId(artifactId);
        artifactReference.setGroupId(groupId);
        artifactReference.setVersion(version);
        artifactReference.setClassifier(fileMetadata.getClassifier());
        artifactReference.setType(packaging);

        ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent(repositoryId);

        String artifactPath = repository.toPath(artifactReference);

        int lastIndex = artifactPath.lastIndexOf('/');

        String path = artifactPath.substring(0, lastIndex);
        File targetPath = new File(repoConfig.getLocation(), path);

        String pomFilename = artifactPath.substring(lastIndex + 1);
        if (StringUtils.isNotEmpty(fileMetadata.getClassifier())) {
            pomFilename = StringUtils.remove(pomFilename, "-" + fileMetadata.getClassifier());
        }
        pomFilename = FilenameUtils.removeExtension(pomFilename) + ".pom";

        copyFile(new File(fileMetadata.getServerFileName()), targetPath, pomFilename, fixChecksums);
        triggerAuditEvent(repoConfig.getId(), path + "/" + pomFilename, AuditEvent.UPLOAD_FILE);
        queueRepositoryTask(repoConfig.getId(), new File(targetPath, pomFilename));
    } catch (IOException ie) {
        throw new ArchivaRestServiceException("Error encountered while uploading pom file: " + ie.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ie);
    } catch (RepositoryException rep) {
        throw new ArchivaRestServiceException("Repository exception: " + rep.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), rep);
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException("RepositoryAdmin exception: " + e.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
    }
}

From source file:org.apache.archiva.web.api.DefaultFileUploadService.java

protected void saveFile(String repositoryId, FileMetadata fileMetadata, boolean generatePom, String groupId,
        String artifactId, String version, String packaging) throws ArchivaRestServiceException {
    try {/*  ww  w  . j  a v  a 2s  . co m*/

        ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository(repositoryId);

        ArtifactReference artifactReference = new ArtifactReference();
        artifactReference.setArtifactId(artifactId);
        artifactReference.setGroupId(groupId);
        artifactReference.setVersion(version);
        artifactReference.setClassifier(fileMetadata.getClassifier());
        artifactReference.setType(
                StringUtils.isEmpty(fileMetadata.getPackaging()) ? packaging : fileMetadata.getPackaging());

        ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent(repositoryId);

        String artifactPath = repository.toPath(artifactReference);

        int lastIndex = artifactPath.lastIndexOf('/');

        String path = artifactPath.substring(0, lastIndex);
        File targetPath = new File(repoConfig.getLocation(), path);

        log.debug("artifactPath: {} found targetPath: {}", artifactPath, targetPath);

        Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
        int newBuildNumber = -1;
        String timestamp = null;

        File versionMetadataFile = new File(targetPath, MetadataTools.MAVEN_METADATA);
        ArchivaRepositoryMetadata versionMetadata = getMetadata(versionMetadataFile);

        if (VersionUtil.isSnapshot(version)) {
            TimeZone timezone = TimeZone.getTimeZone("UTC");
            DateFormat fmt = new SimpleDateFormat("yyyyMMdd.HHmmss");
            fmt.setTimeZone(timezone);
            timestamp = fmt.format(lastUpdatedTimestamp);
            if (versionMetadata.getSnapshotVersion() != null) {
                newBuildNumber = versionMetadata.getSnapshotVersion().getBuildNumber() + 1;
            } else {
                newBuildNumber = 1;
            }
        }

        if (!targetPath.exists()) {
            targetPath.mkdirs();
        }

        String filename = artifactPath.substring(lastIndex + 1);
        if (VersionUtil.isSnapshot(version)) {
            filename = filename.replaceAll(VersionUtil.SNAPSHOT, timestamp + "-" + newBuildNumber);
        }

        boolean fixChecksums = !(archivaAdministration.getKnownContentConsumers()
                .contains("create-missing-checksums"));

        try {
            File targetFile = new File(targetPath, filename);
            if (targetFile.exists() && !VersionUtil.isSnapshot(version) && repoConfig.isBlockRedeployments()) {
                throw new ArchivaRestServiceException("Overwriting released artifacts in repository '"
                        + repoConfig.getId() + "' is not allowed.", Response.Status.BAD_REQUEST.getStatusCode(),
                        null);
            } else {
                copyFile(new File(fileMetadata.getServerFileName()), targetPath, filename, fixChecksums);
                triggerAuditEvent(repository.getId(), path + "/" + filename, AuditEvent.UPLOAD_FILE);
                queueRepositoryTask(repository.getId(), targetFile);
            }
        } catch (IOException ie) {
            log.error("IOException copying file: {}", ie.getMessage(), ie);
            throw new ArchivaRestServiceException(
                    "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed.",
                    Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ie);
        }

        if (generatePom) {
            String pomFilename = filename;
            if (StringUtils.isNotEmpty(fileMetadata.getClassifier())) {
                pomFilename = StringUtils.remove(pomFilename, "-" + fileMetadata.getClassifier());
            }
            pomFilename = FilenameUtils.removeExtension(pomFilename) + ".pom";

            try {
                File generatedPomFile = createPom(targetPath, pomFilename, fileMetadata, groupId, artifactId,
                        version, packaging);
                triggerAuditEvent(repoConfig.getId(), path + "/" + pomFilename, AuditEvent.UPLOAD_FILE);
                if (fixChecksums) {
                    fixChecksums(generatedPomFile);
                }
                queueRepositoryTask(repoConfig.getId(), generatedPomFile);
            } catch (IOException ie) {
                throw new ArchivaRestServiceException(
                        "Error encountered while writing pom file: " + ie.getMessage(),
                        Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ie);
            }
        }

        // explicitly update only if metadata-updater consumer is not enabled!
        if (!archivaAdministration.getKnownContentConsumers().contains("metadata-updater")) {
            updateProjectMetadata(targetPath.getAbsolutePath(), lastUpdatedTimestamp, timestamp, newBuildNumber,
                    fixChecksums, fileMetadata, groupId, artifactId, version, packaging);

            if (VersionUtil.isSnapshot(version)) {
                updateVersionMetadata(versionMetadata, versionMetadataFile, lastUpdatedTimestamp, timestamp,
                        newBuildNumber, fixChecksums, fileMetadata, groupId, artifactId, version, packaging);
            }
        }
    } catch (RepositoryNotFoundException re) {
        throw new ArchivaRestServiceException("Target repository cannot be found: " + re.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), re);
    } catch (RepositoryException rep) {
        throw new ArchivaRestServiceException("Repository exception: " + rep.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), rep);
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException("RepositoryAdmin exception: " + e.getMessage(),
                Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
    }
}