use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class UserServiceImpl method updateUser.
@Override
@HasPermission(type = DefaultPermission.class, action = "update_users")
public void updateUser(User user) throws ServiceLayerException, UserNotFoundException, AuthenticationException {
userServiceInternal.updateUser(user);
SiteFeed siteFeed = siteService.getSite(studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE));
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_UPDATE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(getCurrentUser().getUsername());
auditLog.setPrimaryTargetId(user.getUsername());
auditLog.setPrimaryTargetType(TARGET_TYPE_USER);
auditLog.setPrimaryTargetValue(user.getUsername());
auditServiceInternal.insertAuditLog(auditLog);
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class AddSiteUuidOperation method execute.
@Override
public void execute(String site) throws UpgradeException {
logger.debug("Get site data from database for site " + site);
Map<String, String> params = new HashMap<String, String>();
params.put(SITE_ID, site);
SiteFeed siteFeed = siteFeedMapper.getSite(params);
if (siteFeed != null) {
try {
logger.debug("Add UUID file for site " + site);
addSiteUuidFile(site, siteFeed.getSiteUuid());
} catch (IOException e) {
throw new UpgradeException("Error when adding UUID file for site " + site, e);
}
}
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SiteRepositoryUpgradePipelineImpl method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String site) throws UpgradeException {
String gitLockKey = SITE_SANDBOX_REPOSITORY_GIT_LOCK.replaceAll(PATTERN_SITE, site);
generalLockService.lock(gitLockKey);
try {
clusterSandboxRepoSyncTask.execute(site);
GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
Repository repository = helper.getRepository(site, GitRepositories.SANDBOX);
String sandboxBranch = siteSandboxBranch;
if (repository != null) {
Git git = new Git(repository);
try {
if (!isEmpty()) {
SiteFeed siteFeed = siteService.getSite(site);
if (!StringUtils.isEmpty(siteFeed.getSandboxBranch())) {
sandboxBranch = siteFeed.getSandboxBranch();
}
createTemporaryBranch(site, git);
checkoutBranch(siteUpgradeBranch, git);
super.execute(site);
checkoutBranch(sandboxBranch, git);
mergeTemporaryBranch(repository, git);
deleteTemporaryBranch(git);
}
} catch (GitAPIException | IOException | SiteNotFoundException e) {
throw new UpgradeException("Error branching or merging upgrade branch for site " + site, e);
} finally {
if (!isEmpty()) {
try {
checkoutBranch(sandboxBranch, git);
} catch (GitAPIException e) {
logger.error("Error cleaning up repo for site " + site, e);
}
}
git.close();
}
}
} catch (CryptoException e) {
throw new UpgradeException("Unexpected error upgrading site " + site, e);
} finally {
generalLockService.unlock(gitLockKey);
}
}
Aggregations