Skip to content

Commit

Permalink
Issue uPortal-Project#19 : Enhancement to upload an existing file
Browse files Browse the repository at this point in the history
This PR add the possibility to configure the portlet behaviour when
uploading an existing file by adding a portlet preference property. It's
a first step before developping an UI to let the choice of the user when
the problem appear. This PR is more a first step but let the possibility
to define a default behaviour for this problem, as the default
configuration override all existing files (expect in sardine
implementation).

So next steps are/could be :
- The method putFile for the cmisService must be modified to work
 with this enhancement.
- Give the possibility to a user to change his default behaviour by
  editing portlet preferences.
- wait or implements the UI evolution, referenced here :
  Valums-File-Uploader/file-uploader#40
  • Loading branch information
jgribonvald committed Feb 20, 2014
1 parent b33be54 commit d118b89
Show file tree
Hide file tree
Showing 14 changed files with 1,958 additions and 1,771 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,30 @@
public class SharedUserPortletParameters implements Serializable {

private static final long serialVersionUID = 1L;

protected List<String> driveNames;

protected Map userInfos;

protected CASReceipt receipt;

protected String username;

protected Map<String, UserPassword> userPassword4AuthenticatedFormDrives = new HashMap<String, UserPassword>();

protected boolean showHiddenFiles;

protected String clientIpAdress;


protected List<String> driveNames;

protected Map userInfos;

protected CASReceipt receipt;

protected String username;

protected Map<String, UserPassword> userPassword4AuthenticatedFormDrives = new HashMap<String, UserPassword>();

protected boolean showHiddenFiles;

protected UploadActionType uploadOption;

protected String clientIpAdress;

public SharedUserPortletParameters() {
}

public boolean isInitialized() {
return this.clientIpAdress != null;
}

public void init(String clientIpAdress) {
this.clientIpAdress = clientIpAdress;
}
Expand Down Expand Up @@ -107,8 +109,16 @@ public void setShowHiddenFiles(boolean showHiddenFiles) {
this.showHiddenFiles = showHiddenFiles;
}

public UploadActionType getUploadOption() {
return uploadOption;
}

public void setUploadOption(UploadActionType uploadOption) {
this.uploadOption = uploadOption;
}

public String getClientIpAdress() {
return clientIpAdress;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.portlet.filemanager.beans;

public enum UploadActionType {

/** To override the same filename. */
OVERRIDE(0),
/** To automatically rename the file uploaded. */
RENAME_NEW(1),
/** To rautomatically ename the file already on the server before upload. */
RENAME_OLD(2),
/** To throw an "existingFileException" and return success=false with a specific message and to manage in the UI with user action. */
ERROR(3);

/** Int value of the action type*/
private int code;

/**
* Contructor of the object UploadActionType.java.
* @param code an int
*/
private UploadActionType(final int code) {
this.code = code;
}

/**
* Contructor of the object UploadActionType.java.
* @param code a String
*/
private UploadActionType(final String code) {
this.code = Integer.parseInt(code);
}

/**
* Getter of member code.
* @return <code>int</code> the attribute code
*/
public int getCode() {
return code;
}

/**
* Setter of attribute code.
* @param code the attribute code to set
*/
public void setCode(final int code) {
this.code = code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.portlet.filemanager.exceptions;

public class EsupStockFileExistException extends EsupStockException {

private static final long serialVersionUID = 1709146807320625731L;

public EsupStockFileExistException() {
super("File already exist and overriding file is forbidden !");
}

}
Loading

0 comments on commit d118b89

Please sign in to comment.