ref 12977: SAI - Force the path of the project folder to be updated to a new format

https://support.d4science.org/issues/12977

Now, when the project is open the path is forced to be updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@174652 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-12-07 11:02:49 +00:00
parent 46aacfc420
commit ab7baa8e4b
2 changed files with 46 additions and 33 deletions

View File

@ -466,7 +466,7 @@ public class FilesStorage {
}
} catch (Throwable e) {
logger.error("Retrieve project item on workspace: " + e.getLocalizedMessage(), e);
logger.error("Error retrieving project item on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
@ -536,7 +536,7 @@ public class FilesStorage {
return itemDescription;
} catch (Throwable e) {
logger.error("Retrieve file info on workspace: " + e.getLocalizedMessage(), e);
logger.error("Error retrieving file info on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
@ -566,7 +566,7 @@ public class FilesStorage {
return itemDescription;
} catch (Throwable e) {
logger.error("Retrieve folder info on workspace: " + e.getLocalizedMessage(), e);
logger.error("Error retrieving folder info on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}

View File

@ -50,45 +50,58 @@ public class ProjectArchiver {
public static Project readProject(ItemDescription newProjectFolder, ServiceCredentials serviceCredentials)
throws StatAlgoImporterServiceException {
FilesStorage filesStorage = new FilesStorage();
InputStream inputStream = filesStorage.getProjectItemOnWorkspace(serviceCredentials.getUserName(),
newProjectFolder.getId());
try {
FilesStorage filesStorage = new FilesStorage();
InputStream inputStream = filesStorage.getProjectItemOnWorkspace(serviceCredentials.getUserName(),
newProjectFolder.getId());
XMLDecoder xmlDecoder = new XMLDecoder(inputStream);
Project project = (Project) xmlDecoder.readObject();
xmlDecoder.close();
XMLDecoder xmlDecoder = new XMLDecoder(inputStream);
Project project = (Project) xmlDecoder.readObject();
xmlDecoder.close();
newProjectFolder = filesStorage.getFolderInfoOnWorkspace(serviceCredentials.getUserName(),
newProjectFolder.getId());
if (project != null) {
newProjectFolder = filesStorage.getFolderInfoOnWorkspace(serviceCredentials.getUserName(),
newProjectFolder.getId());
logger.debug("ProjectArchiver set project folder: " + newProjectFolder);
project.setProjectFolder(new ProjectFolder(newProjectFolder));
archive(project, serviceCredentials);
logger.debug("ProjectFolder info updated");
if (project != null) {
logger.debug("ProjectArchiver set project folder: " + newProjectFolder);
project.setProjectFolder(new ProjectFolder(newProjectFolder));
if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null
&& project.getMainCode().getItemDescription().getId() != null
&& !project.getMainCode().getItemDescription().getId().isEmpty()) {
if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null) {
try {
ItemDescription newMainCodeItemDescription = filesStorage.getFileInfoOnWorkspace(
serviceCredentials.getUserName(), project.getMainCode().getItemDescription().getId());
String pLink = filesStorage.getPublicLink(serviceCredentials.getUserName(),
newMainCodeItemDescription.getId());
newMainCodeItemDescription.setPublicLink(pLink);
logger.debug("ProjectArchiver set main code: " + newMainCodeItemDescription);
try {
ItemDescription newMainCodeItemDescription = filesStorage.getFileInfoOnWorkspace(
serviceCredentials.getUserName(), project.getMainCode().getItemDescription().getId());
String pLink = filesStorage.getPublicLink(serviceCredentials.getUserName(),
newMainCodeItemDescription.getId());
newMainCodeItemDescription.setPublicLink(pLink);
logger.debug("ProjectArchiver set main code: " + newMainCodeItemDescription);
project.setMainCode(new MainCode(newMainCodeItemDescription));
} catch (Throwable e) {
logger.error("ProjectArchiver error reading the main code: " + project.getMainCode().getItemDescription());
archive(project, serviceCredentials);
throw new StatAlgoImporterServiceException("Error reading the main code of the project!");
project.setMainCode(new MainCode(newMainCodeItemDescription));
archive(project, serviceCredentials);
logger.debug("Main Code info updated");
} catch (Throwable e) {
logger.error("ProjectArchiver error reading the main code: "
+ project.getMainCode().getItemDescription(), e);
throw new StatAlgoImporterServiceException("Invalid main code of the project!");
}
}
} else {
logger.debug("ProjectArchiver project retrieved is null!");
throw new StatAlgoImporterServiceException("The project retrieved is not valid!");
}
archive(project, serviceCredentials);
} else {
logger.debug("ProjectArchiver project retrieved is null!");
throw new StatAlgoImporterServiceException("The Project retrieved is not valid!");
return project;
} catch (StatAlgoImporterServiceException e) {
logger.error("Error reading the project info: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} catch (Throwable e) {
logger.error("Error reading the project info: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException("Invalid project info");
}
return project;
}
}