use of org.craftercms.commons.validation.annotations.param.ValidateParams in project studio by craftercms.
the class NotificationServiceImpl method notifyRepositoryMergeConflict.
@Override
@ValidateParams
public void notifyRepositoryMergeConflict(@ValidateStringParam(name = "site") final String site, final List<String> filesUnableToMerge, final Locale locale) {
try {
final NotificationConfigTO notificationConfig = getNotificationConfig(site, locale);
final Map<String, Object> templateModel = new HashMap<>();
templateModel.put("files", filesUnableToMerge);
notify(site, notificationConfig.getRepositoryMergeConflictNotifications(), NOTIFICATION_KEY_REPOSITORY_MERGE_CONFLICT, locale, templateModel);
} catch (Throwable ex) {
logger.error("Unable to Notify Error", ex);
}
}
use of org.craftercms.commons.validation.annotations.param.ValidateParams in project studio by craftercms.
the class ContentServiceImpl method moveContent.
@Override
@ValidateParams
public String moveContent(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "fromPath") String fromPath, @ValidateSecurePathParam(name = "toPath") String toPath) {
String retNewFileName = null;
boolean opSuccess = false;
String movePath = null;
try {
String sourcePath = (fromPath.indexOf("" + FILE_SEPARATOR + DmConstants.INDEX_FILE) != -1) ? fromPath.substring(0, fromPath.lastIndexOf(FILE_SEPARATOR)) : fromPath;
String sourcePathOnly = fromPath.substring(0, fromPath.lastIndexOf(FILE_SEPARATOR));
Map<String, String> movePathMap = constructNewPathforCutCopy(site, fromPath, toPath, true);
movePath = movePathMap.get("FILE_PATH");
String moveFileName = movePathMap.get("FILE_NAME");
String movePathOnly = movePath.substring(0, movePath.lastIndexOf(FILE_SEPARATOR));
boolean moveAltFileName = "true".equals(movePathMap.get("ALT_NAME"));
boolean targetIsIndex = DmConstants.INDEX_FILE.equals(moveFileName);
boolean sourceIsIndex = DmConstants.INDEX_FILE.equals(fromPath);
String targetPath = movePathOnly;
if (movePathOnly.equals(sourcePathOnly) || (moveAltFileName == true && !targetIsIndex) || (!sourceIsIndex && !targetIsIndex)) {
// we never send index.xml to the repo, we move folders (and the folder has the rename)
// SO otherwise, this is a rename and we need to forward the full path
targetPath = movePath;
}
logger.debug("Move file for site {0} from {1} to {2}, sourcePath {3} to target path {4}", site, fromPath, toPath, sourcePath, targetPath);
// NOTE: IN WRITE SCENARIOS the repository OP IS PART of this PIPELINE, for some reason,
// historically with MOVE it is not
Map<String, String> commitIds = _contentRepository.moveContent(site, sourcePath, targetPath);
if (commitIds != null) {
// Update the database with the commitId for the target item
updateDatabaseOnMove(site, fromPath, movePath);
updateChildrenOnMove(site, fromPath, movePath);
for (Map.Entry<String, String> entry : commitIds.entrySet()) {
objectMetadataManager.updateCommitId(site, FILE_SEPARATOR + entry.getKey(), entry.getValue());
contentRepository.insertGitLog(site, entry.getValue(), 1, 1);
}
siteService.updateLastCommitId(site, _contentRepository.getRepoLastCommitId(site));
} else {
logger.error("Repository move failed site {0} from {1} to {2}", site, sourcePath, targetPath);
movePath = fromPath;
}
PreviewEventContext context = new PreviewEventContext();
context.setSite(site);
eventService.publish(EVENT_PREVIEW_SYNC, context);
} catch (ServiceLayerException eMoveErr) {
logger.error("Content not found while moving content for site {0} from {1} to {2}, new name is {3}", eMoveErr, site, fromPath, toPath, movePath);
}
return movePath;
}
use of org.craftercms.commons.validation.annotations.param.ValidateParams in project studio by craftercms.
the class ContentServiceImpl method getDeleteCandidates.
@Override
@ValidateParams
public GoLiveDeleteCandidates getDeleteCandidates(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "relativePath") String relativePath) throws ServiceLayerException {
ContentItemTO contentItem = getContentItem(site, relativePath);
GoLiveDeleteCandidates deletedItems = new GoLiveDeleteCandidates(site, this, objectStateService);
if (contentItem != null) {
childDeleteItems(site, contentItem, deletedItems);
// update summary for all uri's delete
}
return deletedItems;
}
use of org.craftercms.commons.validation.annotations.param.ValidateParams in project studio by craftercms.
the class ContentTypesConfigImpl method reloadConfiguration.
@Override
@ValidateParams
public ContentTypeConfigTO reloadConfiguration(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "contentType") String contentType) {
StudioCacheContext cacheContext = new StudioCacheContext(site, true);
String siteConfigPath = getConfigPath().replaceAll(StudioConstants.PATTERN_SITE, site).replaceAll(StudioConstants.PATTERN_CONTENT_TYPE, contentType);
ContentTypeConfigTO config = loadConfiguration(site, contentType);
return config;
}
use of org.craftercms.commons.validation.annotations.param.ValidateParams in project studio by craftercms.
the class ContentTypesConfigImpl method loadConfiguration.
@SuppressWarnings("unchecked")
@Override
@ValidateParams
public ContentTypeConfigTO loadConfiguration(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "contentType") String contentType) {
String siteConfigPath = getConfigPath().replaceAll(StudioConstants.PATTERN_SITE, site).replaceAll(StudioConstants.PATTERN_CONTENT_TYPE, contentType);
String configFileFullPath = siteConfigPath + FILE_SEPARATOR + getConfigFileName();
Document document = null;
try {
if (contentService.contentExists(site, configFileFullPath)) {
document = contentService.getContentAsDocument(site, configFileFullPath);
}
} catch (DocumentException e) {
logger.debug("No content type configuration document found at " + configFileFullPath, e);
}
if (document != null) {
Element root = document.getRootElement();
String name = root.valueOf("@name");
ContentTypeConfigTO contentTypeConfig = new ContentTypeConfigTO();
contentTypeConfig.setName(name);
contentTypeConfig.setLabel(root.valueOf("label"));
String imageThumbnail = root.valueOf("image-thumbnail");
if (imageThumbnail != null)
contentTypeConfig.setImageThumbnail(imageThumbnail);
contentTypeConfig.setForm(root.valueOf("form"));
boolean previewable = ContentFormatUtils.getBooleanValue(root.valueOf("previewable"));
contentTypeConfig.setFormPath(root.valueOf("form-path"));
contentTypeConfig.setPreviewable(previewable);
contentTypeConfig.setModelInstancePath(root.valueOf("model-instance-path"));
boolean contentAsFolder = ContentFormatUtils.getBooleanValue(root.valueOf("content-as-folder"));
contentTypeConfig.setContentAsFolder(contentAsFolder);
boolean useRoundedFolder = ContentFormatUtils.getBooleanValue(root.valueOf("use-rounded-folder"));
contentTypeConfig.setUseRoundedFolder(useRoundedFolder);
List<String> pathIncludes = getPaths(root, "paths/includes/pattern");
if (pathIncludes.size() == 0) {
// if no configuration, include every path
pathIncludes.add(".*");
}
contentTypeConfig.setPathIncludes(pathIncludes);
List<String> pathExcludes = getPaths(root, "paths/excludes/pattern");
contentTypeConfig.setPathExcludes(pathExcludes);
loadRoles(contentTypeConfig, root.selectNodes("allowed-roles/role"));
loadDeleteDependencies(contentTypeConfig, root.selectNodes("delete-dependencies/delete-dependency"));
loadCopyDependencyPatterns(contentTypeConfig, root.selectNodes("copy-dependencies/copy-dependency"));
contentTypeConfig.setLastUpdated(ZonedDateTime.now(ZoneOffset.UTC));
contentTypeConfig.setType(getContentTypeTypeByName(name));
boolean quickCreate = ContentFormatUtils.getBooleanValue(root.valueOf(QUICK_CREATE));
contentTypeConfig.setQuickCreate(quickCreate);
contentTypeConfig.setQuickCreatePath(root.valueOf(QUICK_CREATE_PATH));
return contentTypeConfig;
} else {
logger.debug("No content type configuration document found at " + configFileFullPath);
return null;
}
}
Aggregations