use of org.apache.archiva.metadata.repository.MetadataRepositoryException in project archiva by apache.
the class MetadataAuditListener method auditEvent.
@Override
public void auditEvent(AuditEvent event) {
// for now we only log upload events, some of the others are quite noisy
if (event.getAction().equals(AuditEvent.CREATE_FILE) || event.getAction().equals(AuditEvent.UPLOAD_FILE) || event.getAction().equals(AuditEvent.MERGING_REPOSITORIES)) {
RepositorySession repositorySession = repositorySessionFactory.createSession();
try {
auditManager.addAuditEvent(repositorySession.getRepository(), event);
repositorySession.save();
} catch (MetadataRepositoryException e) {
log.warn("Unable to write audit event to repository: {}", e.getMessage(), e);
} finally {
repositorySession.close();
}
}
}
use of org.apache.archiva.metadata.repository.MetadataRepositoryException in project archiva by apache.
the class FileMetadataRepository method removeArtifact.
@Override
public void removeArtifact(ArtifactMetadata artifactMetadata, String baseVersion) throws MetadataRepositoryException {
try {
Path directory = getDirectory(artifactMetadata.getRepositoryId()).resolve(artifactMetadata.getNamespace() + "/" + artifactMetadata.getProject() + "/" + baseVersion);
Properties properties = readOrCreateProperties(directory, PROJECT_VERSION_METADATA_KEY);
String id = artifactMetadata.getId();
properties.remove("artifact:updated:" + id);
properties.remove("artifact:whenGathered:" + id);
properties.remove("artifact:size:" + id);
properties.remove("artifact:md5:" + id);
properties.remove("artifact:sha1:" + id);
properties.remove("artifact:version:" + id);
properties.remove("artifact:facetIds:" + id);
String prefix = "artifact:facet:" + id + ":";
for (Object key : new ArrayList<>(properties.keySet())) {
String property = (String) key;
if (property.startsWith(prefix)) {
properties.remove(property);
}
}
writeProperties(properties, directory, PROJECT_VERSION_METADATA_KEY);
} catch (IOException e) {
throw new MetadataRepositoryException(e.getMessage(), e);
}
}
use of org.apache.archiva.metadata.repository.MetadataRepositoryException in project archiva by apache.
the class FileMetadataRepository method removeRepository.
@Override
public void removeRepository(String repoId) throws MetadataRepositoryException {
try {
Path dir = getDirectory(repoId);
org.apache.archiva.common.utils.FileUtils.deleteDirectory(dir);
} catch (IOException e) {
throw new MetadataRepositoryException(e.getMessage(), e);
}
}
use of org.apache.archiva.metadata.repository.MetadataRepositoryException in project archiva by apache.
the class FileMetadataRepository method removeNamespace.
@Override
public void removeNamespace(String repositoryId, String project) throws MetadataRepositoryException {
try {
Path namespaceDirectory = getDirectory(repositoryId).resolve(project);
org.apache.archiva.common.utils.FileUtils.deleteDirectory(namespaceDirectory);
// Properties properties = new Properties();
// properties.setProperty( "namespace", namespace );
// writeProperties( properties, namespaceDirectory, NAMESPACE_METADATA_KEY );
} catch (IOException e) {
throw new MetadataRepositoryException(e.getMessage(), e);
}
}
use of org.apache.archiva.metadata.repository.MetadataRepositoryException in project archiva by apache.
the class FileMetadataRepository method removeMetadataFacet.
@Override
public void removeMetadataFacet(String repoId, String facetId, String name) throws MetadataRepositoryException {
try {
Path dir = getMetadataDirectory(repoId, facetId).resolve(name);
org.apache.archiva.common.utils.FileUtils.deleteDirectory(dir);
} catch (IOException e) {
throw new MetadataRepositoryException(e.getMessage(), e);
}
}
Aggregations