From 1225a39302270ec4e010d9b77b46872d3cf640c5 Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 19 Nov 2012 08:10:10 +0000 Subject: [PATCH] Method is added to get download directory by user id. --- .../splat/service/ScenarioServiceImpl.java | 18 +++--- .../service/technical/RepositoryService.java | 57 ++++++++++++++++--- .../technical/RepositoryServiceImpl.java | 48 +++++++++++++--- 3 files changed, 100 insertions(+), 23 deletions(-) diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java index 705b534..3e11657 100644 --- a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java @@ -357,6 +357,10 @@ public class ScenarioServiceImpl implements ScenarioService { return isOk; } + public void checkin(final long scenId, final long userId, final List scInfo) { + + } + /** * {@inheritDoc} * @@ -374,14 +378,14 @@ public class ScenarioServiceImpl implements ScenarioService { * @see org.splat.service.ScenarioService#checkout(org.splat.dal.bo.som.Scenario, org.splat.dal.bo.kernel.User) */ public boolean checkout(final Scenario aScenario, final User user) { - if (!getStudyService().isStaffedBy(aScenario.getOwnerStudy(), user)) { - return false; + boolean res = + getStudyService().isStaffedBy(aScenario.getOwnerStudy(), user); + if (res) { + aScenario.setUser(user); + aScenario.setLastModificationDate(Calendar.getInstance().getTime()); + getScenarioDAO().update(aScenario); } - - aScenario.setUser(user); - aScenario.setLastModificationDate(Calendar.getInstance().getTime()); - getScenarioDAO().update(aScenario); - return true; + return res; } /** diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java index 3965a1a..b8a913b 100644 --- a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java +++ b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java @@ -14,20 +14,63 @@ import java.io.File; import org.splat.dal.bo.kernel.User; /** - * @author RKV + * The service for working with the repository. Provides paths to download and vault directory. * + * @author Roman Kozlov (RKV) */ public interface RepositoryService { - public File getRepositoryIndexDirectory(); + /** + * Get index directory path. + * + * @return index directory path + */ + File getRepositoryIndexDirectory(); - public String getRepositoryVaultPath(); + /** + * Get vault path. + * + * @return vault path + */ + String getRepositoryVaultPath(); - public String getBasepath(); + /** + * Get repository root path. + * + * @return repository root path + */ + String getBasepath(); - public void setBasepath(String basepath); + /** + * Set repository root path. + * + * @param basepath + * repository root path + */ + void setBasepath(String basepath); - public File getDownloadDirectory(User user); + /** + * Get download directory for the given user according to his name. + * + * @param user + * the user + * @return user download directory by user name + */ + File getDownloadDirectory(final User user); - public String getTemplatePath(); + /** + * Get download directory for a user according to his id. + * + * @param userId + * the user id + * @return user download directory by user id + */ + File getDownloadDirectory(final long userId); + + /** + * Get path to templates folder. + * + * @return the path to templates folder + */ + String getTemplatePath(); } diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java index 7ad6f13..b1a6f81 100644 --- a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java @@ -14,44 +14,74 @@ import java.io.File; import org.splat.dal.bo.kernel.User; /** - * @author RKV + * The service for working with the repository. Provides paths to download and vault directory. * + * @author Roman Kozlov (RKV) */ public class RepositoryServiceImpl implements RepositoryService { + /** + * The repository root path. + */ private String _basepath; + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#getRepositoryIndexDirectory() + */ public File getRepositoryIndexDirectory() { return new File(getBasepath() + "lucin/"); } + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#getRepositoryVaultPath() + */ public String getRepositoryVaultPath() { return (getBasepath() + "vault/"); } - public File getDownloadDirectory(User user) { + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#getDownloadDirectory(org.splat.dal.bo.kernel.User) + */ + public File getDownloadDirectory(final User user) { StringBuffer path = new StringBuffer(_basepath).append("downloads/") .append(user.getUsername()).append("/"); return new File(path.toString()); } + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#getDownloadDirectory(long) + */ + public File getDownloadDirectory(final long userId) { + StringBuffer path = new StringBuffer(_basepath).append("downloads/") + .append(userId).append("/"); + return new File(path.toString()); + } + + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#getTemplatePath() + */ public String getTemplatePath() { return (_basepath + "templates/"); } - /** - * Get the basepath. - * @return the basepath + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#getBasepath() */ public String getBasepath() { return _basepath; } - /** - * Set the basepath. - * @param basepath the basepath to set + /** + * {@inheritDoc} + * @see org.splat.service.technical.RepositoryService#setBasepath(java.lang.String) */ - public void setBasepath(String basepath) { + public void setBasepath(final String basepath) { _basepath = basepath; } } -- 2.39.2