Skip to content

Commit

Permalink
Cleanup, mostly formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBoon committed Feb 18, 2019
1 parent c79e748 commit 09ac883
Show file tree
Hide file tree
Showing 14 changed files with 601 additions and 659 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ michael-local
GPATH
GTAGS
GRTAGS
.idea
*.iml
# OS generated files #
######################
.DS_Store
Expand All @@ -32,7 +30,7 @@ scripts/installer/dvinstall/
oauth-credentials.md

/src/main/webapp/oauth2/newAccount.html
#scripts/api/setup-all.sh*
scripts/api/setup-all.sh*

# ctags generated tag file
tags
Expand Down
5 changes: 2 additions & 3 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ To configure Shibboleth see the :doc:`shibboleth` section and to configure OAuth

The ``authenticationproviderrow`` database table controls which "authentication providers" are available within Dataverse. Out of the box, a single row with an id of "builtin" will be present. For each user in Dataverse, the ``authenticateduserlookup`` table will have a value under ``authenticationproviderid`` that matches this id. For example, the default "dataverseAdmin" user will have the value "builtin" under ``authenticationproviderid``. Why is this important? Users are tied to a specific authentication provider but conversion mechanisms are available to switch a user from one authentication provider to the other. As explained in the :doc:`/user/account` section of the User Guide, a graphical workflow is provided for end users to convert from the "builtin" authentication provider to a remote provider. Conversion from a remote authentication provider to the builtin provider can be performed by a sysadmin with access to the "admin" API. See the :doc:`/api/native-api` section of the API Guide for how to list users and authentication providers as JSON.

Enabling a second authentication provider will result in the Log In page showing additional providers for your users to choose from. By default, the Log In page will show the "builtin" provider, but you can adjust this via the ``:DefaultAuthProvider`` configuration option.
Enabling a second authentication provider will result in the Log In page showing additional providers for your users to choose from. By default, the Log In page will show the "builtin" provider, but you can adjust this via the ``:DefaultAuthProvider`` configuration option.

"Remote only" mode should be considered experimental until https://github.com/IQSS/dataverse/issues/2974 is resolved. For now, "remote only" means:

- Shibboleth or OAuth has been enabled.
- ``:AllowSignUp`` is set to "false" per the :doc:`config` section to prevent users from creating local accounts via the web interface. Please note that local accounts can also be created via API, and the way to prevent this is to block the ``builtin-users`` endpoint or scramble (or remove) the ``BuiltinUsers.KEY`` database setting per the :doc:`config` section.
- ``:AllowSignUp`` is set to "false" per the :doc:`config` section to prevent users from creating local accounts via the web interface. Please note that local accounts can also be created via API, and the way to prevent this is to block the ``builtin-users`` endpoint or scramble (or remove) the ``BuiltinUsers.KEY`` database setting per the :doc:`config` section.
- The "builtin" authentication provider has been disabled. Note that disabling the builting auth provider means that the API endpoint for converting an account from a remote auth provider will not work. This is the main reason why https://github.com/IQSS/dataverse/issues/2974 is still open. Converting directly from one remote authentication provider to another (i.e. from GitHub to Google) is not supported. Conversion from remote is always to builtin. Then the user initiates a conversion from builtin to remote. Note that longer term, the plan is to permit multiple login options to the same Dataverse account per https://github.com/IQSS/dataverse/issues/3487 (so all this talk of conversion will be moot) but for now users can only use a single login option, as explained in the :doc:`/user/account` section of the User Guide. In short, "remote only" might work for you if you only plan to use a single remote authentication provider such that no conversion between remote authentication providers will be necessary.

File Storage: Local Filesystem vs. Swift vs. S3
Expand Down Expand Up @@ -1268,7 +1268,6 @@ This sets the base name (without dot and extension), if not set it defaults to '
``curl -X PUT -d domainstats http://localhost:8080/api/admin/settings/:PiwikAnalyticsTrackerFileName``



:FileFixityChecksumAlgorithm
++++++++++++++++++++++++++++

Expand Down
1 change: 0 additions & 1 deletion downloads/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ glassfish-4.1.zip
solr-7.3.0.tgz
weld-osgi-bundle-2.2.10.Final-glassfish4.jar
schemaSpy_5.0.0.jar
solr-4.6.0.tgz
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import javax.ejb.EJB;
import org.apache.commons.io.IOUtils;
Expand All @@ -30,11 +29,11 @@
*/
@WebServlet(name = "CustomizationFilesServlet", urlPatterns = {"/CustomizationFilesServlet"})
public class CustomizationFilesServlet extends HttpServlet {

@EJB
SettingsServiceBean settingsService;


/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
Expand All @@ -45,8 +44,8 @@ public class CustomizationFilesServlet extends HttpServlet {
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");

String customFileType = request.getParameter("customFileType");
String filePath = getFilePath(customFileType);
Expand All @@ -64,7 +63,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re

StringBuilder responseData = new StringBuilder();
try (PrintWriter out = response.getWriter()) {

while ((line = in.readLine()) != null) {
responseData.append(line);
out.println(line);
Expand All @@ -90,37 +89,37 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
}

}

private String getFilePath(String fileTypeParam){

String nonNullDefaultIfKeyNotFound = "";

if (fileTypeParam.equals(CustomizationConstants.fileTypeHomePage)) {

// Homepage
return settingsService.getValueForKey(SettingsServiceBean.Key.HomePageCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeHeader)) {

// Header
return settingsService.getValueForKey(SettingsServiceBean.Key.HeaderCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeFooter)) {

// Footer
return settingsService.getValueForKey(SettingsServiceBean.Key.FooterCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeStyle)) {

// Style (css)
return settingsService.getValueForKey(SettingsServiceBean.Key.StyleCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeLogo)) {

// Logo for installation - appears in header
return settingsService.getValueForKey(SettingsServiceBean.Key.LogoCustomizationFile, nonNullDefaultIfKeyNotFound);
}


return "";
}
Expand All @@ -136,7 +135,7 @@ private String getFilePath(String fileTypeParam){
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
throws ServletException, IOException {
processRequest(request, response);
}

Expand All @@ -150,7 +149,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
throws ServletException, IOException {
processRequest(request, response);
}

Expand Down
21 changes: 10 additions & 11 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public enum DisplayMode {
@Inject
ThumbnailServiceWrapper thumbnailServiceWrapper;
@Inject
SettingsWrapper settingsWrapper;
SettingsWrapper settingsWrapper;
@Inject
ProvPopupFragmentBean provPopupFragmentBean;

Expand Down Expand Up @@ -1202,7 +1202,7 @@ private void updateDatasetFieldInputLevels() {
Format: { DatasetFieldType.id : DatasetField }
--------------------------------------------------------- */
// Initialize Map
Map<Long, DatasetField> mapDatasetFields = new HashMap<>();
Map<Long, DatasetField> mapDatasetFields = new HashMap<>();

// Populate Map
for (DatasetField dsf : workingVersion.getFlatDatasetFields()) {
Expand Down Expand Up @@ -1560,8 +1560,7 @@ private String init(boolean initFull) {
try {
privateUrl = commandEngine.submit(new GetPrivateUrlCommand(dvRequestService.getDataverseRequest(), dataset));
if (privateUrl != null) {
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.privateurl.infoMessageAuthor", Arrays
.asList(getPrivateUrlLink(privateUrl))));
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.privateurl.infoMessageAuthor", Arrays.asList(getPrivateUrlLink(privateUrl))));
}
} catch (CommandException ex) {
// No big deal. The user simply doesn't have access to create or delete a Private URL.
Expand Down Expand Up @@ -1781,7 +1780,7 @@ private void resetVersionUI() {
if (subField.getDatasetFieldType().getName().equals(DatasetFieldConstant.authorIdValue)) {
subField.getDatasetFieldValues().get(0).setValue(creatorOrcidId);
}
if (subField.getDatasetFieldType().getName().equals(DatasetFieldConstant.authorIdType)) {
if (subField.getDatasetFieldType().getName().equals(DatasetFieldConstant.authorIdType)) {
DatasetFieldType authorIdTypeDatasetField = fieldService.findByName(DatasetFieldConstant.authorIdType);
subField.setSingleControlledVocabularyValue(fieldService.findControlledVocabularyValueByDatasetFieldTypeAndStrValue(authorIdTypeDatasetField, "ORCID", true));
}
Expand Down Expand Up @@ -2071,7 +2070,7 @@ private String releaseDataset(boolean minor) {
new PublishDatasetCommand(dataset, dvRequestService.getDataverseRequest(), minor)
);
dataset = result.getDataset();
// Sucessfully executing PublishDatasetCommand does not guarantee that the dataset
// Sucessfully executing PublishDatasetCommand does not guarantee that the dataset
// has been published. If a publishing workflow is configured, this may have sent the
// dataset into a workflow limbo, potentially waiting for a third party system to complete
// the process. So it may be premature to show the "success" message at this point.
Expand Down Expand Up @@ -2714,7 +2713,7 @@ public String save() {
if (editMode == EditMode.CREATE) {
if ( selectedTemplate != null ) {
if ( isSessionUserAuthenticated() ) {
cmd = new CreateNewDatasetCommand(dataset, dvRequestService.getDataverseRequest(), false, selectedTemplate);
cmd = new CreateNewDatasetCommand(dataset, dvRequestService.getDataverseRequest(), false, selectedTemplate);
} else {
JH.addMessage(FacesMessage.SEVERITY_FATAL, BundleUtil.getStringFromBundle("dataset.create.authenticatedUsersOnly"));
return null;
Expand Down Expand Up @@ -2965,7 +2964,7 @@ public boolean isLockedInProgress() {

public boolean isDatasetLockedInWorkflow() {
return (dataset != null)
? dataset.isLockedFor(DatasetLock.Reason.Workflow)
? dataset.isLockedFor(DatasetLock.Reason.Workflow)
: false;
}

Expand Down Expand Up @@ -3464,7 +3463,7 @@ public boolean isDesignatedDatasetThumbnail (FileMetadata fileMetadata) {
* Items for the "Designated this image as the Dataset thumbnail:
*/

private FileMetadata fileMetadataSelectedForThumbnailPopup = null;
private FileMetadata fileMetadataSelectedForThumbnailPopup = null;

public void setFileMetadataSelectedForThumbnailPopup(FileMetadata fm){
fileMetadataSelectedForThumbnailPopup = fm;
Expand Down Expand Up @@ -3538,7 +3537,7 @@ public void saveAsDesignatedThumbnail() {
* Items for the "Tags (Categories)" popup.
*
*/
private FileMetadata fileMetadataSelectedForTagsPopup = null;
private FileMetadata fileMetadataSelectedForTagsPopup = null;

public void setFileMetadataSelectedForTagsPopup(){

Expand Down Expand Up @@ -3849,7 +3848,7 @@ private void removeUnusedFileTagsFromDataset() {
* Items for the "Advanced (Ingest) Options" popup.
*
*/
private FileMetadata fileMetadataSelectedForIngestOptionsPopup = null;
private FileMetadata fileMetadataSelectedForIngestOptionsPopup = null;

public void setFileMetadataSelectedForIngestOptionsPopup(FileMetadata fm){
fileMetadataSelectedForIngestOptionsPopup = fm;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/LoginPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void init() {
authProvider = authSvc.getAuthenticationProvider(systemConfig.getDefaultAuthProvider());
random = new Random();
}

public List<AuthenticationProviderDisplayInfo> listCredentialsAuthenticationProviders() {
List<AuthenticationProviderDisplayInfo> infos = new LinkedList<>();
for ( String id : authSvc.getAuthenticationProviderIdsOfType( CredentialsAuthenticationProvider.class ) ) {
Expand Down
79 changes: 36 additions & 43 deletions src/main/java/edu/harvard/iq/dataverse/api/BatchServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
@Stateless
public class BatchServiceBean {
private static final Logger logger = Logger.getLogger(BatchServiceBean.class.getCanonicalName());
private static final Logger logger = Logger.getLogger(BatchServiceBean.class.getCanonicalName());

@EJB
DataverseServiceBean dataverseService;
Expand All @@ -41,43 +41,40 @@ public void processFilePath(String fileDir, String parentIdtf, DataverseRequest
PrintWriter validationLog = null;
PrintWriter cleanupLog = null;
try {
JsonArrayBuilder status = Json.createArrayBuilder();
Date timestamp = new Date();

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
JsonArrayBuilder status = Json.createArrayBuilder();
Date timestamp = new Date();

validationLog = new PrintWriter(new FileWriter( "../logs/validationLog"+ formatter.format(timestamp)+".txt"));
cleanupLog = new PrintWriter(new FileWriter( "../logs/cleanupLog"+ formatter.format(timestamp)+".txt"));
File dir = new File(fileDir);
if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
if (null != file) {
if (!file.isHidden()) {
if (file.isDirectory()) {
try {
status.add(handleDirectory(dataverseRequest, file, importType, validationLog,
cleanupLog, createDV));
} catch (ImportException e) {
logger.log(Level.SEVERE, "Exception in handleDirectory() for " + file.getName(), e);
}
} else {
try {
status.add(importService.handleFile(dataverseRequest, owner, file, importType,
validationLog, cleanupLog));
} catch (ImportException e) {
logger.log(Level.SEVERE, "Exception in handleFile() for " + file.getName(), e);
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");

}
validationLog = new PrintWriter(new FileWriter( "../logs/validationLog"+ formatter.format(timestamp)+".txt"));
cleanupLog = new PrintWriter(new FileWriter( "../logs/cleanupLog"+ formatter.format(timestamp)+".txt"));
File dir = new File(fileDir);
if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
if (!file.isHidden()) {
if (file.isDirectory()) {
try {
status.add(handleDirectory(dataverseRequest, file, importType, validationLog, cleanupLog, createDV));
} catch (ImportException e) {
logger.log(Level.SEVERE, "Exception in handleDirectory() for "+ file.getName(),e);
}
} else {
try {
status.add(importService.handleFile(dataverseRequest, owner, file, importType, validationLog, cleanupLog));
} catch(ImportException e) {
logger.log(Level.SEVERE, "Exception in handleFile() for "+ file.getName(),e);
}

}
}
} else {
status.add(importService.handleFile(dataverseRequest, owner, dir, importType, validationLog, cleanupLog));

}
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception in processFilePath()", e);
} else {
status.add(importService.handleFile(dataverseRequest, owner, dir, importType, validationLog, cleanupLog));

}
}
catch(Exception e) {
logger.log(Level.SEVERE, "Exception in processFilePath()", e);
} finally {
validationLog.close();
cleanupLog.close();
Expand All @@ -98,20 +95,16 @@ public JsonArrayBuilder handleDirectory(DataverseRequest dataverseRequest, File
}
}
for (File file : dir.listFiles()) {
if (null != file) {
if (!file.isHidden()) {
try {
JsonObjectBuilder fileStatus = importService.handleFile(dataverseRequest, owner, file,
importType, validationLog, cleanupLog);
status.add(fileStatus);
} catch (ImportException | IOException e) {
status.add(Json.createObjectBuilder().add("importStatus",
"Exception importing " + file.getName() + ", message = " + e.getMessage()));
}
if (!file.isHidden()) {
try {
JsonObjectBuilder fileStatus = importService.handleFile(dataverseRequest, owner, file, importType, validationLog, cleanupLog);
status.add(fileStatus);
} catch (ImportException | IOException e) {
status.add(Json.createObjectBuilder().add("importStatus", "Exception importing " + file.getName() + ", message = " + e.getMessage()));
}
}
}
return status;
}

}
}
Loading

0 comments on commit 09ac883

Please sign in to comment.