1832: Accounting Manager - On Storage Accounting filters values must not have the popup validation
Task-Url: https://support.d4science.org/issues/1832 Fixed Main Code delete git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122449 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bfb2a97bf1
commit
65c6329f7b
7
pom.xml
7
pom.xml
|
@ -98,6 +98,13 @@
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class MainDataPanel extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case DELETE_RESOURCE:
|
case DELETE_RESOURCE:
|
||||||
break;
|
break;
|
||||||
|
case DELETE_MAIN_CODE:
|
||||||
case MAIN_CODE_SET:
|
case MAIN_CODE_SET:
|
||||||
codeEditPanel.codeUpdate(event.getProject());
|
codeEditPanel.codeUpdate(event.getProject());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -450,9 +450,45 @@ public class ProjectManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteItem(ItemDescription itemDescription) {
|
public void deleteItem(final ItemDescription itemDescription) {
|
||||||
|
if (project != null
|
||||||
|
&& project.getMainCode() != null
|
||||||
|
&& project.getMainCode().getItemDescription() != null
|
||||||
|
&& itemDescription.getId().compareTo(
|
||||||
|
project.getMainCode().getItemDescription().getId()) == 0) {
|
||||||
|
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
|
||||||
|
"All previous configurations will be lost. Would you like to delete main code?");
|
||||||
|
mb.addDialogHideHandler(new DialogHideHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDialogHide(DialogHideEvent event) {
|
||||||
|
switch (event.getHideButton()) {
|
||||||
|
case NO:
|
||||||
|
break;
|
||||||
|
case YES:
|
||||||
|
deleteItemOnServer(itemDescription,true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mb.setWidth(300);
|
||||||
|
mb.show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
deleteItemOnServer(itemDescription, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteItemOnServer(ItemDescription itemDescription, final boolean mainCode){
|
||||||
|
|
||||||
StatAlgoImporterServiceAsync.INSTANCE.deleteResourceOnProject(
|
StatAlgoImporterServiceAsync.INSTANCE.deleteResourceOnProject(
|
||||||
itemDescription, new AsyncCallback<Void>() {
|
itemDescription, new AsyncCallback<Project>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -470,8 +506,13 @@ public class ProjectManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Project result) {
|
||||||
fireProjectStatusDeleteEvent();
|
project=result;
|
||||||
|
if(mainCode){
|
||||||
|
fireProjectStatusDeleteMainCodeEvent();
|
||||||
|
} else {
|
||||||
|
fireProjectStatusDeleteEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -509,6 +550,13 @@ public class ProjectManager {
|
||||||
eventBus.fireEvent(projectStatusEvent);
|
eventBus.fireEvent(projectStatusEvent);
|
||||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void fireProjectStatusDeleteMainCodeEvent() {
|
||||||
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||||
|
ProjectStatusEventType.DELETE_MAIN_CODE, project);
|
||||||
|
eventBus.fireEvent(projectStatusEvent);
|
||||||
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||||
|
}
|
||||||
|
|
||||||
protected void fireProjectStatusUpdateEvent() {
|
protected void fireProjectStatusUpdateEvent() {
|
||||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||||
|
@ -590,10 +638,8 @@ public class ProjectManager {
|
||||||
mb.show();
|
mb.show();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.error("Project not open: "+project);
|
Log.error("Project not open: " + project);
|
||||||
UtilsGXT3
|
UtilsGXT3.alert("Error", "Project not open!");
|
||||||
.alert("Error",
|
|
||||||
"Project not open!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -617,7 +663,8 @@ public class ProjectManager {
|
||||||
|
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
monitor.hide();
|
monitor.hide();
|
||||||
UtilsGXT3.info("Publish", "The software has been published!");
|
UtilsGXT3.info("Publish",
|
||||||
|
"The software has been published!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public interface StatAlgoImporterService extends RemoteService {
|
||||||
public void addResourceToProject(ItemDescription itemDescription)
|
public void addResourceToProject(ItemDescription itemDescription)
|
||||||
throws StatAlgoImporterServiceException;
|
throws StatAlgoImporterServiceException;
|
||||||
|
|
||||||
public void deleteResourceOnProject(ItemDescription itemDescription)
|
public Project deleteResourceOnProject(ItemDescription itemDescription)
|
||||||
throws StatAlgoImporterServiceException;
|
throws StatAlgoImporterServiceException;
|
||||||
|
|
||||||
public void saveProject(InputData inputData)
|
public void saveProject(InputData inputData)
|
||||||
|
|
|
@ -48,7 +48,7 @@ public interface StatAlgoImporterServiceAsync {
|
||||||
AsyncCallback<Void> asyncCallback);
|
AsyncCallback<Void> asyncCallback);
|
||||||
|
|
||||||
void deleteResourceOnProject(ItemDescription itemDescription,
|
void deleteResourceOnProject(ItemDescription itemDescription,
|
||||||
AsyncCallback<Void> asyncCallback);
|
AsyncCallback<Project> asyncCallback);
|
||||||
|
|
||||||
void openProjectOnWorkspace(ItemDescription newProjectFolder,
|
void openProjectOnWorkspace(ItemDescription newProjectFolder,
|
||||||
AsyncCallback<Project> asyncCallback);
|
AsyncCallback<Project> asyncCallback);
|
||||||
|
|
|
@ -115,6 +115,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
case ADD_RESOURCE:
|
case ADD_RESOURCE:
|
||||||
case DELETE_RESOURCE:
|
case DELETE_RESOURCE:
|
||||||
|
case DELETE_MAIN_CODE:
|
||||||
create(event);
|
create(event);
|
||||||
break;
|
break;
|
||||||
case SAVE:
|
case SAVE:
|
||||||
|
|
|
@ -21,7 +21,8 @@ public class InputVariablePanel extends ContentPanel {
|
||||||
|
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
private InputVariableTabPanel inputVariableTabPanel;
|
private InputVariableTabPanel inputVariableTabPanel;
|
||||||
//private InputVariablePanelState state;
|
|
||||||
|
// private InputVariablePanelState state;
|
||||||
|
|
||||||
public InputVariablePanel(EventBus eventBus) {
|
public InputVariablePanel(EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
|
@ -66,7 +67,7 @@ public class InputVariablePanel extends ContentPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(InputRequestEvent.TYPE,
|
eventBus.addHandler(InputRequestEvent.TYPE,
|
||||||
new InputRequestEvent.InputRequestEventHandler() {
|
new InputRequestEvent.InputRequestEventHandler() {
|
||||||
|
|
||||||
|
@ -77,41 +78,40 @@ public class InputVariablePanel extends ContentPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(
|
|
||||||
NewSelectedRowsVariableEvent.TYPE,
|
|
||||||
new NewSelectedRowsVariableEvent.NewSelectedRowsVariableEventHandler() {
|
|
||||||
|
|
||||||
@Override
|
eventBus.addHandler(
|
||||||
public void onNewVariable(NewSelectedRowsVariableEvent event) {
|
NewSelectedRowsVariableEvent.TYPE,
|
||||||
addNewSelectedRowsVariable(event
|
new NewSelectedRowsVariableEvent.NewSelectedRowsVariableEventHandler() {
|
||||||
.getSelectedRowsVariable());
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onNewVariable(NewSelectedRowsVariableEvent event) {
|
||||||
|
addNewSelectedRowsVariable(event
|
||||||
|
.getSelectedRowsVariable());
|
||||||
|
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addNewSelectedRowsVariable(
|
protected void addNewSelectedRowsVariable(
|
||||||
InputOutputVariables selectedRowsVariable) {
|
InputOutputVariables selectedRowsVariable) {
|
||||||
inputVariableTabPanel.addSelectedRowsVariable(selectedRowsVariable);
|
inputVariableTabPanel.addSelectedRowsVariable(selectedRowsVariable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void manageInputRequestEvents(InputRequestEvent event) {
|
protected void manageInputRequestEvents(InputRequestEvent event) {
|
||||||
inputVariableTabPanel.requestInput();
|
inputVariableTabPanel.requestInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void manageProjectStatusEvents(ProjectStatusEvent event) {
|
protected void manageProjectStatusEvents(ProjectStatusEvent event) {
|
||||||
Log.debug("InputVariablePanel recieved event ProjectStatus: "
|
Log.debug("InputVariablePanel recieved event ProjectStatus: "
|
||||||
+ event.toString());
|
+ event.toString());
|
||||||
switch (event.getProjectStatusEventType()) {
|
switch (event.getProjectStatusEventType()) {
|
||||||
|
case SAVE:
|
||||||
|
break;
|
||||||
|
case SOFTWARE_CREATED:
|
||||||
|
break;
|
||||||
case START:
|
case START:
|
||||||
break;
|
break;
|
||||||
case OPEN:
|
case OPEN:
|
||||||
|
@ -122,12 +122,18 @@ public class InputVariablePanel extends ContentPanel {
|
||||||
break;
|
break;
|
||||||
case ADD_RESOURCE:
|
case ADD_RESOURCE:
|
||||||
break;
|
break;
|
||||||
|
case DELETE_RESOURCE:
|
||||||
|
break;
|
||||||
|
case DELETE_MAIN_CODE:
|
||||||
|
setMainCode(event.getProject());
|
||||||
|
break;
|
||||||
case MAIN_CODE_SET:
|
case MAIN_CODE_SET:
|
||||||
setMainCode(event.getProject());
|
setMainCode(event.getProject());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create(Project project) {
|
private void create(Project project) {
|
||||||
|
@ -145,21 +151,21 @@ public class InputVariablePanel extends ContentPanel {
|
||||||
private void startPanel(Project project) {
|
private void startPanel(Project project) {
|
||||||
enable();
|
enable();
|
||||||
expand();
|
expand();
|
||||||
//state = InputVariablePanelState.OPENED;
|
// state = InputVariablePanelState.OPENED;
|
||||||
inputVariableTabPanel.startTabs(project);
|
inputVariableTabPanel.startTabs(project);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePanel(Project project) {
|
private void updatePanel(Project project) {
|
||||||
inputVariableTabPanel.updateTabs(project);
|
inputVariableTabPanel.updateTabs(project);
|
||||||
Log.debug("ToolBoxPanel Updated");
|
Log.debug("ToolBoxPanel Updated");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMainCode(Project project) {
|
private void setMainCode(Project project) {
|
||||||
inputVariableTabPanel.setMainCode(project);
|
inputVariableTabPanel.setMainCode(project);
|
||||||
Log.debug("ToolBoxPanel Updated");
|
Log.debug("ToolBoxPanel Updated");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ public enum ProjectStatusEventType {
|
||||||
UPDATE,
|
UPDATE,
|
||||||
ADD_RESOURCE,
|
ADD_RESOURCE,
|
||||||
DELETE_RESOURCE,
|
DELETE_RESOURCE,
|
||||||
|
DELETE_MAIN_CODE,
|
||||||
SOFTWARE_CREATED,
|
SOFTWARE_CREATED,
|
||||||
SAVE;
|
SAVE;
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
System.out.println("initializing StatAlgoImporterService");
|
System.out.println("initializing StatAlgoImporterService");
|
||||||
String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt";
|
String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt";
|
||||||
InputStream notificationRecipientsInputStream = this.getServletContext()
|
InputStream notificationRecipientsInputStream = this
|
||||||
.getResourceAsStream(notificationRecipientsFile);
|
.getServletContext().getResourceAsStream(
|
||||||
|
notificationRecipientsFile);
|
||||||
String text = null;
|
String text = null;
|
||||||
try {
|
try {
|
||||||
text = IOUtils.toString(notificationRecipientsInputStream,
|
text = IOUtils.toString(notificationRecipientsInputStream,
|
||||||
|
@ -70,7 +71,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
ArrayList<Recipient> recipients = new ArrayList<Recipient>();
|
ArrayList<Recipient> recipients = new ArrayList<Recipient>();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(text);
|
JSONObject obj = new JSONObject(text);
|
||||||
System.out.println(""+obj);
|
System.out.println("" + obj);
|
||||||
JSONArray arr = obj.getJSONArray("recipients");
|
JSONArray arr = obj.getJSONArray("recipients");
|
||||||
for (int i = 0; i < arr.length(); i++) {
|
for (int i = 0; i < arr.length(); i++) {
|
||||||
JSONObject dest = arr.getJSONObject(i);
|
JSONObject dest = arr.getJSONObject(i);
|
||||||
|
@ -80,11 +81,11 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
String name = dest.getString("name");
|
String name = dest.getString("name");
|
||||||
Recipient rec = new Recipient(user, surname, name);
|
Recipient rec = new Recipient(user, surname, name);
|
||||||
recipients.add(rec);
|
recipients.add(rec);
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println("Recipients: "+recipients);
|
System.out.println("Recipients: " + recipients);
|
||||||
SessionUtil.setRecipients(this.getServletContext(), recipients);
|
SessionUtil.setRecipients(this.getServletContext(), recipients);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,12 +209,18 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
logger.debug("createProjectOnWorkspace()");
|
logger.debug("createProjectOnWorkspace()");
|
||||||
ProjectFolder projectFolder = new ProjectFolder(newProjectFolder);
|
if (ProjectArchiver.existProjectInFolder(newProjectFolder,
|
||||||
Project projectSession = new Project(projectFolder);
|
aslSession)) {
|
||||||
SessionUtil.setProjectSession(session, projectSession);
|
throw new StatAlgoImporterServiceException(
|
||||||
|
"Attention a project is present in this folder, use open or another folder!");
|
||||||
|
} else {
|
||||||
|
ProjectFolder projectFolder = new ProjectFolder(
|
||||||
|
newProjectFolder);
|
||||||
|
Project projectSession = new Project(projectFolder);
|
||||||
|
SessionUtil.setProjectSession(session, projectSession);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} catch (StatAlgoImporterServiceException e) {
|
} catch (StatAlgoImporterServiceException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -316,7 +323,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteResourceOnProject(ItemDescription itemDescription)
|
public Project deleteResourceOnProject(ItemDescription itemDescription)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
@ -330,14 +337,27 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
Project project = SessionUtil.getProjectSession(session);
|
Project project = SessionUtil.getProjectSession(session);
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
FilesStorage fileStorage = new FilesStorage();
|
if (project.getMainCode() != null
|
||||||
fileStorage.deleteItemOnFolder(aslSession.getUsername(),
|
&& project.getMainCode().getItemDescription() != null
|
||||||
itemDescription.getId());
|
&& project.getMainCode().getItemDescription().getId()
|
||||||
|
.compareTo(itemDescription.getId()) == 0) {
|
||||||
|
project.setMainCode(null);
|
||||||
|
project.setInputData(null);
|
||||||
|
project.setProjectTarget(null);
|
||||||
|
FilesStorage fileStorage = new FilesStorage();
|
||||||
|
fileStorage.deleteItemOnFolder(aslSession.getUsername(),
|
||||||
|
itemDescription.getId());
|
||||||
|
SessionUtil.setProjectSession(session, project);
|
||||||
|
} else {
|
||||||
|
FilesStorage fileStorage = new FilesStorage();
|
||||||
|
fileStorage.deleteItemOnFolder(aslSession.getUsername(),
|
||||||
|
itemDescription.getId());
|
||||||
|
}
|
||||||
|
return project;
|
||||||
} else {
|
} else {
|
||||||
throw new StatAlgoImporterServiceException("No project open!");
|
throw new StatAlgoImporterServiceException("No project open!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
} catch (StatAlgoImporterServiceException e) {
|
} catch (StatAlgoImporterServiceException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -391,9 +411,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
throw new StatAlgoImporterServiceException(
|
throw new StatAlgoImporterServiceException(
|
||||||
"No main code set!");
|
"No main code set!");
|
||||||
} else {
|
} else {
|
||||||
FilesStorage filesStorage = new FilesStorage();
|
MainCodeSave mainCodeSave = new MainCodeSave();
|
||||||
filesStorage.saveItem(aslSession.getUsername(), mainCode
|
mainCodeSave.save(aslSession,
|
||||||
.getItemDescription().getId(), code);
|
mainCode.getItemDescription(), code, project);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StatAlgoImporterServiceException("No project open!");
|
throw new StatAlgoImporterServiceException("No project open!");
|
||||||
|
@ -423,7 +443,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
if (project != null && project.getProjectFolder() != null
|
if (project != null && project.getProjectFolder() != null
|
||||||
&& project.getProjectFolder().getItemDescription() != null) {
|
&& project.getProjectFolder().getItemDescription() != null) {
|
||||||
MainCodeSave mainCodeSave = new MainCodeSave();
|
MainCodeSave mainCodeSave = new MainCodeSave();
|
||||||
ItemDescription mainCodeItemDescription = mainCodeSave.save(
|
ItemDescription mainCodeItemDescription = mainCodeSave.saveNew(
|
||||||
aslSession, fileDescription, code, project);
|
aslSession, fileDescription, code, project);
|
||||||
MainCode mainCode = new MainCode(mainCodeItemDescription);
|
MainCode mainCode = new MainCode(mainCodeItemDescription);
|
||||||
project.setMainCode(mainCode);
|
project.setMainCode(mainCode);
|
||||||
|
@ -504,7 +524,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
logger.debug("PublishSoftware()");
|
logger.debug("PublishSoftware()");
|
||||||
ArrayList<Recipient> recipients=SessionUtil.getRecipients(session.getServletContext());
|
ArrayList<Recipient> recipients = SessionUtil.getRecipients(session
|
||||||
|
.getServletContext());
|
||||||
Project project = SessionUtil.getProjectSession(session);
|
Project project = SessionUtil.getProjectSession(session);
|
||||||
if (project != null && project.getProjectTarget() != null
|
if (project != null && project.getProjectTarget() != null
|
||||||
&& project.getProjectTarget().getTargetFolder() != null
|
&& project.getProjectTarget().getTargetFolder() != null
|
||||||
|
|
|
@ -397,6 +397,67 @@ public class FilesStorage {
|
||||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @param folderId
|
||||||
|
* @return
|
||||||
|
* @throws StatAlgoImporterServiceException
|
||||||
|
*/
|
||||||
|
public boolean existProjectItemOnWorkspace(String user,
|
||||||
|
String folderId) throws StatAlgoImporterServiceException {
|
||||||
|
Workspace ws;
|
||||||
|
try {
|
||||||
|
ws = HomeLibrary.getUserWorkspace(user);
|
||||||
|
|
||||||
|
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||||
|
if (!workSpaceItem.isFolder()) {
|
||||||
|
throw new StatAlgoImporterServiceException(
|
||||||
|
"Item is not valid folder!");
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceItem projectItem = ws.find(
|
||||||
|
STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
|
||||||
|
|
||||||
|
if (projectItem == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||||
|
| HomeNotFoundException | ItemNotFoundException
|
||||||
|
| WrongItemTypeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @param itemId
|
||||||
|
* @return
|
||||||
|
* @throws StatAlgoImporterServiceException
|
||||||
|
*/
|
||||||
|
public WorkspaceItem retrieveItemInfoOnWorkspace(String user, String itemId)
|
||||||
|
throws StatAlgoImporterServiceException {
|
||||||
|
Workspace ws;
|
||||||
|
try {
|
||||||
|
ws = HomeLibrary.getUserWorkspace(user);
|
||||||
|
|
||||||
|
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||||
|
return workSpaceItem;
|
||||||
|
|
||||||
|
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||||
|
| HomeNotFoundException | ItemNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,6 +31,21 @@ public class MainCodeSave {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param aslSession
|
||||||
|
* @param file
|
||||||
|
* @param code
|
||||||
|
* @param project
|
||||||
|
* @throws StatAlgoImporterServiceException
|
||||||
|
*/
|
||||||
|
public void save(ASLSession aslSession, ItemDescription file,
|
||||||
|
String code, Project project) throws StatAlgoImporterServiceException{
|
||||||
|
FilesStorage filesStorage = new FilesStorage();
|
||||||
|
filesStorage.saveItem(aslSession.getUsername(), file.getId(), code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param aslSession
|
* @param aslSession
|
||||||
|
@ -40,7 +55,7 @@ public class MainCodeSave {
|
||||||
* @return
|
* @return
|
||||||
* @throws StatAlgoImporterServiceException
|
* @throws StatAlgoImporterServiceException
|
||||||
*/
|
*/
|
||||||
public ItemDescription save(ASLSession aslSession, ItemDescription file,
|
public ItemDescription saveNew(ASLSession aslSession, ItemDescription file,
|
||||||
String code, Project project)
|
String code, Project project)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
Path tempFile = createTempFile(file, code);
|
Path tempFile = createTempFile(file, code);
|
||||||
|
@ -49,6 +64,7 @@ public class MainCodeSave {
|
||||||
return mainCode;
|
return mainCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Path createTempFile(ItemDescription file, String code)
|
private Path createTempFile(ItemDescription file, String code)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,12 +7,17 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectFolder;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.gargoylesoftware.htmlunit.javascript.host.Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Giancarlo Panichi email: <a
|
* @author Giancarlo Panichi email: <a
|
||||||
|
@ -41,6 +46,14 @@ public class ProjectArchiver {
|
||||||
.getItemDescription().getId());
|
.getItemDescription().getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean existProjectInFolder(ItemDescription newProjectFolder,
|
||||||
|
ASLSession aslSession) throws StatAlgoImporterServiceException {
|
||||||
|
FilesStorage filesStorage = new FilesStorage();
|
||||||
|
return filesStorage.existProjectItemOnWorkspace(aslSession.getUsername(), newProjectFolder.getId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Project readProject(ItemDescription newProjectFolder,
|
public static Project readProject(ItemDescription newProjectFolder,
|
||||||
ASLSession aslSession) throws StatAlgoImporterServiceException {
|
ASLSession aslSession) throws StatAlgoImporterServiceException {
|
||||||
|
@ -51,6 +64,30 @@ public class ProjectArchiver {
|
||||||
XMLDecoder xmlDecoder = new XMLDecoder(inputStream);
|
XMLDecoder xmlDecoder = new XMLDecoder(inputStream);
|
||||||
Project project = (Project) xmlDecoder.readObject();
|
Project project = (Project) xmlDecoder.readObject();
|
||||||
xmlDecoder.close();
|
xmlDecoder.close();
|
||||||
|
|
||||||
|
WorkspaceItem projectFolderItem=filesStorage.retrieveItemInfoOnWorkspace(aslSession.getUsername(), newProjectFolder.getId());
|
||||||
|
try {
|
||||||
|
newProjectFolder.setId(projectFolderItem.getId());
|
||||||
|
newProjectFolder.setName(projectFolderItem.getName());
|
||||||
|
newProjectFolder.setOwner(projectFolderItem.getOwner().getPortalLogin());
|
||||||
|
newProjectFolder.setPath(projectFolderItem.getPath());
|
||||||
|
newProjectFolder.setType(projectFolderItem.getType().name());
|
||||||
|
} catch (InternalErrorException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(project!=null && project.getProjectFolder()!=null &&
|
||||||
|
newProjectFolder.compareInfo(project.getProjectFolder().getItemDescription())){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
project.setProjectFolder(new ProjectFolder(newProjectFolder));
|
||||||
|
archive(project, aslSession);
|
||||||
|
}
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ public class ItemDescription implements Serializable {
|
||||||
private String path;
|
private String path;
|
||||||
private String type;
|
private String type;
|
||||||
private String publicLink;
|
private String publicLink;
|
||||||
|
|
||||||
public ItemDescription(){
|
public ItemDescription() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class ItemDescription implements Serializable {
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPublicLink() {
|
public String getPublicLink() {
|
||||||
return publicLink;
|
return publicLink;
|
||||||
}
|
}
|
||||||
|
@ -81,17 +81,31 @@ public class ItemDescription implements Serializable {
|
||||||
this.publicLink = publicLink;
|
this.publicLink = publicLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare basic information with another ItemDescription not null
|
||||||
|
*
|
||||||
|
* @param itemDescription
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean compareInfo(ItemDescription itemDescription){
|
||||||
|
if(itemDescription!=null && id.compareTo(itemDescription.getId())==0 &&
|
||||||
|
name.compareTo(itemDescription.getName())==0 &&
|
||||||
|
owner.compareTo(itemDescription.getOwner())==0 &&
|
||||||
|
path.compareTo(itemDescription.getPath())==0 &&
|
||||||
|
type.compareTo(itemDescription.getType())==0
|
||||||
|
){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ItemDescription [id=" + id + ", name=" + name + ", owner="
|
return "ItemDescription [id=" + id + ", name=" + name + ", owner="
|
||||||
+ owner + ", path=" + path + ", type=" + type + ", publicLink="
|
+ owner + ", path=" + path + ", type=" + type + ", publicLink="
|
||||||
+ publicLink + "]";
|
+ publicLink + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue