use of org.craftercms.studio.api.v2.repository.blob.StudioBlobStore in project studio by craftercms.
the class BlobAwareContentRepository method publish.
@Override
public void publish(String site, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment) throws DeploymentException {
logger.debug("Publishing items {0} to environment {1} in site {2}", deploymentItems, environment, site);
Map<String, StudioBlobStore> stores = new LinkedHashMap<>();
MultiValueMap<String, DeploymentItemTO> items = new LinkedMultiValueMap<>();
List<DeploymentItemTO> localItems = new LinkedList<>();
try {
for (DeploymentItemTO item : deploymentItems) {
StudioBlobStore store = getBlobStore(site, item.getPath());
if (store != null) {
stores.putIfAbsent(store.getId(), store);
items.add(store.getId(), item);
localItems.add(mapDeploymentItem(item));
} else {
localItems.add(item);
}
}
for (String storeId : stores.keySet()) {
logger.debug("Publishing blobs to environment {0} using store {1} for site {2}", environment, storeId, site);
stores.get(storeId).publish(site, sandboxBranch, items.get(storeId), environment, author, comment);
}
logger.debug("Publishing local files to environment {0} for site {1}", environment, site);
localRepositoryV2.publish(site, sandboxBranch, localItems, environment, author, comment);
} catch (Exception e) {
throw new DeploymentException("Error during deployment to environment " + environment + " for site " + site, e);
}
}
use of org.craftercms.studio.api.v2.repository.blob.StudioBlobStore in project studio by craftercms.
the class BlobAwareContentRepository method writeContent.
@Override
public String writeContent(String site, String path, InputStream content) throws ServiceLayerException {
logger.debug("Writing {0} in site {1}", path, site);
try {
StudioBlobStore store = getBlobStore(site, path);
if (store != null) {
store.writeContent(site, normalize(path), content);
Blob reference = store.getReference(normalize(path));
return localRepositoryV1.writeContent(site, getPointerPath(site, path), new ByteArrayInputStream(objectMapper.writeValueAsBytes(reference)));
}
return localRepositoryV1.writeContent(site, path, content);
} catch (RepositoryLockedException e) {
throw e;
} catch (Exception e) {
logger.error("Error writing content {0} in site {1}", e, path, site);
throw new ServiceLayerException(e);
}
}
use of org.craftercms.studio.api.v2.repository.blob.StudioBlobStore in project studio by craftercms.
the class BlobAwareContentRepository method moveContent.
@Override
public Map<String, String> moveContent(String site, String fromPath, String toPath, String newName) {
logger.debug("Moving content from {0} to {1} in site {2}", fromPath, toPath, site);
try {
StudioBlobStore store = getBlobStore(site, fromPath, toPath);
if (store != null) {
Map<String, String> result = store.moveContent(site, normalize(fromPath), normalize(toPath), newName);
if (result != null) {
boolean isFolder = isFolder(site, fromPath);
Map<String, String> diskResult = localRepositoryV1.moveContent(site, isFolder ? fromPath : getPointerPath(site, fromPath), isFolder ? toPath : getPointerPath(site, toPath), newName);
Set<String> keys = new HashSet<>(diskResult.keySet());
keys.forEach(k -> {
String val = diskResult.get(k);
diskResult.put(getPathFromPointerPath(site, k), val);
});
return diskResult;
}
}
return localRepositoryV1.moveContent(site, fromPath, toPath, newName);
} catch (Exception e) {
logger.error("Error moving content from {0} to {1} in site {2}", e, fromPath, toPath, site);
return null;
}
}
Aggregations