From cd0374115ebeafb7b6417019638ca47aa6b0fa53 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 21 Jul 2017 17:55:05 +0100 Subject: [PATCH 01/90] Page speed improvements --- webapp/src/main/webapp/WEB-INF/web.xml | 22 ++++++++++++++++++++++ webapp/src/main/webapp/css/browseIndex.css | 3 --- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml index d4987ed81..ea06a7d8a 100644 --- a/webapp/src/main/webapp/WEB-INF/web.xml +++ b/webapp/src/main/webapp/WEB-INF/web.xml @@ -154,6 +154,28 @@ REQUEST + + ExpiresFilter + org.apache.catalina.filters.ExpiresFilter + + ExpiresByType image + access plus 10 minutes + + + ExpiresByType text/css + access plus 10 minutes + + + ExpiresByType application/javascript + access plus 10 minutes + + + + ExpiresFilter + /* + REQUEST + + ${stylesheets.add('')} <#-- ${scripts.add("")} --> - ${headScripts.add('')} + ${scripts.add('')} <#-- --> From 47f3f304cbf97bf232723fcae31d98045e2e432d Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 25 Aug 2017 08:51:10 +0100 Subject: [PATCH 07/90] [VIVO-1375] Upgrade to Servlet 3.0 spec --- api/pom.xml | 4 +- .../vedit/controller/EditFrontController.java | 3 + .../vedit/controller/OperationController.java | 2 + .../DashboardPropertyListController.java | 2 + .../IndividualListRdfController.java | 2 + .../webapp/controller/MailUsersServlet.java | 2 + .../controller/MultipartRequestWrapper.java | 2 +- .../webapp/controller/OntologyController.java | 2 + .../controller/SparqlQueryBuilderServlet.java | 2 + .../admin/UserAccountsAdminController.java | 3 + .../ajax/UserAccountsAjaxController.java | 2 + .../ManageProxiesController.java | 3 + .../ajax/ManageProxiesAjaxController.java | 2 + .../user/UserAccountsUserController.java | 2 + .../admin/RestrictLoginsController.java | 3 + .../controller/admin/ShowAuthController.java | 2 + .../ShowBackgroundThreadsController.java | 3 + .../controller/admin/ShowConfiguration.java | 3 + .../admin/ShowSourcesController.java | 3 + .../admin/SparqlQueryController.java | 2 + .../admin/StartupStatusController.java | 3 + .../WaitForBackgroundThreadsController.java | 2 + .../ajax/SparqlQueryAjaxController.java | 2 + .../api/SparqlQueryApiController.java | 2 + .../api/SparqlUpdateApiController.java | 2 + .../authenticate/AdminLoginController.java | 3 + .../authenticate/LoginExternalAuthReturn.java | 2 + .../authenticate/LoginExternalAuthSetup.java | 2 + .../controller/authenticate/ProgramLogin.java | 2 + .../dumprestore/DumpRestoreController.java | 2 + .../webapp/controller/edit/Authenticate.java | 2 + .../Classes2ClassesOperationController.java | 2 + .../edit/DatapropEditController.java | 2 + .../edit/DatatypeRetryController.java | 2 + .../controller/edit/DeletePageController.java | 2 + .../controller/edit/EntityEditController.java | 2 + .../edit/EntityRetryController.java | 2 + .../IndividualTypeOperationController.java | 2 + .../vitro/webapp/controller/edit/Logout.java | 2 + .../controller/edit/MenuManagementEdit.java | 2 + .../NamespacePrefixOperationController.java | 2 + .../edit/OntologyEditController.java | 2 + .../controller/edit/PrimitiveDelete.java | 2 + .../controller/edit/PrimitiveRdfEdit.java | 2 + ...perties2PropertiesOperationController.java | 2 + .../edit/PropertyEditController.java | 2 + .../edit/RefactorOperationController.java | 2 + .../controller/edit/ReorderController.java | 2 + .../edit/RestrictionOperationController.java | 2 + .../controller/edit/VclassEditController.java | 2 + .../edit/VclassRetryController.java | 2 + ...ataPropertyStatementListingController.java | 2 + .../listing/IndividualsListingController.java | 2 + ...ectPropertyStatementListingController.java | 2 + .../listing/OntologiesListingController.java | 2 + .../jena/NamespacesListingController.java | 2 + .../jena/RestrictionsListingController.java | 2 + .../freemarker/AboutController.java | 3 + .../freemarker/BaseSiteAdminController.java | 95 +- .../freemarker/BrowseController.java | 3 + .../freemarker/ContactFormController.java | 3 + .../freemarker/ContactMailController.java | 2 + .../freemarker/DeletePropertyController.java | 2 + .../freemarker/HomePageController.java | 3 + .../freemarker/ImageUploadController.java | 2 + .../freemarker/IndividualListController.java | 3 + .../freemarker/ListClassGroupsController.java | 3 + .../ListDatatypePropertiesController.java | 3 + .../ListFauxPropertiesController.java | 3 + .../ListPropertyGroupsController.java | 3 + .../ListPropertyWebappsController.java | 3 + .../ListVClassWebappsController.java | 3 + .../controller/freemarker/PageController.java | 2 + .../freemarker/RevisionInfoController.java | 3 + .../freemarker/SamplesController.java | 3 + .../ShowClassHierarchyController.java | 3 + .../ShowDataPropertyHierarchyController.java | 3 + ...ShowObjectPropertyHierarchyController.java | 3 + .../SimpleReasonerRecomputeController.java | 3 + .../freemarker/SiteAdminController.java | 3 + .../freemarker/StaticPageController.java | 3 + .../freemarker/TermsOfUseController.java | 3 + .../controller/freemarker/TestController.java | 7 + .../freemarker/ViewLabelsServlet.java | 2 + .../grefine/GrefineMqlreadServlet.java | 2 + .../grefine/GrefinePropertyListServlet.java | 2 + .../grefine/JSONReconcileServlet.java | 2 + .../individual/IndividualController.java | 2 + .../controller/jena/JenaAdminActions.java | 2 + .../jena/JenaCsv2RdfController.java | 2 + .../controller/jena/JenaExportController.java | 2 + .../controller/jena/JenaIngestController.java | 2 + .../controller/jena/JenaXMLFileUpload.java | 4 +- .../controller/jena/RDFUploadController.java | 2 + .../jena/RDFUploadFormController.java | 2 + .../webapp/controller/json/JsonServlet.java | 2 + .../controller/EditRequestAJAXController.java | 2 + .../EditRequestDispatchController.java | 2 + .../controller/PostEditCleanupController.java | 2 + .../controller/ProcessRdfFormController.java | 3 + .../serving/FileServingServlet.java | 2 + .../webapp/filters/CachingResponseFilter.java | 2 + .../webapp/filters/CharsetEncodingFilter.java | 2 + .../vitro/webapp/filters/ClickjackFilter.java | 3 + .../webapp/filters/JSessionStripFilter.java | 2 + .../webapp/filters/PageRoutingFilter.java | 3 + .../webapp/filters/RequestModelsPrep.java | 3 + .../filters/SessionTimeoutLimitingFilter.java | 2 + .../filters/StartupStatusDisplayFilter.java | 2 + .../webapp/filters/URLRewriterFilter.java | 2 + .../selection/LocaleSelectionController.java | 2 + .../i18n/selection/LocaleSelectionFilter.java | 2 + .../controller/AutocompleteController.java | 2 + .../DataAutocompleteController.java | 2 + .../search/controller/IndexController.java | 2 + .../controller/PagedSearchController.java | 2 + .../controller/SearchHelpController.java | 2 + .../controller/SearchServiceController.java | 2 + .../vitro/webapp/sparql/GetAllClasses.java | 2 + .../vitro/webapp/sparql/GetAllPrefix.java | 2 + .../webapp/sparql/GetClazzAllProperties.java | 2 + .../webapp/sparql/GetClazzDataProperties.java | 2 + .../sparql/GetClazzObjectProperties.java | 2 + .../vitro/webapp/sparql/GetObjectClasses.java | 2 + .../vitro/webapp/utils/JSPPageHandler.java | 11 + .../developer/DeveloperSettingsServlet.java | 2 + .../vitro/opensocial/GadgetController.java | 3 + .../VitroLinkedDataFragmentServlet.java | 2 + .../javax/servlet/ServletContextStub.java | 142 ++ .../servlet/http/HttpServletRequestStub.java | 85 ++ .../servlet/http/HttpServletResponseStub.java | 27 + webapp/src/main/webapp/WEB-INF/web.xml | 1169 +---------------- 132 files changed, 629 insertions(+), 1195 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 7917eba4e..f44774ea8 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -44,8 +44,8 @@ javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 provided diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/controller/EditFrontController.java b/api/src/main/java/edu/cornell/mannlib/vedit/controller/EditFrontController.java index 07e8ee09f..98e0e03c0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/controller/EditFrontController.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/controller/EditFrontController.java @@ -3,6 +3,8 @@ package edu.cornell.mannlib.vedit.controller; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; + +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -21,6 +23,7 @@ import java.io.IOException; * @author bjl23 * */ +@WebServlet(name = "EditFrontController", urlPatterns = {"/editForm"} ) public class EditFrontController extends VitroHttpServlet { private static final Log log = LogFactory.getLog(EditFrontController.class.getName()); private static final String CONTROLLER_PKG = "edu.cornell.mannlib.vitro.webapp.controller.edit"; diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java b/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java index e688e4661..6547be004 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java @@ -11,6 +11,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -27,6 +28,7 @@ import edu.cornell.mannlib.vedit.util.OperationUtils; import edu.cornell.mannlib.vedit.validator.ValidationObject; import edu.cornell.mannlib.vedit.validator.Validator; +@WebServlet(name = "OperationController", urlPatterns = {"/doEdit"} ) public class OperationController extends BaseEditController { private static final Log log = LogFactory.getLog(OperationController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/DashboardPropertyListController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/DashboardPropertyListController.java index e2fe2df68..274bec982 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/DashboardPropertyListController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/DashboardPropertyListController.java @@ -11,6 +11,7 @@ import java.util.List; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; * @author bdc34 * */ +@WebServlet(name = "DashboardPropertyListController", urlPatterns = {"/dashboardPropList"} ) public class DashboardPropertyListController extends VitroHttpServlet { /** diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/IndividualListRdfController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/IndividualListRdfController.java index 6d1124394..06ce8c50e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/IndividualListRdfController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/IndividualListRdfController.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.util.Collection; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,6 +38,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; import edu.cornell.mannlib.vitro.webapp.utils.http.AcceptHeaderParsingException; import edu.cornell.mannlib.vitro.webapp.utils.http.NotAcceptableException; +@WebServlet(name = "IndividualListRdf", urlPatterns = {"/listrdf/*"} ) public class IndividualListRdfController extends VitroApiServlet { private static final Log log = LogFactory .getLog(IndividualListRdfController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java index f01aea93c..612dc6203 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java @@ -17,6 +17,7 @@ import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao; import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory; +@WebServlet(name = "mailusers", urlPatterns = {"/mailusers"}, loadOnStartup = 5) public class MailUsersServlet extends VitroHttpServlet { private static final Log log = LogFactory.getLog(MailUsersServlet.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MultipartRequestWrapper.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MultipartRequestWrapper.java index f64ceccc6..2e3773b22 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MultipartRequestWrapper.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MultipartRequestWrapper.java @@ -233,7 +233,7 @@ public class MultipartRequestWrapper extends HttpServletRequestWrapper { * Look in the map of parsed parameters. Make a protective copy. */ @Override - public Enumeration getParameterNames() { + public Enumeration getParameterNames() { return Collections.enumeration(new HashSet<>(parameters.keySet())); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java index 5f93836f9..ce3cd1c64 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java @@ -8,6 +8,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils; import edu.cornell.mannlib.vitro.webapp.web.ContentType; +@WebServlet(name = "ontology", urlPatterns = {"/ontology/*"}) public class OntologyController extends VitroHttpServlet{ private static final Log log = LogFactory.getLog(OntologyController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java index 412355438..acf738b3d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java @@ -7,6 +7,7 @@ import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -25,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; * This servlet works as a RequestDispatcher to direct to the sparl query builder page. * @author yuysun */ +@WebServlet(name = "SparlQueryBuilder", urlPatterns = {"/admin/sparqlquerybuilder"}) public class SparqlQueryBuilderServlet extends BaseEditController { private static final Log log = LogFactory.getLog(SparqlQueryBuilderServlet.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAdminController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAdminController.java index bcf5d3a5f..0b850b590 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAdminController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAdminController.java @@ -15,10 +15,13 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; +import javax.servlet.annotation.WebServlet; + /** * Parcel out the different actions required of the Administrators portion of * the UserAccounts GUI. */ +@WebServlet(name = "AccountsAdmin", urlPatterns = {"/accountsAdmin/*"} ) public class UserAccountsAdminController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(UserAccountsAdminController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/ajax/UserAccountsAjaxController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/ajax/UserAccountsAjaxController.java index 8b6894747..d671962fc 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/ajax/UserAccountsAjaxController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/ajax/UserAccountsAjaxController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts.admin.ajax; import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -18,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController; /** * Handle the AJAX functions that are specific to the UserAccounts pages. */ +@WebServlet(name = "AccountsAjax", urlPatterns = {"/accountsAjax/*"} ) public class UserAccountsAjaxController extends VitroAjaxController { private static final Log log = LogFactory .getLog(UserAccountsAjaxController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesController.java index 3074b33f7..bfd135034 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesController.java @@ -15,9 +15,12 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; +import javax.servlet.annotation.WebServlet; + /** * Parcel out the different actions required of the ManageProxies GUI. */ +@WebServlet(name = "ManageProxies", urlPatterns = {"/manageProxies/*"} ) public class ManageProxiesController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(ManageProxiesController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ajax/ManageProxiesAjaxController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ajax/ManageProxiesAjaxController.java index c1e936419..97d2e1ce2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ajax/ManageProxiesAjaxController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ajax/ManageProxiesAjaxController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ajax; import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -18,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController; /** * Handle the AJAX functions that are specific to the ManageProxies pages. */ +@WebServlet(name = "ProxiesAjax", urlPatterns = {"/proxiesAjax/*"} ) public class ManageProxiesAjaxController extends VitroAjaxController { private static final Log log = LogFactory .getLog(ManageProxiesAjaxController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java index de90d217d..0fa6d4903 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts.user; import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource.EXTERNAL; import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest.AUTHORIZED; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; @@ -26,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.i18n.I18n; /** * Parcel out the different actions required of the UserAccounts GUI. */ +@WebServlet(name = "AccountsUser", urlPatterns = {"/accounts/*"} ) public class UserAccountsUserController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(UserAccountsUserController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/RestrictLoginsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/RestrictLoginsController.java index 86ba316db..88a437dd2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/RestrictLoginsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/RestrictLoginsController.java @@ -18,10 +18,13 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.i18n.I18n; +import javax.servlet.annotation.WebServlet; + /** * Offer the user the ability to apply a RestrictedAuthenticator or revert to a * BasicAuthenticator. */ +@WebServlet(name = "RestrictLogins", urlPatterns = {"/admin/restrictLogins"} ) public class RestrictLoginsController extends FreemarkerHttpServlet { public static final String PARAMETER_RESTRICT = "restrict"; public static final String PARAMETER_OPEN = "open"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowAuthController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowAuthController.java index 7d8f5274e..b3ee6af2d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowAuthController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowAuthController.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.TreeMap; import javax.servlet.ServletContext; +import javax.servlet.annotation.WebServlet; import edu.cornell.mannlib.vedit.beans.LoginStatusBean; import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories; @@ -36,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem * Show a summary of who is logged in and how they are to be treated by the * authorization system. */ +@WebServlet(name = "ShowAuth", urlPatterns = {"/admin/showAuth"} ) public class ShowAuthController extends FreemarkerHttpServlet { @Override diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java index 7f6780e78..dcd7b5487 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java @@ -17,10 +17,13 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread; +import javax.servlet.annotation.WebServlet; + /** * Show the list of living background threads (instances of * VitroBackgroundThread), and their status. */ +@WebServlet(name = "ShowBackgroundThreads", urlPatterns = {"/admin/showThreads"} ) public class ShowBackgroundThreadsController extends FreemarkerHttpServlet { private static final String TEMPLATE_NAME = "admin-showThreads.ftl"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java index b496384a8..e345445ac 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java @@ -16,9 +16,12 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + /** * Show the current ConfigurationProperties and the Java system properties. */ +@WebServlet(name = "ShowConfiguration", urlPatterns = {"/admin/showConfiguration"} ) public class ShowConfiguration extends FreemarkerHttpServlet { @Override protected AuthorizationRequest requiredActions(VitroRequest vreq) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowSourcesController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowSourcesController.java index 5df2d68bb..c04199160 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowSourcesController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowSourcesController.java @@ -34,6 +34,8 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.RequestModelAccess; import edu.cornell.mannlib.vitro.webapp.utils.logging.ComplexStringFormatter; import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString; +import javax.servlet.annotation.WebServlet; + /** * Show the details of where our RDF data is coming from. What are the * structures that supply the triples? @@ -103,6 +105,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString; * At the same time, write these to the log as INFO messages, without the fancy formatting. * */ +@WebServlet(name = "ShowRDFSources", urlPatterns = {"/admin/showSources"} ) public class ShowSourcesController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(ShowSourcesController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/SparqlQueryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/SparqlQueryController.java index 5879fcb55..df1fb7440 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/SparqlQueryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/SparqlQueryController.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -43,6 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.sparql.SparqlQueryUtils; /** * Present the SPARQL Query form, and execute the queries. */ +@WebServlet(name = "SparqlQuery", urlPatterns = {"/admin/sparqlquery"}) public class SparqlQueryController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(SparqlQueryController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java index 388a76215..2a755d1d3 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java @@ -14,9 +14,12 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem import edu.cornell.mannlib.vitro.webapp.i18n.I18n; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; +import javax.servlet.annotation.WebServlet; + /** * Display the startup status page. */ +@WebServlet(name = "StartupStatus", urlPatterns = {"/startupStatus"} ) public class StartupStatusController extends FreemarkerHttpServlet { @Override diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/WaitForBackgroundThreadsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/WaitForBackgroundThreadsController.java index 585f31d94..69ea5ed4d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/WaitForBackgroundThreadsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/admin/WaitForBackgroundThreadsController.java @@ -14,6 +14,7 @@ import java.util.Enumeration; import java.util.List; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -41,6 +42,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.Work * * Otherwise, the result will be 200 (OK), with a brief message. */ +@WebServlet(name = "WaitForBackgroundThreads", urlPatterns = {"/admin/wait"} ) public class WaitForBackgroundThreadsController extends VitroHttpServlet { private static final Log log = LogFactory .getLog(WaitForBackgroundThreadsController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java index b13c4b4a2..03fbc4f5a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java @@ -8,6 +8,7 @@ import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -29,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; * * The result is delivered in JSON format. */ +@WebServlet(name = "ajaxSparqlQuery", urlPatterns = {"/ajax/sparqlQuery"} ) public class SparqlQueryAjaxController extends VitroAjaxController { private static final Log log = LogFactory .getLog(SparqlQueryAjaxController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlQueryApiController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlQueryApiController.java index dfe79d767..16e75d06b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlQueryApiController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlQueryApiController.java @@ -10,6 +10,7 @@ import static javax.servlet.http.HttpServletResponse.SC_NOT_ACCEPTABLE; import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -40,6 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.http.NotAcceptableException; * 500 Unknown error * */ +@WebServlet(name = "SparqlQueryApi", urlPatterns = {"/api/sparqlQuery"}) public class SparqlQueryApiController extends VitroApiServlet { private static final AuthorizationRequest REQUIRED_ACTIONS = SimplePermission.USE_SPARQL_QUERY_API.ACTION; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java index 08f83a2b6..682d73281 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java @@ -11,6 +11,7 @@ import java.io.IOException; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -48,6 +49,7 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer; * 500 Unknown error * */ +@WebServlet(name = "SparqlUpdateApi", urlPatterns = {"/api/sparqlUpdate"}) public class SparqlUpdateApiController extends VitroApiServlet { private static final Log log = LogFactory .getLog(SparqlUpdateApiController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/AdminLoginController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/AdminLoginController.java index 1b044a58a..d7efcd82a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/AdminLoginController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/AdminLoginController.java @@ -23,6 +23,8 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Red import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + /** * Provide a "hidden" login page for systems where the Login Widget has been * modified to only show the link to an External Authentication system. @@ -30,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem * This page is only hidden because there is no link to it. Anyone who knows the * URL can come here, but they need to pass Internal Authentication to proceed. */ +@WebServlet(name = "adminLogin", urlPatterns = {"/admin/login"}) public class AdminLoginController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(AdminLoginController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java index 56d1f965d..1db8c4c16 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.util.Enumeration; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.Messag * Handle the return from the external authorization login server. If we are * successful, record the login. Otherwise, display the failure. */ +@WebServlet(name = "loginExternalAuthReturn", urlPatterns = {"/loginExternalAuthReturn"}) public class LoginExternalAuthReturn extends BaseLoginServlet { private static final Log log = LogFactory .getLog(LoginExternalAuthReturn.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthSetup.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthSetup.java index e64980db7..5dbd4b069 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthSetup.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthSetup.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.Enumeration; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -22,6 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean; * Send a request to the external authorization server that will return us to * the LoginExternalAuthReturn servlet for further processing. */ +@WebServlet(name = "loginExternalAuthSetup", urlPatterns = {"/loginExternalAuth"}) public class LoginExternalAuthSetup extends BaseLoginServlet { private static final Log log = LogFactory .getLog(LoginExternalAuthSetup.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java index 664a7d557..1c775f1a0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -24,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator.Lo * Provide a means for programmatic login If they provide the right parameters, * log them in and send 200. Otherwise, send 403 error. */ +@WebServlet(name = "programLogin", urlPatterns = {"/programLogin"}) public class ProgramLogin extends HttpServlet { private static final Log log = LogFactory.getLog(ProgramLogin.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java index 3c2302266..45fabe992 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -35,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; * The first request, the selection and the redirected dump should all be GET * requests. A restore should be a POST request. */ +@WebServlet(name = "DumpRestoreController", urlPatterns = {"/dumpRestore/*"} ) public class DumpRestoreController extends FreemarkerHttpServlet { private static final RequestedAction REQUIRED_ACTION = SimplePermission.USE_ADVANCED_DATA_TOOLS_PAGES.ACTION; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java index c9e155466..da38df6a4 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java @@ -18,6 +18,7 @@ import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -42,6 +43,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginLogoutEvent; +@WebServlet(name = "authenticate", urlPatterns = {"/authenticate"}) public class Authenticate extends VitroHttpServlet { private static final Log log = LogFactory.getLog(Authenticate.class .getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java index 44f6cf343..7f8310d4e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import java.io.IOException; import java.util.HashMap; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -18,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Classes2Classes; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +@WebServlet(name = "Classes2ClassesOperationController", urlPatterns = {"/classes2ClassesOp"} ) public class Classes2ClassesOperationController extends BaseEditController { private static final Log log = LogFactory.getLog(Classes2ClassesOperationController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java index 6ee09beb5..4c300fb39 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatapropEditController.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -29,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +@WebServlet(name = "DatapropEditController", urlPatterns = {"/datapropEdit"} ) public class DatapropEditController extends BaseEditController { private static final Log log = LogFactory.getLog(DatapropEditController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatatypeRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatatypeRetryController.java index 22d711f61..54c99473e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatatypeRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DatatypeRetryController.java @@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import java.io.IOException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -22,6 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; +@WebServlet(name = "DatatypeRetryController", urlPatterns = {"/datatype_retry"} ) public class DatatypeRetryController extends BaseEditController { private static final Log log = LogFactory.getLog(DatatypeRetryController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java index e7d64d410..a557308af 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.StringWriter; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -31,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; /** *Process deletions for page, deleting page, data getters and any associated menu items. */ +@WebServlet(name = "DeletePageController", urlPatterns = {"/deletePageController"} ) public class DeletePageController extends VitroHttpServlet { private final static String REDIRECT_URL = "/pageList"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityEditController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityEditController.java index 9a3dfee95..6f39b35e1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityEditController.java @@ -10,6 +10,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -33,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; +@WebServlet(name = "EntityEditController", urlPatterns = {"/entityEdit"} ) public class EntityEditController extends BaseEditController { private static final Log log = LogFactory.getLog(EntityEditController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java index 211faeb5f..c3d1641ed 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/EntityRetryController.java @@ -14,6 +14,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -51,6 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.edit.listener.impl.IndividualDataPropertyStatementProcessor; +@WebServlet(name = "EntityRetryController", urlPatterns = {"/entity_retry"} ) public class EntityRetryController extends BaseEditController { private static final Log log = LogFactory.getLog(EntityRetryController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/IndividualTypeOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/IndividualTypeOperationController.java index 312e6ac25..2592969c7 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/IndividualTypeOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/IndividualTypeOperationController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import java.io.IOException; import java.util.HashMap; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -17,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; +@WebServlet(name = "IndividualTypeOperationController", urlPatterns = {"/individualTypeOp"} ) public class IndividualTypeOperationController extends BaseEditController { private static final Log log = LogFactory.getLog(IndividualTypeOperationController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Logout.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Logout.java index dc2dd3acf..faf883375 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Logout.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Logout.java @@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -17,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.i18n.I18n; /** * Provide a means for programmatic logout. */ +@WebServlet(name = "logout", urlPatterns = {"/logout"}) public class Logout extends HttpServlet { private static final Log log = LogFactory.getLog(Logout.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java index 53480cc0d..978f35f3c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java @@ -8,6 +8,7 @@ import java.io.StringWriter; import java.io.Writer; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -31,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; *Process edits from display model editing, so form should submit to this page which should *then process the parameters and then make the necessary changes to the model. */ +@WebServlet(name = "MenuManagementEdit", urlPatterns = {"/menuManagementEdit"} ) public class MenuManagementEdit extends VitroHttpServlet { private static final String CMD_PARAM = "cmd"; private final static String REORDER_PARAM_VALUE = "Reorder"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespacePrefixOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespacePrefixOperationController.java index 93a30468f..af5997efa 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespacePrefixOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespacePrefixOperationController.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.HashSet; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +@WebServlet(name = "NamespacePrefixOperationController", urlPatterns = {"/namespacePrefixOp"} ) public class NamespacePrefixOperationController extends BaseEditController { private static final Log log = LogFactory.getLog(IndividualTypeOperationController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java index de78b9097..8a588f391 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyEditController.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -25,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.jena.OntologyDaoJena; +@WebServlet(name = "OntologyEditController", urlPatterns = {"/ontologyEdit"} ) public class OntologyEditController extends BaseEditController { private static final Log log = LogFactory.getLog(OntologyEditController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveDelete.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveDelete.java index ada1dbe5e..aeea323ee 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveDelete.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveDelete.java @@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; @@ -18,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; +@WebServlet(name = "primitiveDelete", urlPatterns = {"/edit/primitiveDelete"}) public class PrimitiveDelete extends VitroAjaxController { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveRdfEdit.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveRdfEdit.java index ce4868322..1e4b4ee22 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveRdfEdit.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PrimitiveRdfEdit.java @@ -12,6 +12,7 @@ import java.util.HashSet; import java.util.Set; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector; +@WebServlet(name = "primitiveRdfEdit", urlPatterns = {"/edit/primitiveRdfEdit"}) public class PrimitiveRdfEdit extends VitroAjaxController { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java index 40e9c019f..166a89b4e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import java.io.IOException; import java.util.HashMap; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -17,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao; +@WebServlet(name = "Properties2PropertiesOperationController", urlPatterns = {"/props2PropsOp"} ) public class Properties2PropertiesOperationController extends BaseEditController { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java index fb10dd860..97620f9be 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyEditController.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +@WebServlet(name = "PropertyEditController", urlPatterns = {"/propertyEdit"} ) public class PropertyEditController extends BaseEditController { private static final Log log = LogFactory.getLog(PropertyEditController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java index 1db540d9c..c8b212faf 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java @@ -13,6 +13,7 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -57,6 +58,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup; +@WebServlet(name = "RefactorOperationController", urlPatterns = {"/refactorOp"} ) public class RefactorOperationController extends BaseEditController { private static final Log log = LogFactory.getLog(RefactorOperationController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/ReorderController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/ReorderController.java index c5a859193..550bb851a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/ReorderController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/ReorderController.java @@ -7,6 +7,7 @@ import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import static javax.servlet.http.HttpServletResponse.SC_OK; import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -42,6 +43,7 @@ import java.io.IOException; * @author rjy7 * */ +@WebServlet(name = "ReorderController", urlPatterns = {"/edit/reorder"} ) public class ReorderController extends VitroAjaxController { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java index d19d451cc..f9c51db71 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java @@ -7,6 +7,7 @@ import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSER import java.util.HashMap; import java.util.Iterator; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -33,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; +@WebServlet(name = "RestrictionOperationController", urlPatterns = {"/addRestriction"} ) public class RestrictionOperationController extends BaseEditController { private static final Log log = LogFactory.getLog(RestrictionOperationController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java index b5a6899a8..9e5c682be 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassEditController.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -31,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; +@WebServlet(name = "VclassEditController", urlPatterns = {"/vclassEdit"} ) public class VclassEditController extends BaseEditController { private static final Log log = LogFactory.getLog(VclassEditController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassRetryController.java index b037c35b3..5cc9ba747 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/VclassRetryController.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; +@WebServlet(name = "VclassRetryController", urlPatterns = {"/vclass_retry"} ) public class VclassRetryController extends BaseEditController { private static final Log log = LogFactory.getLog(VclassRetryController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/DataPropertyStatementListingController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/DataPropertyStatementListingController.java index 1738db01e..eef50a63b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/DataPropertyStatementListingController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/DataPropertyStatementListingController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit.listing; import java.util.ArrayList; import java.util.Iterator; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -20,6 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler; +@WebServlet(name = "DataPropertyStatementListingController", urlPatterns = {"/listDataPropertyStatements"} ) public class DataPropertyStatementListingController extends BaseEditController { public void doGet(HttpServletRequest request, HttpServletResponse response) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/IndividualsListingController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/IndividualsListingController.java index 7f8678653..fc94aee2a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/IndividualsListingController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/IndividualsListingController.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -23,6 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler; +@WebServlet(name = "IndividualsListingController", urlPatterns = {"/listIndividuals"} ) public class IndividualsListingController extends BaseEditController { //private static final int MAX_INDIVIDUALS = 50; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ObjectPropertyStatementListingController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ObjectPropertyStatementListingController.java index f8ff7189d..ba56b401c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ObjectPropertyStatementListingController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/ObjectPropertyStatementListingController.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -23,6 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler; +@WebServlet(name = "ObjectPropertyStatementListingController", urlPatterns = {"/listObjectPropertyStatements"} ) public class ObjectPropertyStatementListingController extends BaseEditController { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/OntologiesListingController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/OntologiesListingController.java index 4b5025f1b..522d2d6e1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/OntologiesListingController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/OntologiesListingController.java @@ -6,6 +6,7 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -17,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler; +@WebServlet(name = "OntologiesListingController", urlPatterns = {"/listOntologies"} ) public class OntologiesListingController extends BaseEditController { @Override diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/NamespacesListingController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/NamespacesListingController.java index 502df6c7a..c6a09d0d2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/NamespacesListingController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/NamespacesListingController.java @@ -6,6 +6,7 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.Iterator; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -25,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; +@WebServlet(name = "NamespacesListingController", urlPatterns = {"/listNamespaces"} ) public class NamespacesListingController extends BaseEditController { public void doGet(HttpServletRequest request, HttpServletResponse response) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/RestrictionsListingController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/RestrictionsListingController.java index 64e04b6fa..4072bd835 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/RestrictionsListingController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/jena/RestrictionsListingController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit.listing.jena; import java.util.ArrayList; import java.util.Iterator; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,6 +38,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; +@WebServlet(name = "RestrictionsListingController", urlPatterns = {"/listRestrictions"} ) public class RestrictionsListingController extends BaseEditController { private static String LAMBDA = ""; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java index 83c9d9150..545c62299 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java @@ -13,6 +13,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "AboutController", urlPatterns = {"/about"} ) public class AboutController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java index 998106d64..dacaa2a4b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java @@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -36,6 +37,46 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { protected static final String TEMPLATE_DEFAULT = "siteAdmin-main.ftl"; public static final AuthorizationRequest REQUIRED_ACTIONS = SimplePermission.SEE_SITE_ADMIN_PAGE.ACTION; + + private static final List siteMaintenanceUrls = new ArrayList<>(); + private static final List siteConfigData = new ArrayList<>(); + + public static void registerSiteMaintenanceUrl(String key, String url, AuthorizationRequest permission) { + AdminUrl adminUrl = new AdminUrl(); + + adminUrl.key = key; + adminUrl.url = url; + adminUrl.permission = permission; + + siteMaintenanceUrls.add(adminUrl); + } + + public static void registerSiteConfigData(String key, String url, AuthorizationRequest permission) { + AdminUrl adminUrl = new AdminUrl(); + + adminUrl.key = key; + adminUrl.url = url; + adminUrl.permission = permission; + + siteConfigData.add(adminUrl); + } + + static { + registerSiteMaintenanceUrl("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences"), SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION); + registerSiteMaintenanceUrl("rebuildSearchIndex", UrlBuilder.getUrl("/SearchIndex"), IndexController.REQUIRED_ACTIONS); + registerSiteMaintenanceUrl("startupStatus", UrlBuilder.getUrl("/startupStatus"), SimplePermission.SEE_STARTUP_STATUS.ACTION); + registerSiteMaintenanceUrl("restrictLogins", UrlBuilder.getUrl("/admin/restrictLogins"), SimplePermission.LOGIN_DURING_MAINTENANCE.ACTION); + registerSiteMaintenanceUrl("activateDeveloperPanel", "javascript:new DeveloperPanel(developerAjaxUrl).setupDeveloperPanel({developer_enabled: true});", SimplePermission.ENABLE_DEVELOPER_PANEL.ACTION); + + registerSiteConfigData("userAccounts", UrlBuilder.getUrl("/accountsAdmin"), SimplePermission.MANAGE_USER_ACCOUNTS.ACTION); + registerSiteConfigData("manageProxies", UrlBuilder.getUrl("/manageProxies"), SimplePermission.MANAGE_PROXIES.ACTION); + registerSiteConfigData("siteInfo", UrlBuilder.getUrl("/editForm", "controller", "ApplicationBean"), SimplePermission.EDIT_SITE_INFORMATION.ACTION); + //TODO: Add specific permissions for page management + registerSiteConfigData("menuManagement", UrlBuilder.getUrl("/individual", + "uri", "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#DefaultMenu", + "switchToDisplayModel", "true"), SimplePermission.MANAGE_MENUS.ACTION); + registerSiteConfigData("pageManagement", UrlBuilder.getUrl("/pageList"), SimplePermission.MANAGE_MENUS.ACTION); + } @Override protected AuthorizationRequest requiredActions(VitroRequest vreq) { @@ -65,27 +106,16 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { Map urls = new HashMap<>(); - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION)) { - urls.put("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences")); + for (AdminUrl adminUrl : siteMaintenanceUrls) { + if (adminUrl.permission == null || PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION)) { + urls.put(adminUrl.key, adminUrl.url); + } } - - if (PolicyHelper.isAuthorizedForActions(vreq, IndexController.REQUIRED_ACTIONS)) { - urls.put("rebuildSearchIndex", UrlBuilder.getUrl("/SearchIndex")); - } - + if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.SEE_STARTUP_STATUS.ACTION)) { - urls.put("startupStatus", UrlBuilder.getUrl("/startupStatus")); urls.put("startupStatusAlert", !StartupStatus.getBean(getServletContext()).allClear()); } - - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.LOGIN_DURING_MAINTENANCE.ACTION)) { - urls.put("restrictLogins", UrlBuilder.getUrl("/admin/restrictLogins")); - } - - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.ENABLE_DEVELOPER_PANEL.ACTION)) { - urls.put("activateDeveloperPanel", "javascript:new DeveloperPanel(developerAjaxUrl).setupDeveloperPanel({developer_enabled: true});"); - } - + return urls; } @@ -130,27 +160,13 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { protected Map getSiteConfigData(VitroRequest vreq) { Map data = new HashMap(); - - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.MANAGE_USER_ACCOUNTS.ACTION)) { - data.put("userAccounts", UrlBuilder.getUrl("/accountsAdmin")); + + for (AdminUrl adminUrl : siteConfigData) { + if (adminUrl.permission == null || PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION)) { + data.put(adminUrl.key, adminUrl.url); + } } - - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.MANAGE_PROXIES.ACTION)) { - data.put("manageProxies", UrlBuilder.getUrl("/manageProxies")); - } - - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.EDIT_SITE_INFORMATION.ACTION)) { - data.put("siteInfo", UrlBuilder.getUrl("/editForm", "controller", "ApplicationBean")); - } - - //TODO: Add specific permissions for page management - if (PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.MANAGE_MENUS.ACTION)) { - data.put("menuManagement", UrlBuilder.getUrl("/individual", - "uri", "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#DefaultMenu", - "switchToDisplayModel", "true")); - data.put("pageManagement", UrlBuilder.getUrl("/pageList")); - } - + return data; } @@ -211,4 +227,9 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { return urls; } + final static class AdminUrl { + String key; + String url; + AuthorizationRequest permission; + } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java index 46c22e56e..5b97f51f1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java @@ -18,6 +18,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest; import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "browsecontroller", urlPatterns = {"/browse"}, loadOnStartup = 5) public class BrowseController extends FreemarkerHttpServlet { static final long serialVersionUID=2006030721126L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java index 84a315fab..b442f61fa 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactFormController.java @@ -15,10 +15,13 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory; +import javax.servlet.annotation.WebServlet; + /** * Controller for comments ("contact us") page * * @author bjl23 */ +@WebServlet(name = "ContactFormController", urlPatterns = {"/contact"} ) public class ContactFormController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java index 71b36a534..fdb706414 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java @@ -21,6 +21,7 @@ import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; @@ -34,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory; +@WebServlet(name = "sendMail", urlPatterns = {"/submitFeedback"}, loadOnStartup = 5) public class ContactMailController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(ContactMailController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/DeletePropertyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/DeletePropertyController.java index a292b639a..e53e257c4 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/DeletePropertyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/DeletePropertyController.java @@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker; import java.util.HashMap; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -28,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; * Custom deletion controller to which deletion requests from default property form are sent. May be replaced * later with additional features in process rdf form controller or alternative location. */ +@WebServlet(name = "DeletePropertyController", urlPatterns = {"/deletePropertyController"} ) public class DeletePropertyController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(DeletePropertyController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java index d09d1a10d..d327571e2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java @@ -17,6 +17,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetter; import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "HomePageController", urlPatterns = {"/home"} ) public class HomePageController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java index f94f3a1e0..1ffe091ce 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker; import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest.UNAUTHORIZED; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import org.apache.commons.fileupload.FileItem; @@ -38,6 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.web.images.PlaceholderUtil; /** * Handle adding, replacing or deleting the main image on an Individual. */ +@WebServlet(name = "ImageUploadController", urlPatterns = {"/uploadImages"} ) public class ImageUploadController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; private static final Log log = LogFactory diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java index afa6e4b20..f2aab469e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java @@ -28,9 +28,12 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery; import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual; +import javax.servlet.annotation.WebServlet; + /** * Generates a list of individuals for display in a template */ +@WebServlet(name = "IndividualListController", urlPatterns = {"/individuallist"} ) public class IndividualListController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java index 1ed6b5d8d..d4275b280 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListClassGroupsController.java @@ -22,7 +22,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ListClassGroupsController", urlPatterns = {"/listGroups"} ) public class ListClassGroupsController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(ListClassGroupsController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java index 9dfa6eb54..a85f68224 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListDatatypePropertiesController.java @@ -29,6 +29,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ListDatatypePropertiesController", urlPatterns = {"/listDatatypeProperties"} ) public class ListDatatypePropertiesController extends FreemarkerHttpServlet { private static Log log = LogFactory.getLog( ListDatatypePropertiesController.class ); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListFauxPropertiesController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListFauxPropertiesController.java index eba0f1c7f..8675d4d6b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListFauxPropertiesController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListFauxPropertiesController.java @@ -23,6 +23,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ListFauxPropertiesController", urlPatterns = {"/listFauxProperties"} ) public class ListFauxPropertiesController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(ListFauxPropertiesController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java index b6e4704ee..a522829cd 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyGroupsController.java @@ -24,6 +24,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ListPropertyGroupsController", urlPatterns = {"/listPropertyGroups"} ) public class ListPropertyGroupsController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java index 48f63f8a5..a60e16ac2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListPropertyWebappsController.java @@ -33,6 +33,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ListPropertyWebappsController", urlPatterns = {"/listPropertyWebapps"} ) public class ListPropertyWebappsController extends FreemarkerHttpServlet { private static Log log = LogFactory.getLog( ListPropertyWebappsController.class ); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java index caa2251a5..465c43b65 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ListVClassWebappsController.java @@ -26,7 +26,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ListVClassWebappsController", urlPatterns = {"/listVClassWebapps"} ) public class ListVClassWebappsController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(ListVClassWebappsController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java index af568e6c7..29ac5e1b8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletContext; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -40,6 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils; * * See implementations of PageDataGetter for more variables. */ +@WebServlet(name = "PageController", urlPatterns = "/pageController") public class PageController extends FreemarkerHttpServlet{ private static final Log log = LogFactory.getLog(PageController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/RevisionInfoController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/RevisionInfoController.java index 3ca3e0356..a07e8c0b4 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/RevisionInfoController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/RevisionInfoController.java @@ -12,9 +12,12 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + /** * Display the detailed revision information. */ +@WebServlet(name = "RevisionInfoController", urlPatterns = {"/revisionInfo"} ) public class RevisionInfoController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; private static final String TEMPLATE_DEFAULT = "revisionInfo.ftl"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SamplesController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SamplesController.java index 9107e30ac..af100c6ad 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SamplesController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SamplesController.java @@ -14,11 +14,14 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + /** * Freemarker controller and template samples. * @author rjy7 * */ +@WebServlet(name = "FreemarkerSamplesController", urlPatterns = {"/freemarkersamples"} ) public class SamplesController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java index a969c3fd3..f66163b7e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowClassHierarchyController.java @@ -28,7 +28,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ShowClassHierarchyController", urlPatterns = {"/showClassHierarchy"} ) public class ShowClassHierarchyController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(ShowClassHierarchyController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java index 089bba107..5aaa0479f 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowDataPropertyHierarchyController.java @@ -28,6 +28,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ShowDataPropertyHierarchyController", urlPatterns = {"/showDataPropertyHierarchy"} ) public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(ShowDataPropertyHierarchyController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java index 62d3981a2..8dc204dc0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ShowObjectPropertyHierarchyController.java @@ -29,6 +29,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils; import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "ShowObjectPropertyHierarchyController", urlPatterns = {"/showObjectPropertyHierarchy"} ) public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(ShowObjectPropertyHierarchyController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SimpleReasonerRecomputeController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SimpleReasonerRecomputeController.java index 25e1b87cd..fb4158988 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SimpleReasonerRecomputeController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SimpleReasonerRecomputeController.java @@ -18,6 +18,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "SimpleReasonerRecomputeController", urlPatterns = {"/RecomputeInferences"} ) public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog( diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java index 425d34c4b..4827cd259 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java @@ -5,6 +5,9 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "SiteAdminController", urlPatterns = {"/siteAdmin","/siteAdmin.jsp"} ) public class SiteAdminController extends BaseSiteAdminController { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/StaticPageController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/StaticPageController.java index 92a64134a..e7c9d7a63 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/StaticPageController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/StaticPageController.java @@ -14,10 +14,13 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.i18n.I18n; +import javax.servlet.annotation.WebServlet; + /* * Servlet that only specifies a template, without putting any data * into the template model. Page content is fully specified in the template. */ +@WebServlet(name = "StaticPageController", urlPatterns = {"/login"} ) public class StaticPageController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TermsOfUseController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TermsOfUseController.java index 5f0ea4f34..7de7bec51 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TermsOfUseController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TermsOfUseController.java @@ -13,6 +13,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "TermsOfUseController", urlPatterns = {"/termsOfUse"} ) public class TermsOfUseController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java index 29abf3d1e..d1eadbfe8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java @@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -12,11 +13,17 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + /** * Freemarker controller and template sandbox. * @author rjy7 * */ +@WebServlet(name = "FreemarkerTestController", displayName = "FreemarkerTestController", urlPatterns = {"/freemarkertest"} ) public class TestController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java index cc01b5e8f..2f573188c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java @@ -13,6 +13,7 @@ import java.util.Locale; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -39,6 +40,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataProper /*Servlet to view all labels in various languages for individual*/ +@WebServlet(name = "ViewLabelsServlet", urlPatterns = {"/viewLabels"} ) public class ViewLabelsServlet extends FreemarkerHttpServlet{ private static final Log log = LogFactory.getLog(ViewLabelsServlet.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefineMqlreadServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefineMqlreadServlet.java index fb07a0b1e..303d6869e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefineMqlreadServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefineMqlreadServlet.java @@ -10,6 +10,7 @@ import java.util.Map; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -34,6 +35,7 @@ import org.apache.jena.rdf.model.Literal; * @author Eliza Chan (elc2013@med.cornell.edu) * */ +@WebServlet(name = "Google Refine Mqlread Service", urlPatterns = {"/grefineMqlread"} ) public class GrefineMqlreadServlet extends VitroHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefinePropertyListServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefinePropertyListServlet.java index 68b9eddf0..be06db3d7 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefinePropertyListServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/GrefinePropertyListServlet.java @@ -14,6 +14,7 @@ import java.util.List; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -40,6 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; * @author Eliza Chan (elc2013@med.cornell.edu) * */ +@WebServlet(name = "Google Refine Property List Service", urlPatterns = {"/get_properties_of_type"} ) public class GrefinePropertyListServlet extends VitroHttpServlet { private int MAXDEPTH = 7; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java index c8ace7803..38a39b2e8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/grefine/JSONReconcileServlet.java @@ -12,6 +12,7 @@ import java.util.Map; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -41,6 +42,7 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames; * @author Eliza Chan (elc2013@med.cornell.edu) * */ +@WebServlet(name = "JSON Reconcile Service", urlPatterns = {"/reconcile"} ) public class JSONReconcileServlet extends VitroHttpServlet { private static final String PARAM_QUERY = "term"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualController.java index e3bf884e2..35a8ed89b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualController.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -26,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.i18n.I18n; /** * Handles requests for entity information. */ +@WebServlet(name = "individual", urlPatterns = {"/display","/display/*","/entity","/entity/*","/individual","/individual/*"}) public class IndividualController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(IndividualController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaAdminActions.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaAdminActions.java index 6a97e736a..3273ed93f 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaAdminActions.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaAdminActions.java @@ -13,6 +13,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -51,6 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.modules.tboxreasoner.TBoxReasonerModule; +@WebServlet(name = "JenaAdminServlet", urlPatterns = {"/jenaAdmin"} ) public class JenaAdminActions extends BaseEditController { private static final Log log = LogFactory.getLog(JenaAdminActions.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaCsv2RdfController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaCsv2RdfController.java index 1824c2a7e..d8a1f9099 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaCsv2RdfController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaCsv2RdfController.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -28,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.Csv2Rdf; import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils; +@WebServlet(name = "JenaCsv2RdfController", urlPatterns = {"/csv2rdf"} ) public class JenaCsv2RdfController extends JenaIngestController { Log log = LogFactory.getLog( JenaCsv2RdfController.class ); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaExportController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaExportController.java index 4d7db548f..0edc02bbd 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaExportController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaExportController.java @@ -14,6 +14,7 @@ import java.io.OutputStream; import java.util.HashMap; import java.util.Map; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -41,6 +42,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils; +@WebServlet(name = "JenaExportController", urlPatterns = {"/export/*"} ) public class JenaExportController extends BaseEditController { private static final AuthorizationRequest REQUIRED_ACTIONS = SimplePermission.USE_ADVANCED_DATA_TOOLS_PAGES.ACTION .or(SimplePermission.EDIT_ONTOLOGY.ACTION); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java index 50014cf4e..e5dfac058 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaIngestController.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -80,6 +81,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaOutputUtils; import edu.cornell.mannlib.vitro.webapp.utils.jena.WorkflowOntology; import edu.cornell.mannlib.vitro.webapp.utils.sparql.SparqlQueryUtils; +@WebServlet(name = "JenaIngestController", urlPatterns = {"/ingest"} ) public class JenaIngestController extends BaseEditController { private static final Log log = LogFactory.getLog(JenaIngestController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaXMLFileUpload.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaXMLFileUpload.java index 97729606d..d5cf345f8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaXMLFileUpload.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/JenaXMLFileUpload.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.stream.StreamSource; @@ -36,7 +37,8 @@ import org.apache.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -public class JenaXMLFileUpload extends JenaIngestController { +@WebServlet(name = "JenaXMLFileUpload", urlPatterns = {"/jenaXmlFileUpload/*"} ) +public class JenaXMLFileUpload extends JenaIngestController { Log log = LogFactory.getLog(JenaXMLFileUpload.class); private String baseDirectoryForFiles; private int maxFileSize = 1024 * 1024 * 500; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadController.java index ec0fc9884..748e4a248 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadController.java @@ -16,6 +16,7 @@ import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -50,6 +51,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; +@WebServlet(name = "RDFUploadController", urlPatterns = {"/uploadRDF"} ) public class RDFUploadController extends JenaIngestController { private static int maxFileSizeInBytes = 1024 * 1024 * 2000; //2000mb diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadFormController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadFormController.java index 1e2c79c0f..39f9d1230 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadFormController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/jena/RDFUploadFormController.java @@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.jena; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -13,6 +14,7 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +@WebServlet(name = "RDFUploadFormController", urlPatterns = {"/uploadRDFForm"} ) public class RDFUploadFormController extends BaseEditController { private static final Log log = LogFactory.getLog(RDFUploadFormController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java index 6b7a32543..5e67f4d56 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java @@ -7,6 +7,7 @@ import java.util.Collections; import java.util.List; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -31,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils; * * Moved most of the logic into a group of JsonProducer classes. jeb228 */ +@WebServlet(name = "JSONService", urlPatterns = {"/dataservice"} ) public class JsonServlet extends VitroHttpServlet { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(JsonServlet.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestAJAXController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestAJAXController.java index 2674b3dc9..d1708939b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestAJAXController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestAJAXController.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller; import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils; * form. Try adding the behavior logic to the code that generates the * EditConfiguration for the form. */ +@WebServlet(name = "EditRequestAJAX", urlPatterns = {"/editRequestAJAX"} ) public class EditRequestAJAXController extends VitroHttpServlet { private static final long serialVersionUID = 1L; public static Log log = LogFactory.getLog(EditRequestDispatchController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java index 3c2f7c1f4..f3f98dbd1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java @@ -7,6 +7,7 @@ import static edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigura import java.util.HashMap; import java.util.Map; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -47,6 +48,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.MultiValueEditSu * form. Try adding the behavior logic to the code that generates the * EditConfiguration for the form. */ +@WebServlet(name = "EditRequestDispatch", urlPatterns = {"/editRequestDispatch"} ) public class EditRequestDispatchController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; public static Log log = LogFactory.getLog(EditRequestDispatchController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/PostEditCleanupController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/PostEditCleanupController.java index 40ef5e169..6e4932098 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/PostEditCleanupController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/PostEditCleanupController.java @@ -2,6 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.ProcessRdfFormController.Utilities; +@WebServlet(name = "PostEditCleanupController", urlPatterns = {"/postEditCleanupController"} ) public class PostEditCleanupController extends FreemarkerHttpServlet{ private static Log log = LogFactory.getLog(PostEditCleanupController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/ProcessRdfFormController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/ProcessRdfFormController.java index 3e447cbe9..6998738fa 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/ProcessRdfFormController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/ProcessRdfFormController.java @@ -38,12 +38,15 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.ProcessRdfForm; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.RdfLiteralHash; +import javax.servlet.annotation.WebServlet; + /** * This servlet will convert a request to an EditSubmission, * find the EditConfiguration associated with the request, * use ProcessRdfForm to process these to a set of RDF additions and retractions, * the apply these to the models. */ +@WebServlet(name = "ProcessRdfFormController", urlPatterns = {"/edit/process"} ) public class ProcessRdfFormController extends FreemarkerHttpServlet{ private Log log = LogFactory.getLog(ProcessRdfFormController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java index 2737dc25e..9a647f345 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java @@ -12,6 +12,7 @@ import java.net.URLDecoder; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -45,6 +46,7 @@ import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileStorage; * the file system, return a 500. *

*/ +@WebServlet(name = "serveFiles", urlPatterns = {"/file/*"}) public class FileServingServlet extends VitroHttpServlet { /** If we can't locate the requested image, use this one instead. */ private static final String PATH_MISSING_LINK_IMAGE = "/images/missingLink.png"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CachingResponseFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CachingResponseFilter.java index e1119c82d..78124ea4b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CachingResponseFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CachingResponseFilter.java @@ -15,6 +15,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -67,6 +68,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchResultsParser; * An unconditional request may mean that there is no external cache, or that * the cache doesn't have a copy of this particular page. */ +@WebFilter(filterName = "Caching Response filter", urlPatterns = {"/*"}) public class CachingResponseFilter implements Filter { private static final Log log = LogFactory .getLog(CachingResponseFilter.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CharsetEncodingFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CharsetEncodingFilter.java index 015520cfd..f801a3c82 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CharsetEncodingFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/CharsetEncodingFilter.java @@ -11,10 +11,12 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import org.apache.commons.fileupload.servlet.ServletFileUpload; +@WebFilter(filterName = "Character Set Encoding Filter", urlPatterns = {"/*"}) public class CharsetEncodingFilter implements Filter { @Override diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/ClickjackFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/ClickjackFilter.java index 8491e4c81..1846db2f0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/ClickjackFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/ClickjackFilter.java @@ -4,12 +4,14 @@ package edu.cornell.mannlib.vitro.webapp.filters; import java.io.IOException; +import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletResponse; /** @@ -20,6 +22,7 @@ import javax.servlet.http.HttpServletResponse; * http://blogs.msdn.com/sdl/archive/2009/02/05/clickjacking-defense-in-ie8.aspx, * https://www.owasp.org/index.php/ClickjackFilter_for_Java_EE */ +@WebFilter(filterName = "ClickjackFilter", urlPatterns = {"/*"}, dispatcherTypes = {DispatcherType.REQUEST, DispatcherType.FORWARD}) public class ClickjackFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/JSessionStripFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/JSessionStripFilter.java index 276e6a67b..556f47081 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/JSessionStripFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/JSessionStripFilter.java @@ -10,6 +10,7 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; @@ -36,6 +37,7 @@ import org.apache.commons.logging.LogFactory; } * some of this code is from URLRewriteFilter */ +@WebFilter(filterName = "JSession Strip Filter", urlPatterns = {"/*"}) public class JSessionStripFilter implements Filter { private FilterConfig filterConfig = null; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/PageRoutingFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/PageRoutingFilter.java index d2a4e738a..3dd4f0b95 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/PageRoutingFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/PageRoutingFilter.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -15,6 +16,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -32,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; * * It should only be applied to requests, not forwards, includes or errors. */ +@WebFilter(filterName = "PageRoutingFilter", urlPatterns = {"/*"}, dispatcherTypes = {DispatcherType.REQUEST}) public class PageRoutingFilter implements Filter{ protected FilterConfig filterConfig; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java index 25c3cb377..6c9c55e8e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java @@ -7,12 +7,14 @@ import java.text.Collator; import java.util.Enumeration; import java.util.Locale; +import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -30,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; * * This is done in a filter, so it applies to both Servlets and JSPs. */ +@WebFilter(filterName = "RequestModelsPrep", urlPatterns = {"/*"}, dispatcherTypes = {DispatcherType.REQUEST, DispatcherType.FORWARD}) public class RequestModelsPrep implements Filter { private final static Log log = LogFactory.getLog(RequestModelsPrep.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/SessionTimeoutLimitingFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/SessionTimeoutLimitingFilter.java index 343411b07..960212b7b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/SessionTimeoutLimitingFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/SessionTimeoutLimitingFilter.java @@ -10,6 +10,7 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -23,6 +24,7 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean; *
  • Other sessions are trivial, and should have a short interval.
  • * */ +@WebFilter(filterName = "Session Timeout Limiting Filter", urlPatterns = {"/*"}) public class SessionTimeoutLimitingFilter implements Filter { /** Maximum inactive interval for a trivial session object, in seconds. */ private static final int TRIVIAL_SESSION_LIFETIME = 120; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java index d27973112..c82d2f0ef 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java @@ -15,6 +15,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -38,6 +39,7 @@ import freemarker.template.TemplateException; * requests will display normally. However, if the status contains a fatal * error, this filter will hijack every request, and will not let you proceed. */ +@WebFilter(filterName = "Startup Status Display Filter", urlPatterns = {"/*"}) public class StartupStatusDisplayFilter implements Filter { private static final String TEMPLATE_PATH = "/templates/freemarker/body/admin/startupStatus-displayRaw.ftl"; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewriterFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewriterFilter.java index e41be326f..7f79879c8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewriterFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/filters/URLRewriterFilter.java @@ -11,6 +11,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -23,6 +24,7 @@ import javax.servlet.http.HttpServletResponse; * @author bjl23 * */ +@WebFilter(filterName = "URL Rewriter Filter", urlPatterns = {"/*"}) public class URLRewriterFilter implements Filter { private ServletContext _context; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionController.java index cdbe9a855..b1845b7a1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionController.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Locale; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.i18n.I18n; * Set the new Locale in the Session using SelectedLocale and return to the * referrer. */ +@WebServlet(name = "LocaleSelectionController", urlPatterns = {"/selectLocale"}) public class LocaleSelectionController extends HttpServlet { private static final Log log = LogFactory .getLog(LocaleSelectionController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionFilter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionFilter.java index f9af6a537..07e68c9a8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionFilter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectionFilter.java @@ -14,6 +14,7 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; @@ -29,6 +30,7 @@ import org.apache.commons.logging.LogFactory; * * Otherwise, just process the request as usual. */ +@WebFilter(filterName = "Locale selection filter", urlPatterns = {"/*"}) public class LocaleSelectionFilter implements Filter { private static final Log log = LogFactory .getLog(LocaleSelectionFilter.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java index 9d988b927..ad6b893ce 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -42,6 +43,7 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames; * via the search index. */ +@WebServlet(name = "AutocompleteController", urlPatterns = {"/autocomplete","/populateselect"} ) public class AutocompleteController extends VitroAjaxController { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/DataAutocompleteController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/DataAutocompleteController.java index 6545fb978..8e10c8c01 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/DataAutocompleteController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/DataAutocompleteController.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -38,6 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController; * . */ +@WebServlet(name = "DataAutocompleteController", urlPatterns = {"/dataautocomplete"} ) public class DataAutocompleteController extends VitroAjaxController { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/IndexController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/IndexController.java index d7dbf91d2..52610773b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/IndexController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/IndexController.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -45,6 +46,7 @@ import edu.cornell.mannlib.vitro.webapp.services.freemarker.FreemarkerProcessing * can maintain a history of activity. This will provide the contents of the * display. */ +@WebServlet(name = "IndexController", urlPatterns = {"/SearchIndex"} ) public class IndexController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(IndexController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java index bc997adf6..2edd8599c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -57,6 +58,7 @@ import edu.ucsf.vitro.opensocial.OpenSocialManager; * Paged search controller that uses the search engine */ +@WebServlet(name = "SearchController", urlPatterns = {"/search","/search.jsp","/fedsearch","/searchcontroller"} ) public class PagedSearchController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchHelpController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchHelpController.java index 8ab1cf278..2cfceb28e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchHelpController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchHelpController.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Enumeration; import javax.servlet.RequestDispatcher; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; +@WebServlet(name = "SearchHelpController", urlPatterns = {"/searchHelp"} ) public class SearchHelpController extends FreemarkerHttpServlet { private static final Log log = LogFactory.getLog(SearchHelpController.class.getName()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java index 5406969cc..e129bbfa1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; @@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer; * Accepts requests to update a set of URIs in the search index. */ @SuppressWarnings("serial") +@WebServlet(name = "SearchServiceController", urlPatterns = {"/searchService/*"}) public class SearchServiceController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(SearchServiceController.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java index 5be57117a..9e5c2c7c1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.List; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -25,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; * @author yuysun */ +@WebServlet(name = "GetAllClasses", urlPatterns = {"/admin/getAllClasses"}) public class GetAllClasses extends BaseEditController { private static final Log log = LogFactory.getLog(GetAllClasses.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java index 866c75b36..6e3998b54 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; * @author yuysun */ +@WebServlet(name = "GetAllPrefix", urlPatterns = {"/admin/getAllPrefix"}) public class GetAllPrefix extends BaseEditController { private static final Log log = LogFactory.getLog(GetAllPrefix.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzAllProperties.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzAllProperties.java index 4aa4bd02e..ba27c6136 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzAllProperties.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzAllProperties.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -35,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; * This servlet gets all the properties for a given subject. */ +@WebServlet(name = "GetClazzAllProperties", urlPatterns = {"/admin/getClazzAllProperties"}) public class GetClazzAllProperties extends BaseEditController { private static final Log log = LogFactory.getLog(GetClazzAllProperties.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java index df4efd566..fdd7a0458 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Iterator; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -24,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; * This servlet gets all the data properties for a given subject. */ +@WebServlet(name = "GetClazzDataProperties", urlPatterns = {"/admin/getClazzDataProperties"}) public class GetClazzDataProperties extends BaseEditController { private static final Log log = LogFactory.getLog(GetClazzDataProperties.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java index 1bc63c21d..9a8fa1497 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -32,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; * This servlet gets all the object properties for a given subject. */ +@WebServlet(name = "GetClazzObjectProperties", urlPatterns = {"/admin/getClazzObjectProperties"}) public class GetClazzObjectProperties extends BaseEditController { private static final Log log = LogFactory.getLog(GetClazzObjectProperties.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java index 474194afb..db83a2f0a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.List; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -26,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; * This servlet gets all the range classes for a given predicate. */ +@WebServlet(name = "GetObjectClasses", urlPatterns = {"/admin/getObjectClasses"}) public class GetObjectClasses extends BaseEditController { private static final Log log = LogFactory.getLog(GetObjectClasses.class); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/JSPPageHandler.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/JSPPageHandler.java index ac7dd7d1e..ee7184ce4 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/JSPPageHandler.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/JSPPageHandler.java @@ -11,6 +11,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; @@ -68,6 +69,16 @@ public class JSPPageHandler { @Override public ServletOutputStream getOutputStream() throws IOException { return new ServletOutputStream() { + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + + } + @Override public void write(int b) throws IOException { byteArray.write(b); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/developer/DeveloperSettingsServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/developer/DeveloperSettingsServlet.java index e5458c57a..b28b2d568 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/developer/DeveloperSettingsServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/developer/DeveloperSettingsServlet.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; @@ -35,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.services.freemarker.FreemarkerProcessing * is only a statement that developer mode is enabled. Otherwise, it * is a full panel (collapsed at first). */ +@WebServlet(name = "DeveloperAjax", urlPatterns = {"/admin/developerAjax"} ) public class DeveloperSettingsServlet extends VitroAjaxController { private static final Log log = LogFactory .getLog(DeveloperSettingsServlet.class); diff --git a/api/src/main/java/edu/ucsf/vitro/opensocial/GadgetController.java b/api/src/main/java/edu/ucsf/vitro/opensocial/GadgetController.java index 7326925af..dd61dcb6b 100644 --- a/api/src/main/java/edu/ucsf/vitro/opensocial/GadgetController.java +++ b/api/src/main/java/edu/ucsf/vitro/opensocial/GadgetController.java @@ -16,6 +16,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Red import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "GadgetController", urlPatterns = {"/orng/*"}) public class GadgetController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; diff --git a/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java b/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java index 3e326e772..e2bd34a14 100644 --- a/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java +++ b/api/src/main/java/org/vivoweb/linkeddatafragments/servlet/VitroLinkedDataFragmentServlet.java @@ -29,6 +29,7 @@ import org.vivoweb.linkeddatafragments.datasource.rdfservice.RDFServiceDataSourc import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -46,6 +47,7 @@ import java.util.Map.Entry; /** * Servlet that responds with a Linked Data Fragment. */ +@WebServlet(name = "TpfServlet", urlPatterns = {"/tpf/*"}) public class VitroLinkedDataFragmentServlet extends VitroHttpServlet { private final static long serialVersionUID = 1L; diff --git a/api/src/test/java/stubs/javax/servlet/ServletContextStub.java b/api/src/test/java/stubs/javax/servlet/ServletContextStub.java index 91a0a9416..89d6e96bc 100644 --- a/api/src/test/java/stubs/javax/servlet/ServletContextStub.java +++ b/api/src/test/java/stubs/javax/servlet/ServletContextStub.java @@ -9,14 +9,21 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.Enumeration; +import java.util.EventListener; import java.util.HashMap; import java.util.Map; import java.util.Set; +import javax.servlet.Filter; +import javax.servlet.FilterRegistration; import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; +import javax.servlet.SessionCookieConfig; +import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -150,6 +157,11 @@ public class ServletContextStub implements ServletContext { "ServletContextStub.getInitParameterNames() not implemented."); } + @Override + public boolean setInitParameter(String s, String s1) { + return false; + } + @Override public int getMajorVersion() { throw new RuntimeException( @@ -168,6 +180,16 @@ public class ServletContextStub implements ServletContext { "ServletContextStub.getMinorVersion() not implemented."); } + @Override + public int getEffectiveMajorVersion() { + return 0; + } + + @Override + public int getEffectiveMinorVersion() { + return 0; + } + @Override public RequestDispatcher getNamedDispatcher(String arg0) { throw new RuntimeException( @@ -212,6 +234,126 @@ public class ServletContextStub implements ServletContext { "ServletContextStub.getServletContextName() not implemented."); } + @Override + public ServletRegistration.Dynamic addServlet(String s, String s1) { + return null; + } + + @Override + public ServletRegistration.Dynamic addServlet(String s, Servlet servlet) { + return null; + } + + @Override + public ServletRegistration.Dynamic addServlet(String s, Class aClass) { + return null; + } + + @Override + public T createServlet(Class aClass) throws ServletException { + return null; + } + + @Override + public ServletRegistration getServletRegistration(String s) { + return null; + } + + @Override + public Map getServletRegistrations() { + return null; + } + + @Override + public FilterRegistration.Dynamic addFilter(String s, String s1) { + return null; + } + + @Override + public FilterRegistration.Dynamic addFilter(String s, Filter filter) { + return null; + } + + @Override + public FilterRegistration.Dynamic addFilter(String s, Class aClass) { + return null; + } + + @Override + public T createFilter(Class aClass) throws ServletException { + return null; + } + + @Override + public FilterRegistration getFilterRegistration(String s) { + return null; + } + + @Override + public Map getFilterRegistrations() { + return null; + } + + @Override + public SessionCookieConfig getSessionCookieConfig() { + return null; + } + + @Override + public void setSessionTrackingModes(Set set) { + + } + + @Override + public Set getDefaultSessionTrackingModes() { + return null; + } + + @Override + public Set getEffectiveSessionTrackingModes() { + return null; + } + + @Override + public void addListener(String s) { + + } + + @Override + public void addListener(T t) { + + } + + @Override + public void addListener(Class aClass) { + + } + + @Override + public T createListener(Class aClass) throws ServletException { + return null; + } + + @Override + public JspConfigDescriptor getJspConfigDescriptor() { + return null; + } + + @Override + public ClassLoader getClassLoader() { + return null; + } + + @Override + public void declareRoles(String... strings) { + + } + + @Override + public String getVirtualServerName() { + return null; + } + @Override @SuppressWarnings("rawtypes") @Deprecated diff --git a/api/src/test/java/stubs/javax/servlet/http/HttpServletRequestStub.java b/api/src/test/java/stubs/javax/servlet/http/HttpServletRequestStub.java index 03368c2f5..fb216bc60 100644 --- a/api/src/test/java/stubs/javax/servlet/http/HttpServletRequestStub.java +++ b/api/src/test/java/stubs/javax/servlet/http/HttpServletRequestStub.java @@ -8,6 +8,7 @@ import java.io.UnsupportedEncodingException; import java.net.URL; import java.security.Principal; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -15,11 +16,20 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import javax.servlet.AsyncContext; +import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpUpgradeHandler; +import javax.servlet.http.Part; import edu.cornell.mannlib.vitro.webapp.web.URLEncoder; @@ -156,6 +166,11 @@ public class HttpServletRequestStub implements HttpServletRequest { return getSession(true); } + @Override + public String changeSessionId() { + return null; + } + @Override public HttpSession getSession(boolean create) { if (create && (session == null)) { @@ -369,6 +384,36 @@ public class HttpServletRequestStub implements HttpServletRequest { "HttpServletRequestStub.isRequestedSessionIdFromUrl() not implemented."); } + @Override + public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException { + return false; + } + + @Override + public void login(String s, String s1) throws ServletException { + + } + + @Override + public void logout() throws ServletException { + + } + + @Override + public Collection getParts() throws IOException, ServletException { + return null; + } + + @Override + public Part getPart(String s) throws IOException, ServletException { + return null; + } + + @Override + public T upgrade(Class aClass) throws IOException, ServletException { + return null; + } + @Override public boolean isRequestedSessionIdValid() { throw new RuntimeException( @@ -393,6 +438,11 @@ public class HttpServletRequestStub implements HttpServletRequest { "HttpServletRequestStub.getContentLength() not implemented."); } + @Override + public long getContentLengthLong() { + return 0; + } + @Override public String getContentType() { throw new RuntimeException( @@ -423,6 +473,41 @@ public class HttpServletRequestStub implements HttpServletRequest { "HttpServletRequestStub.getLocalPort() not implemented."); } + @Override + public ServletContext getServletContext() { + return null; + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + return null; + } + + @Override + public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException { + return null; + } + + @Override + public boolean isAsyncStarted() { + return false; + } + + @Override + public boolean isAsyncSupported() { + return false; + } + + @Override + public AsyncContext getAsyncContext() { + return null; + } + + @Override + public DispatcherType getDispatcherType() { + return null; + } + @Override public Locale getLocale() { throw new RuntimeException( diff --git a/api/src/test/java/stubs/javax/servlet/http/HttpServletResponseStub.java b/api/src/test/java/stubs/javax/servlet/http/HttpServletResponseStub.java index 3edd787e6..eeaaeeb5b 100644 --- a/api/src/test/java/stubs/javax/servlet/http/HttpServletResponseStub.java +++ b/api/src/test/java/stubs/javax/servlet/http/HttpServletResponseStub.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Collection; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -14,6 +15,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; @@ -62,6 +64,16 @@ public class HttpServletResponseStub implements HttpServletResponse { return headers.get(name); } + @Override + public Collection getHeaders(String s) { + return null; + } + + @Override + public Collection getHeaderNames() { + return null; + } + // ---------------------------------------------------------------------- // Stub methods // ---------------------------------------------------------------------- @@ -115,6 +127,16 @@ public class HttpServletResponseStub implements HttpServletResponse { } return new ServletOutputStream() { + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + + } + @Override public void write(int thisChar) throws IOException { outputStream.write(thisChar); @@ -214,6 +236,11 @@ public class HttpServletResponseStub implements HttpServletResponse { "HttpServletResponseStub.setContentLength() not implemented."); } + @Override + public void setContentLengthLong(long l) { + + } + @Override public void setLocale(Locale arg0) { throw new RuntimeException( diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml index 93d65c786..3297931ec 100644 --- a/webapp/src/main/webapp/WEB-INF/web.xml +++ b/webapp/src/main/webapp/WEB-INF/web.xml @@ -2,10 +2,11 @@ - + @@ -41,7 +42,10 @@ - + edu.cornell.mannlib.vitro.webapp.startup.StartupManager @@ -53,101 +57,49 @@ - + - - Startup Status Display Filter - edu.cornell.mannlib.vitro.webapp.filters.StartupStatusDisplayFilter - Startup Status Display Filter /* - - - Session Timeout Limiting Filter - edu.cornell.mannlib.vitro.webapp.filters.SessionTimeoutLimitingFilter - Session Timeout Limiting Filter /* - - - Character Set Encoding Filter - edu.cornell.mannlib.vitro.webapp.filters.CharsetEncodingFilter - Character Set Encoding Filter /* - - - Override the Locale in the HttpRequest, if appropriate. - Locale selection filter - edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionFilter - Locale selection filter /* - - - Recognize conditional requests, and generate Cache-Control headers. - Caching Response filter - edu.cornell.mannlib.vitro.webapp.filters.CachingResponseFilter - Caching Response filter /* - - - JSession Strip Filter - edu.cornell.mannlib.vitro.webapp.filters.JSessionStripFilter - JSession Strip Filter /* - - - URL Rewriter Filter - edu.cornell.mannlib.vitro.webapp.filters.URLRewriterFilter - URL Rewriter Filter /* - - - RequestModelsPrep - edu.cornell.mannlib.vitro.webapp.filters.RequestModelsPrep - RequestModelsPrep /* REQUEST FORWARD - - - ClickjackFilter - edu.cornell.mannlib.vitro.webapp.filters.ClickjackFilter - ClickjackFilter /* REQUEST FORWARD - - - PageRoutingFilter - edu.cornell.mannlib.vitro.webapp.filters.PageRoutingFilter - PageRoutingFilter /* @@ -176,798 +128,7 @@ REQUEST - - - - - IndexController - edu.cornell.mannlib.vitro.webapp.search.controller.IndexController - - - IndexController - /SearchIndex - - - - SimpleReasonerRecomputeController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.SimpleReasonerRecomputeController - - - SimpleReasonerRecomputeController - /RecomputeInferences - - - - MenuManagementEdit - edu.cornell.mannlib.vitro.webapp.controller.edit.MenuManagementEdit - - - MenuManagementEdit - /menuManagementEdit - - - - ajaxSparqlQuery - edu.cornell.mannlib.vitro.webapp.controller.ajax.SparqlQueryAjaxController - - - ajaxSparqlQuery - /ajax/sparqlQuery - - - - AboutController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.AboutController - - - AboutController - /about - - - - HomePageController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.HomePageController - - - HomePageController - /home - - - - PageController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.PageController - - - - - FreemarkerTestController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.TestController - - - FreemarkerTestController - /freemarkertest - - - - FreemarkerSamplesController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.SamplesController - - - FreemarkerSamplesController - /freemarkersamples - - - - SiteAdminController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.SiteAdminController - - - SiteAdminController - /siteAdmin - - - SiteAdminController - /siteAdmin.jsp - - - - StaticPageController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.StaticPageController - - - StaticPageController - /login - - - - RevisionInfoController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.RevisionInfoController - - - RevisionInfoController - /revisionInfo - - - - ImageUploadController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploadController - - - ImageUploadController - /uploadImages - - - - ProcessRdfFormController - edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.ProcessRdfFormController - - - ProcessRdfFormController - /edit/process - - - - DeletePropertyController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.DeletePropertyController - - - DeletePropertyController - /deletePropertyController - - - - - - PostEditCleanupController - edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.PostEditCleanupController - - - PostEditCleanupController - /postEditCleanupController - - - - DeletePageController - edu.cornell.mannlib.vitro.webapp.controller.edit.DeletePageController - - - DeletePageController - /deletePageController - - - - EditRequestDispatch - edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestDispatchController - - - EditRequestDispatch - /editRequestDispatch - - - - EditRequestAJAX - edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestAJAXController - - - EditRequestAJAX - /editRequestAJAX - - - - RDFUploadFormController - edu.cornell.mannlib.vitro.webapp.controller.jena.RDFUploadFormController - - - RDFUploadFormController - /uploadRDFForm - - - - RDFUploadController - edu.cornell.mannlib.vitro.webapp.controller.jena.RDFUploadController - - - RDFUploadController - /uploadRDF - - - - JenaIngestController - edu.cornell.mannlib.vitro.webapp.controller.jena.JenaIngestController - - - JenaIngestController - /ingest - - - - JenaCsv2RdfController - edu.cornell.mannlib.vitro.webapp.controller.jena.JenaCsv2RdfController - - - JenaCsv2RdfController - /csv2rdf - - - - JenaExportController - edu.cornell.mannlib.vitro.webapp.controller.jena.JenaExportController - - - JenaExportController - /export/* - - - - JenaXMLFileUpload - edu.cornell.mannlib.vitro.webapp.controller.jena.JenaXMLFileUpload - - - JenaXMLFileUpload - /jenaXmlFileUpload/* - - - - JenaAdminServlet - edu.cornell.mannlib.vitro.webapp.controller.jena.JenaAdminActions - - - JenaAdminServlet - /jenaAdmin - - - - DumpRestoreController - edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController - - - DumpRestoreController - /dumpRestore/* - - - - EditFrontController - edu.cornell.mannlib.vedit.controller.EditFrontController - - - EditFrontController - /editForm - - - - OperationController - edu.cornell.mannlib.vedit.controller.OperationController - - - OperationController - /doEdit - - - - EntityEditController - edu.cornell.mannlib.vitro.webapp.controller.edit.EntityEditController - - - EntityEditController - /entityEdit - - - - VclassEditController - edu.cornell.mannlib.vitro.webapp.controller.edit.VclassEditController - - - VclassEditController - /vclassEdit - - - - Classes2ClassesOperationController - edu.cornell.mannlib.vitro.webapp.controller.edit.Classes2ClassesOperationController - - - Classes2ClassesOperationController - /classes2ClassesOp - - - - Properties2PropertiesOperationController - edu.cornell.mannlib.vitro.webapp.controller.edit.Properties2PropertiesOperationController - - - Properties2PropertiesOperationController - /props2PropsOp - - - - NamespacePrefixOperationController - edu.cornell.mannlib.vitro.webapp.controller.edit.NamespacePrefixOperationController - - - NamespacePrefixOperationController - /namespacePrefixOp - - - - RefactorOperationController - edu.cornell.mannlib.vitro.webapp.controller.edit.RefactorOperationController - - - RefactorOperationController - /refactorOp - - - - IndividualTypeOperationController - edu.cornell.mannlib.vitro.webapp.controller.edit.IndividualTypeOperationController - - - IndividualTypeOperationController - /individualTypeOp - - - - DatapropEditController - edu.cornell.mannlib.vitro.webapp.controller.edit.DatapropEditController - - - DatapropEditController - /datapropEdit - - - - OntologyEditController - edu.cornell.mannlib.vitro.webapp.controller.edit.OntologyEditController - - - OntologyEditController - /ontologyEdit - - - - PropertyEditController - edu.cornell.mannlib.vitro.webapp.controller.edit.PropertyEditController - - - PropertyEditController - /propertyEdit - - - - EntityRetryController - edu.cornell.mannlib.vitro.webapp.controller.edit.EntityRetryController - - - EntityRetryController - /entity_retry - - - - VclassRetryController - edu.cornell.mannlib.vitro.webapp.controller.edit.VclassRetryController - - - VclassRetryController - /vclass_retry - - - - DatatypeRetryController - edu.cornell.mannlib.vitro.webapp.controller.edit.DatatypeRetryController - - - DatatypeRetryController - /datatype_retry - - - - ListClassGroupsController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListClassGroupsController - - - ListClassGroupsController - /listGroups - - - - ListPropertyGroupsController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListPropertyGroupsController - - - ListPropertyGroupsController - /listPropertyGroups - - - - OntologiesListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.OntologiesListingController - - - OntologiesListingController - /listOntologies - - - - NamespacesListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.jena.NamespacesListingController - - - NamespacesListingController - /listNamespaces - - - - RestrictionsListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.jena.RestrictionsListingController - - - RestrictionsListingController - /listRestrictions - - - - RestrictionOperationController - edu.cornell.mannlib.vitro.webapp.controller.edit.RestrictionOperationController - - - RestrictionOperationController - /addRestriction - - - - AccountsAdmin - edu.cornell.mannlib.vitro.webapp.controller.accounts.admin.UserAccountsAdminController - - - AccountsAdmin - /accountsAdmin/* - - - - AccountsAjax - edu.cornell.mannlib.vitro.webapp.controller.accounts.admin.ajax.UserAccountsAjaxController - - - AccountsAjax - /accountsAjax/* - - - - AccountsUser - edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsUserController - - - AccountsUser - /accounts/* - - - - ViewLabelsServlet - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ViewLabelsServlet - - - ViewLabelsServlet - /viewLabels - - - - ManageProxies - edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ManageProxiesController - - - ManageProxies - /manageProxies/* - - - - ProxiesAjax - edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ajax.ManageProxiesAjaxController - - - ProxiesAjax - /proxiesAjax/* - - - - ShowAuth - edu.cornell.mannlib.vitro.webapp.controller.admin.ShowAuthController - - - ShowAuth - /admin/showAuth - - - - ShowConfiguration - edu.cornell.mannlib.vitro.webapp.controller.admin.ShowConfiguration - - - ShowConfiguration - /admin/showConfiguration - - - - StartupStatus - edu.cornell.mannlib.vitro.webapp.controller.admin.StartupStatusController - - - StartupStatus - /startupStatus - - - - RestrictLogins - edu.cornell.mannlib.vitro.webapp.controller.admin.RestrictLoginsController - - - RestrictLogins - /admin/restrictLogins - - - - ShowBackgroundThreads - edu.cornell.mannlib.vitro.webapp.controller.admin.ShowBackgroundThreadsController - - - ShowBackgroundThreads - /admin/showThreads - - - - WaitForBackgroundThreads - edu.cornell.mannlib.vitro.webapp.controller.admin.WaitForBackgroundThreadsController - - - WaitForBackgroundThreads - /admin/wait - - - - ListVClassWebappsController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListVClassWebappsController - - - ListVClassWebappsController - /listVClassWebapps - - - - IndividualsListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.IndividualsListingController - - - IndividualsListingController - /listIndividuals - - - - - ShowClassHierarchyController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ShowClassHierarchyController - - - ShowClassHierarchyController - /showClassHierarchy - - - - ShowObjectPropertyHierarchyController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ShowObjectPropertyHierarchyController - - - ShowObjectPropertyHierarchyController - /showObjectPropertyHierarchy - - - - ShowDataPropertyHierarchyController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ShowDataPropertyHierarchyController - - - ShowDataPropertyHierarchyController - /showDataPropertyHierarchy - - - - ListFauxPropertiesController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListFauxPropertiesController - - - ListFauxPropertiesController - /listFauxProperties - - - - ListPropertyWebappsController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListPropertyWebappsController - - - ListPropertyWebappsController - /listPropertyWebapps - - - - ListDatatypePropertiesController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListDatatypePropertiesController - - - ListDatatypePropertiesController - /listDatatypeProperties - - - - DataPropertyStatementListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.DataPropertyStatementListingController - - - DataPropertyStatementListingController - /listDataPropertyStatements - - - - ObjectPropertyStatementListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.ObjectPropertyStatementListingController - - - ObjectPropertyStatementListingController - /listObjectPropertyStatements - - - - IndividualListController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController - - - IndividualListController - /individuallist - - - - IndividualListRdf - edu.cornell.mannlib.vitro.webapp.controller.IndividualListRdfController - - - IndividualListRdf - /listrdf/* - - - - SearchController - edu.cornell.mannlib.vitro.webapp.search.controller.PagedSearchController - - - SearchController - /search - - - - SearchHelpController - edu.cornell.mannlib.vitro.webapp.search.controller.SearchHelpController - - - SearchHelpController - /searchHelp - - - - DeveloperAjax - edu.cornell.mannlib.vitro.webapp.utils.developer.DeveloperSettingsServlet - - - DeveloperAjax - /admin/developerAjax - - - - - SearchController - /search.jsp - - - SearchController - /fedsearch - - - SearchController - /searchcontroller - - - - AutocompleteController - edu.cornell.mannlib.vitro.webapp.search.controller.AutocompleteController - - - AutocompleteController - /autocomplete - - - AutocompleteController - /populateselect - - - - DataAutocompleteController - edu.cornell.mannlib.vitro.webapp.search.controller.DataAutocompleteController - - - DataAutocompleteController - /dataautocomplete - - - ReorderController - edu.cornell.mannlib.vitro.webapp.controller.edit.ReorderController - - - ReorderController - /edit/reorder - - - - TermsOfUseController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.TermsOfUseController - - - TermsOfUseController - /termsOfUse - - - - ContactFormController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ContactFormController - - - ContactFormController - /contact - - - - JSON Service - edu.cornell.mannlib.vitro.webapp.controller.json.JsonServlet - - - JSON Service - /dataservice - - - - DashboardPropertyListController - edu.cornell.mannlib.vitro.webapp.controller.DashboardPropertyListController - - - DashboardPropertyListController - /dashboardPropList - - + dwr-invoker org.directwebremoting.servlet.DwrServlet @@ -985,304 +146,17 @@ /dwr/* - - sendMail - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ContactMailController - 5 - - - sendMail - /submitFeedback - - - - mailusers - edu.cornell.mannlib.vitro.webapp.controller.MailUsersServlet - 5 - - - - ontology - edu.cornell.mannlib.vitro.webapp.controller.OntologyController - - - - individual - edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualController - - - - authenticate - edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate - - - - loginExternalAuthSetup - edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginExternalAuthSetup - - - - loginExternalAuthReturn - edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginExternalAuthReturn - - - - programLogin - edu.cornell.mannlib.vitro.webapp.controller.authenticate.ProgramLogin - - - programLogin - /programLogin - - - - adminLogin - edu.cornell.mannlib.vitro.webapp.controller.authenticate.AdminLoginController - - - adminLogin - /admin/login - - - - logout - edu.cornell.mannlib.vitro.webapp.controller.edit.Logout - - - - - - browsecontroller - edu.cornell.mannlib.vitro.webapp.controller.freemarker.BrowseController - 5 - - - browsecontroller - /browse - - - - serveFiles - edu.cornell.mannlib.vitro.webapp.filestorage.serving.FileServingServlet - - - serveFiles - /file/* - - - - SparqlQuery - edu.cornell.mannlib.vitro.webapp.controller.admin.SparqlQueryController - - - - SparqlQuery - /admin/sparqlquery - - - - SparqlQueryApi - edu.cornell.mannlib.vitro.webapp.controller.api.SparqlQueryApiController - - - - SparqlQueryApi - /api/sparqlQuery - - - - SparqlUpdateApi - edu.cornell.mannlib.vitro.webapp.controller.api.SparqlUpdateApiController - - - - SparqlUpdateApi - /api/sparqlUpdate - - - - primitiveRdfEdit - edu.cornell.mannlib.vitro.webapp.controller.edit.PrimitiveRdfEdit - - - primitiveRdfEdit - /edit/primitiveRdfEdit - - - - primitiveDelete - edu.cornell.mannlib.vitro.webapp.controller.edit.PrimitiveDelete - - - primitiveDelete - /edit/primitiveDelete - - - - - mailusers - /mailusers - - - - individual - /entity - - - individual - /entity/* - - - individual - /individual - - - individual - /individual/* - - - individual - /display - - - individual - /display/* - - - - ontology - /ontology/* - - - authenticate - /authenticate - - - loginExternalAuthSetup - /loginExternalAuth - - - loginExternalAuthReturn - /loginExternalAuthReturn - - - logout - /logout - - - - - - SparlQueryBuilder - edu.cornell.mannlib.vitro.webapp.controller.SparqlQueryBuilderServlet - - - SparlQueryBuilder - /admin/sparqlquerybuilder - - - - GetAllClasses - edu.cornell.mannlib.vitro.webapp.sparql.GetAllClasses - - - GetAllClasses - /admin/getAllClasses - - - - GetAllPrefix - edu.cornell.mannlib.vitro.webapp.sparql.GetAllPrefix - - - GetAllPrefix - /admin/getAllPrefix - - - - GetClazzDataProperties - edu.cornell.mannlib.vitro.webapp.sparql.GetClazzDataProperties - - - GetClazzDataProperties - /admin/getClazzDataProperties - - - - GetClazzAllProperties - edu.cornell.mannlib.vitro.webapp.sparql.GetClazzAllProperties - - - GetClazzAllProperties - /admin/getClazzAllProperties - - - - GetClazzObjectProperties - edu.cornell.mannlib.vitro.webapp.sparql.GetClazzObjectProperties - - - GetClazzObjectProperties - /admin/getClazzObjectProperties - - - - GetObjectClasses - edu.cornell.mannlib.vitro.webapp.sparql.GetObjectClasses - - - GetObjectClasses - /admin/getObjectClasses - - - - SearchServiceController - edu.cornell.mannlib.vitro.webapp.search.controller.SearchServiceController - - - SearchServiceController - /searchService/* - - - - - GadgetController - edu.ucsf.vitro.opensocial.GadgetController - - - GadgetController - /orng/* - - - - Multiple-language support. Allows user to select his preferred langauge - LocaleSelectionController - edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionController - - - LocaleSelectionController - /selectLocale - - - - TpfServlet - TpfServlet - org.vivoweb.linkeddatafragments.servlet.VitroLinkedDataFragmentServlet - - - TpfServlet - /tpf/* - +--> @@ -1338,9 +212,8 @@ xml application/xml - + - /WEB-INF/tlds/database.tld @@ -1373,16 +246,4 @@ - - - - - - - - From 121eb088d1b031a407b6ec0d09390737dd1774f1 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Sun, 27 Aug 2017 22:11:18 +0100 Subject: [PATCH 08/90] [VIVO-1376] Smoke test for SDB that looks for signs that it hasn't been upgraded from Jena 2. --- .../webapp/application/ApplicationImpl.java | 17 ++++++++++------- .../impl/sdb/SDBConnectionSmokeTests.java | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java index b631836c8..1838bb3ff 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java @@ -171,14 +171,17 @@ public class ApplicationImpl implements Application { ss.info(this, "Started the ContentTripleSource: " + contentTripleSource); - ConfigurationTripleSource configurationTripleSource = app - .getConfigurationTripleSource(); - configurationTripleSource.startup(app, css); - ss.info(this, "Started the ConfigurationTripleSource: " - + configurationTripleSource); + // Ensure that we haven't failed setting up the content triple store before continuing + if (!ss.isStartupAborted()) { + ConfigurationTripleSource configurationTripleSource = app + .getConfigurationTripleSource(); + configurationTripleSource.startup(app, css); + ss.info(this, "Started the ConfigurationTripleSource: " + + configurationTripleSource); - configureJena(); - prepareCombinedTripleSource(app, ctx); + configureJena(); + prepareCombinedTripleSource(app, ctx); + } } private void configureJena() { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/triplesource/impl/sdb/SDBConnectionSmokeTests.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/triplesource/impl/sdb/SDBConnectionSmokeTests.java index 3246d2c07..5cdd73130 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/triplesource/impl/sdb/SDBConnectionSmokeTests.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/triplesource/impl/sdb/SDBConnectionSmokeTests.java @@ -94,7 +94,22 @@ public class SDBConnectionSmokeTests { try (Connection conn = DriverManager .getConnection(url, connectionProps)) { - // Just open the connection and close it. + // We have an SQL connection - see if we have any XSD Strings in the database + String skip = props.getProperty("skip.Jena3StringTest", "false"); + if (!Boolean.parseBoolean(skip)) { + try { + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT COUNT(1) AS total FROM Nodes WHERE datatype='http://www.w3.org/2001/XMLSchema#string'"); + if (rs != null && rs.next()) { + long total = rs.getLong("total"); + if (total > 0) { + ss.fatal("XSD Strings exist in Nodes table. Requires upgrade for Jena 3"); + } + } + } catch (SQLException e) { + // Ignore SQL Exception here, as it likely represents a triple store that's not initialised yet. + } + } } catch (SQLException e) { ss.fatal("Can't connect to the database: " + PROPERTY_DB_URL + "='" + url + "', " + PROPERTY_DB_USERNAME + "='" + username From c40969726718105d8083235d39661899f5f1958c Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Tue, 29 Aug 2017 08:19:15 +0100 Subject: [PATCH 09/90] Update to use newer jenatools --- home/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/pom.xml b/home/pom.xml index 06d33c35c..0a5802f25 100644 --- a/home/pom.xml +++ b/home/pom.xml @@ -69,13 +69,13 @@ org.vivoweb jena2tools - 1.0 + 1.0.1 true org.vivoweb jena3tools - 1.0 + 1.0.1 true From a132b2421eb524950fd41fa3ce7fffc305c36268 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Tue, 29 Aug 2017 22:56:15 +0100 Subject: [PATCH 10/90] [VIVO-1294] Allow applications built on Vitro to have application-level messages distinct from themes --- .../webapp/i18n/VitroResourceBundle.java | 96 ++++++++++++------- 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java index 6bfc75434..5fa5e217d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java @@ -9,7 +9,9 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import java.util.Properties; import java.util.ResourceBundle; @@ -49,6 +51,22 @@ public class VitroResourceBundle extends ResourceBundle { private static final String FILE_FLAG = "@@file "; private static final String MESSAGE_FILE_NOT_FOUND = "File {1} not found for property {0}."; + private static final List appPrefixes = new ArrayList<>(); + + static { + addAppPrefix("vitro"); + } + + public static void addAppPrefix(String prefix) { + if (!prefix.endsWith("-") && !prefix.endsWith("_")) { + prefix = prefix + "_"; + } + + if (!appPrefixes.contains(prefix)) { + appPrefixes.add(prefix); + } + } + // ---------------------------------------------------------------------- // Factory method // ---------------------------------------------------------------------- @@ -94,7 +112,6 @@ public class VitroResourceBundle extends ResourceBundle { private final String appI18nPath; private final String themeI18nPath; private final Control control; - private final Properties defaults; private final Properties properties; private VitroResourceBundle(String bundleName, ServletContext ctx, @@ -105,49 +122,58 @@ public class VitroResourceBundle extends ResourceBundle { this.appI18nPath = appI18nPath; this.themeI18nPath = themeI18nPath; this.control = control; - - this.defaults = new Properties(); - this.properties = new Properties(this.defaults); - - loadProperties(); + this.properties = loadProperties(); loadReferencedFiles(); } - private void loadProperties() throws IOException { + private Properties loadProperties() throws IOException { String resourceName = control.toResourceName(bundleName, "properties"); + Properties props = null; - String defaultsPath = joinPath(appI18nPath, resourceName); - String propertiesPath = joinPath(themeI18nPath, resourceName); - File defaultsFile = locateFile(defaultsPath); - File propertiesFile = locateFile(propertiesPath); + File defaultsPath = locateFile(joinPath(appI18nPath, resourceName)); + File propertiesPath = locateFile(joinPath(themeI18nPath, resourceName)); - if ((defaultsFile == null) && (propertiesFile == null)) { - throw new FileNotFoundException("Property file not found at '" - + defaultsPath + "' or '" + propertiesPath + "'"); - } - - if (defaultsFile != null) { - log.debug("Loading bundle '" + bundleName + "' defaults from '" - + defaultsPath + "'"); - FileInputStream stream = new FileInputStream(defaultsFile); - Reader reader = new InputStreamReader(stream, "UTF-8"); - try { - this.defaults.load(reader); - } finally { - reader.close(); + props = loadProperties(props, defaultsPath); + if (appPrefixes != null && appPrefixes.size() > 0) { + for (String appPrefix : appPrefixes) { + props = loadProperties(props, locateFile(joinPath(appI18nPath, (appPrefix + resourceName)))); } } - if (propertiesFile != null) { - log.debug("Loading bundle '" + bundleName + "' overrides from '" - + propertiesPath + "'"); - FileInputStream stream = new FileInputStream(propertiesFile); - Reader reader = new InputStreamReader(stream, "UTF-8"); - try { - this.properties.load(reader); - } finally { - reader.close(); - } + props = loadProperties(props, propertiesPath); + if (props == null) { + throw new FileNotFoundException("Property file not found at '" + defaultsPath + "' or '" + propertiesPath + "'"); } + props = loadProperties(props, locateFile(joinPath(appI18nPath, "local_" + resourceName))); + + return props; + } + + private Properties loadProperties(Properties defProps, File file) throws IOException { + if (file == null || !file.isFile()) { + return defProps; + } + + Properties props = null; + if (defProps != null) { + props = new Properties(defProps); + } else { + props = new Properties(); + } + + log.debug("Loading bundle '" + bundleName + "' defaults from '" + file + "'"); + FileInputStream stream = new FileInputStream(file); + Reader reader = new InputStreamReader(stream, "UTF-8"); + try { + props.load(reader); + } finally { + reader.close(); + } + + if (props.size() > 0) { + return props; + } + + return defProps; } private void loadReferencedFiles() throws IOException { From 62c2a0614ad0f215d191456347e53168f0a64972 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Wed, 30 Aug 2017 19:51:21 +0100 Subject: [PATCH 11/90] Upgrade to latest Jena 3.4.0 --- .../mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java | 7 ++++++- .../vitro/webapp/dao/jena/RDFServiceDatasetGraph.java | 7 ++++++- dependencies/pom.xml | 8 ++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java index ea30dbf27..5898d1ff4 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java @@ -56,7 +56,12 @@ public class RDFServiceDataset implements Dataset { return RDFServiceGraph.createRDFServiceModel(g.getDefaultGraph()); } - @Override + @Override + public Model getUnionModel() { + return RDFServiceGraph.createRDFServiceModel(g.getUnionGraph()); + } + + @Override public Lock getLock() { return g.getLock(); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java index fed31166c..4c9892133 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java @@ -259,7 +259,12 @@ public class RDFServiceDatasetGraph implements DatasetGraph { return graph; } } - + + @Override + public RDFServiceGraph getUnionGraph() { + return defaultGraph; + } + private boolean supportsTransactions(Graph graph) { return (graph.getTransactionHandler() != null && graph.getTransactionHandler().transactionsSupported()); diff --git a/dependencies/pom.xml b/dependencies/pom.xml index cbe488523..5583e87e9 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -222,22 +222,22 @@ org.apache.jena jena-arq - 3.3.0 + 3.4.0 org.apache.jena jena-core - 3.3.0 + 3.4.0 org.apache.jena jena-sdb - 3.3.0 + 3.4.0 org.apache.jena jena-tdb - 3.3.0 + 3.4.0 org.apache.solr From 3475f90fb4c9626f0fac724d5ba2cbde59921e0a Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Wed, 30 Aug 2017 19:56:10 +0100 Subject: [PATCH 12/90] Update to latest jenatools --- home/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/pom.xml b/home/pom.xml index 0a5802f25..38f3716b9 100644 --- a/home/pom.xml +++ b/home/pom.xml @@ -69,13 +69,13 @@ org.vivoweb jena2tools - 1.0.1 + 1.1.1 true org.vivoweb jena3tools - 1.0.1 + 1.1.1 true From 3f655b740866b6ac835b1b70b7f33839baffa2e7 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Wed, 30 Aug 2017 22:51:33 +0100 Subject: [PATCH 13/90] Adjust all integer types that can be stored differently in TDB --- .../impl/jena/tdb/RDFServiceTDB.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/jena/tdb/RDFServiceTDB.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/jena/tdb/RDFServiceTDB.java index b2f0995d1..89843a11f 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/jena/tdb/RDFServiceTDB.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/jena/tdb/RDFServiceTDB.java @@ -208,7 +208,7 @@ public class RDFServiceTDB extends RDFServiceJena { ModelSerializationFormat serializationFormat) throws RDFServiceException { return super.isEquivalentGraph(graphURI, - adjustForNonNegativeIntegers(serializedGraph), + adjustForIntegers(serializedGraph), serializationFormat); } @@ -231,25 +231,38 @@ public class RDFServiceTDB extends RDFServiceJena { } /** - * Convert all of the references to "nonNegativeInteger" to "integer" in - * this serialized graph. - * - * This isn't rigorous: it could fail if another property contained the text - * "nonNegativeInteger" in its name, or if that text were used as part of a - * string literal. If that happens before this TDB bug is fixed, we'll need - * to improve this method. - * + * Convert all of the references to integer compatible type to "integer" in the serialized graph. + * + * TDB converts every valid literal that is compatible with xsd:integer to xsd:integer. + * + * This assumes that every literal has been typed validly. But if the type / lexical value aren't matched, + * you've probably got bigger problems. + * * It also isn't scalable: if we wanted real scalability, we would write to * a temporary file as we converted. */ - private InputStream adjustForNonNegativeIntegers(InputStream serializedGraph) + private InputStream adjustForIntegers(InputStream serializedGraph) throws RDFServiceException { try { String raw = IOUtils.toString(serializedGraph, "UTF-8"); - String modified = raw.replace("nonNegativeInteger", "integer"); + String modified = raw; + modified = modified.replaceAll(integerPattern, "^^"); return new ByteArrayInputStream(modified.getBytes("UTF-8")); } catch (IOException e) { throw new RDFServiceException(e); } } + + private final String integerPattern = + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^" + "|" + + "\\^\\^"; } From 04f61c466f58d2372e806d7f73b4dd781895e053 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Thu, 31 Aug 2017 00:02:57 +0100 Subject: [PATCH 14/90] Fix broken site admin links --- .../freemarker/BaseSiteAdminController.java | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java index dacaa2a4b..2220dbda1 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BaseSiteAdminController.java @@ -41,41 +41,46 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { private static final List siteMaintenanceUrls = new ArrayList<>(); private static final List siteConfigData = new ArrayList<>(); - public static void registerSiteMaintenanceUrl(String key, String url, AuthorizationRequest permission) { + public static void registerSiteMaintenanceUrl(String key, String url, ParamMap urlParams, AuthorizationRequest permission) { AdminUrl adminUrl = new AdminUrl(); adminUrl.key = key; adminUrl.url = url; + adminUrl.urlParams = urlParams; adminUrl.permission = permission; siteMaintenanceUrls.add(adminUrl); } - public static void registerSiteConfigData(String key, String url, AuthorizationRequest permission) { + public static void registerSiteConfigData(String key, String url, ParamMap urlParams, AuthorizationRequest permission) { AdminUrl adminUrl = new AdminUrl(); adminUrl.key = key; adminUrl.url = url; + adminUrl.urlParams = urlParams; adminUrl.permission = permission; siteConfigData.add(adminUrl); } static { - registerSiteMaintenanceUrl("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences"), SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION); - registerSiteMaintenanceUrl("rebuildSearchIndex", UrlBuilder.getUrl("/SearchIndex"), IndexController.REQUIRED_ACTIONS); - registerSiteMaintenanceUrl("startupStatus", UrlBuilder.getUrl("/startupStatus"), SimplePermission.SEE_STARTUP_STATUS.ACTION); - registerSiteMaintenanceUrl("restrictLogins", UrlBuilder.getUrl("/admin/restrictLogins"), SimplePermission.LOGIN_DURING_MAINTENANCE.ACTION); - registerSiteMaintenanceUrl("activateDeveloperPanel", "javascript:new DeveloperPanel(developerAjaxUrl).setupDeveloperPanel({developer_enabled: true});", SimplePermission.ENABLE_DEVELOPER_PANEL.ACTION); + registerSiteMaintenanceUrl("recomputeInferences", "/RecomputeInferences", null, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION); + registerSiteMaintenanceUrl("rebuildSearchIndex", "/SearchIndex", null, IndexController.REQUIRED_ACTIONS); + registerSiteMaintenanceUrl("startupStatus", "/startupStatus", null, SimplePermission.SEE_STARTUP_STATUS.ACTION); + registerSiteMaintenanceUrl("restrictLogins", "/admin/restrictLogins", null, SimplePermission.LOGIN_DURING_MAINTENANCE.ACTION); + registerSiteMaintenanceUrl("activateDeveloperPanel", "javascript:new DeveloperPanel(developerAjaxUrl).setupDeveloperPanel({developer_enabled: true});", null, SimplePermission.ENABLE_DEVELOPER_PANEL.ACTION); + + registerSiteConfigData("userAccounts", "/accountsAdmin", null, SimplePermission.MANAGE_USER_ACCOUNTS.ACTION); + registerSiteConfigData("manageProxies", "/manageProxies", null, SimplePermission.MANAGE_PROXIES.ACTION); + + registerSiteConfigData("siteInfo", "/editForm", new ParamMap(new String[] {"controller", "ApplicationBean"}), SimplePermission.EDIT_SITE_INFORMATION.ACTION); - registerSiteConfigData("userAccounts", UrlBuilder.getUrl("/accountsAdmin"), SimplePermission.MANAGE_USER_ACCOUNTS.ACTION); - registerSiteConfigData("manageProxies", UrlBuilder.getUrl("/manageProxies"), SimplePermission.MANAGE_PROXIES.ACTION); - registerSiteConfigData("siteInfo", UrlBuilder.getUrl("/editForm", "controller", "ApplicationBean"), SimplePermission.EDIT_SITE_INFORMATION.ACTION); //TODO: Add specific permissions for page management - registerSiteConfigData("menuManagement", UrlBuilder.getUrl("/individual", + registerSiteConfigData("menuManagement", "/individual", new ParamMap(new String[] { "uri", "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#DefaultMenu", - "switchToDisplayModel", "true"), SimplePermission.MANAGE_MENUS.ACTION); - registerSiteConfigData("pageManagement", UrlBuilder.getUrl("/pageList"), SimplePermission.MANAGE_MENUS.ACTION); + "switchToDisplayModel", "true" }), SimplePermission.MANAGE_MENUS.ACTION); + + registerSiteConfigData("pageManagement", "/pageList", null, SimplePermission.MANAGE_MENUS.ACTION); } @Override @@ -108,7 +113,15 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { for (AdminUrl adminUrl : siteMaintenanceUrls) { if (adminUrl.permission == null || PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION)) { - urls.put(adminUrl.key, adminUrl.url); + if (adminUrl.url.startsWith("javascript:")) { + urls.put(adminUrl.key, adminUrl.url); + } else { + if (adminUrl.urlParams != null) { + urls.put(adminUrl.key, UrlBuilder.getUrl(adminUrl.url, adminUrl.urlParams)); + } else { + urls.put(adminUrl.key, UrlBuilder.getUrl(adminUrl.url)); + } + } } } @@ -163,7 +176,15 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { for (AdminUrl adminUrl : siteConfigData) { if (adminUrl.permission == null || PolicyHelper.isAuthorizedForActions(vreq, SimplePermission.USE_MISCELLANEOUS_ADMIN_PAGES.ACTION)) { - data.put(adminUrl.key, adminUrl.url); + if (adminUrl.url.startsWith("javascript:")) { + data.put(adminUrl.key, adminUrl.url); + } else { + if (adminUrl.urlParams != null) { + data.put(adminUrl.key, UrlBuilder.getUrl(adminUrl.url, adminUrl.urlParams)); + } else { + data.put(adminUrl.key, UrlBuilder.getUrl(adminUrl.url)); + } + } } } @@ -230,6 +251,7 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet { final static class AdminUrl { String key; String url; + ParamMap urlParams; AuthorizationRequest permission; } } From 5e6185353d6629f95f40415c1c5f3c2a93c262f7 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 15 Sep 2017 09:33:14 +0100 Subject: [PATCH 15/90] [VIVO-1317] Remove Glassfish JSON library --- .../datatools/dumprestore/DumpNode.java | 11 +++++------ dependencies/pom.xml | 15 +++++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpNode.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpNode.java index 95f4875a8..11dc2b3d9 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpNode.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpNode.java @@ -5,8 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.json.JsonObject; -import javax.json.JsonString; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.jena.atlas.lib.EscapeStr; @@ -16,7 +15,7 @@ import org.apache.jena.atlas.lib.EscapeStr; * able to write to a different format. */ public abstract class DumpNode { - public static DumpNode fromJson(JsonObject json) throws BadNodeException { + public static DumpNode fromJson(JsonNode json) throws BadNodeException { if (json == null) { return new DumpNullNode(); } @@ -74,9 +73,9 @@ public abstract class DumpNode { return (s == null) ? null : EscapeStr.unescapeStr(s); } - private static String getString(JsonObject json, String name) { - JsonString jsString = json.getJsonString(name); - return (jsString == null) ? null : json.getString(name); + private static String getString(JsonNode json, String name) { + JsonNode node = json.get(name); + return node == null ? null : node.asText(); } public abstract String getValue(); diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 5583e87e9..ae9b83161 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -203,6 +203,11 @@ jackson-core 2.7.4 + org.apache.httpcomponents @@ -254,11 +259,6 @@ freemarker 2.3.23 - - org.glassfish - javax.json - 1.0.4 - org.hibernate jtidy @@ -297,11 +297,6 @@ 1.2.1 - javax.mail mail From 06a9360b4322eea017b713e189e5b39b0234b0b0 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 15 Sep 2017 12:48:02 +0100 Subject: [PATCH 16/90] [VIVO-1320] Replace json.org code with Jackson binding --- api/src/main/java/org/json/CDL.java | 261 ---- api/src/main/java/org/json/Cookie.java | 169 --- api/src/main/java/org/json/CookieList.java | 90 -- api/src/main/java/org/json/HTTP.java | 163 --- api/src/main/java/org/json/HTTPTokener.java | 77 - api/src/main/java/org/json/JSONArray.java | 871 ------------ api/src/main/java/org/json/JSONException.java | 27 - api/src/main/java/org/json/JSONObject.java | 1259 ----------------- api/src/main/java/org/json/JSONString.java | 18 - api/src/main/java/org/json/JSONStringer.java | 78 - api/src/main/java/org/json/JSONTokener.java | 460 ------ api/src/main/java/org/json/JSONWriter.java | 318 ----- api/src/main/java/org/json/Test.java | 413 ------ api/src/main/java/org/json/XML.java | 401 ------ api/src/main/java/org/json/XMLTokener.java | 292 ---- dependencies/pom.xml | 5 + 16 files changed, 5 insertions(+), 4897 deletions(-) delete mode 100644 api/src/main/java/org/json/CDL.java delete mode 100644 api/src/main/java/org/json/Cookie.java delete mode 100644 api/src/main/java/org/json/CookieList.java delete mode 100644 api/src/main/java/org/json/HTTP.java delete mode 100644 api/src/main/java/org/json/HTTPTokener.java delete mode 100644 api/src/main/java/org/json/JSONArray.java delete mode 100644 api/src/main/java/org/json/JSONException.java delete mode 100644 api/src/main/java/org/json/JSONObject.java delete mode 100644 api/src/main/java/org/json/JSONString.java delete mode 100644 api/src/main/java/org/json/JSONStringer.java delete mode 100644 api/src/main/java/org/json/JSONTokener.java delete mode 100644 api/src/main/java/org/json/JSONWriter.java delete mode 100644 api/src/main/java/org/json/Test.java delete mode 100644 api/src/main/java/org/json/XML.java delete mode 100644 api/src/main/java/org/json/XMLTokener.java diff --git a/api/src/main/java/org/json/CDL.java b/api/src/main/java/org/json/CDL.java deleted file mode 100644 index 6d9edbf9f..000000000 --- a/api/src/main/java/org/json/CDL.java +++ /dev/null @@ -1,261 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * This provides static methods to convert comma delimited text into a - * JSONArray, and to covert a JSONArray into comma delimited text. Comma - * delimited text is a very popular format for data interchange. It is - * understood by most database, spreadsheet, and organizer programs. - *

    - * Each row of text represents a row in a table or a data record. Each row - * ends with a NEWLINE character. Each row contains one or more values. - * Values are separated by commas. A value can contain any character except - * for comma, unless is is wrapped in single quotes or double quotes. - *

    - * The first row usually contains the names of the columns. - *

    - * A comma delimited list can be converted into a JSONArray of JSONObjects. - * The names for the elements in the JSONObjects can be taken from the names - * in the first row. - * @author JSON.org - * @version 2 - */ -public class CDL { - - /** - * Get the next value. The value can be wrapped in quotes. The value can - * be empty. - * @param x A JSONTokener of the source text. - * @return The value string, or null if empty. - * @throws JSONException if the quoted string is badly formed. - */ - private static String getValue(JSONTokener x) throws JSONException { - char c; - do { - c = x.next(); - } while (c <= ' ' && c != 0); - switch (c) { - case 0: - return null; - case '"': - case '\'': - return x.nextString(c); - case ',': - x.back(); - return ""; - default: - x.back(); - return x.nextTo(','); - } - } - - /** - * Produce a JSONArray of strings from a row of comma delimited values. - * @param x A JSONTokener of the source text. - * @return A JSONArray of strings. - * @throws JSONException - */ - public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { - JSONArray ja = new JSONArray(); - for (;;) { - String value = getValue(x); - if (value == null) { - return null; - } - ja.put(value); - for (;;) { - char c = x.next(); - if (c == ',') { - break; - } - if (c != ' ') { - if (c == '\n' || c == '\r' || c == 0) { - return ja; - } - throw x.syntaxError("Bad character '" + c + "' (" + - (int)c + ")."); - } - } - } - } - - /** - * Produce a JSONObject from a row of comma delimited text, using a - * parallel JSONArray of strings to provides the names of the elements. - * @param names A JSONArray of names. This is commonly obtained from the - * first row of a comma delimited text file using the rowToJSONArray - * method. - * @param x A JSONTokener of the source text. - * @return A JSONObject combining the names and values. - * @throws JSONException - */ - public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) - throws JSONException { - JSONArray ja = rowToJSONArray(x); - return ja != null ? ja.toJSONObject(names) : null; - } - - /** - * Produce a JSONArray of JSONObjects from a comma delimited text string, - * using the first row as a source of names. - * @param string The comma delimited text. - * @return A JSONArray of JSONObjects. - * @throws JSONException - */ - public static JSONArray toJSONArray(String string) throws JSONException { - return toJSONArray(new JSONTokener(string)); - } - - /** - * Produce a JSONArray of JSONObjects from a comma delimited text string, - * using the first row as a source of names. - * @param x The JSONTokener containing the comma delimited text. - * @return A JSONArray of JSONObjects. - * @throws JSONException - */ - public static JSONArray toJSONArray(JSONTokener x) throws JSONException { - return toJSONArray(rowToJSONArray(x), x); - } - - /** - * Produce a JSONArray of JSONObjects from a comma delimited text string - * using a supplied JSONArray as the source of element names. - * @param names A JSONArray of strings. - * @param string The comma delimited text. - * @return A JSONArray of JSONObjects. - * @throws JSONException - */ - public static JSONArray toJSONArray(JSONArray names, String string) - throws JSONException { - return toJSONArray(names, new JSONTokener(string)); - } - - /** - * Produce a JSONArray of JSONObjects from a comma delimited text string - * using a supplied JSONArray as the source of element names. - * @param names A JSONArray of strings. - * @param x A JSONTokener of the source text. - * @return A JSONArray of JSONObjects. - * @throws JSONException - */ - public static JSONArray toJSONArray(JSONArray names, JSONTokener x) - throws JSONException { - if (names == null || names.length() == 0) { - return null; - } - JSONArray ja = new JSONArray(); - for (;;) { - JSONObject jo = rowToJSONObject(names, x); - if (jo == null) { - break; - } - ja.put(jo); - } - if (ja.length() == 0) { - return null; - } - return ja; - } - - - /** - * Produce a comma delimited text row from a JSONArray. Values containing - * the comma character will be quoted. - * @param ja A JSONArray of strings. - * @return A string ending in NEWLINE. - */ - public static String rowToString(JSONArray ja) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < ja.length(); i += 1) { - if (i > 0) { - sb.append(','); - } - Object o = ja.opt(i); - if (o != null) { - String s = o.toString(); - if (s.indexOf(',') >= 0) { - if (s.indexOf('"') >= 0) { - sb.append('\''); - sb.append(s); - sb.append('\''); - } else { - sb.append('"'); - sb.append(s); - sb.append('"'); - } - } else { - sb.append(s); - } - } - } - sb.append('\n'); - return sb.toString(); - - } - - /** - * Produce a comma delimited text from a JSONArray of JSONObjects. The - * first row will be a list of names obtained by inspecting the first - * JSONObject. - * @param ja A JSONArray of JSONObjects. - * @return A comma delimited text. - * @throws JSONException - */ - public static String toString(JSONArray ja) throws JSONException { - JSONObject jo = ja.optJSONObject(0); - if (jo != null) { - JSONArray names = jo.names(); - if (names != null) { - return rowToString(names) + toString(names, ja); - } - } - return null; - } - - /** - * Produce a comma delimited text from a JSONArray of JSONObjects using - * a provided list of names. The list of names is not included in the - * output. - * @param names A JSONArray of strings. - * @param ja A JSONArray of JSONObjects. - * @return A comma delimited text. - * @throws JSONException - */ - public static String toString(JSONArray names, JSONArray ja) - throws JSONException { - if (names == null || names.length() == 0) { - return null; - } - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < ja.length(); i += 1) { - JSONObject jo = ja.optJSONObject(i); - if (jo != null) { - sb.append(rowToString(jo.toJSONArray(names))); - } - } - return sb.toString(); - } -} diff --git a/api/src/main/java/org/json/Cookie.java b/api/src/main/java/org/json/Cookie.java deleted file mode 100644 index b752461fd..000000000 --- a/api/src/main/java/org/json/Cookie.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * Convert a web browser cookie specification to a JSONObject and back. - * JSON and Cookies are both notations for name/value pairs. - * @author JSON.org - * @version 2 - */ -public class Cookie { - - /** - * Produce a copy of a string in which the characters '+', '%', '=', ';' - * and control characters are replaced with "%hh". This is a gentle form - * of URL encoding, attempting to cause as little distortion to the - * string as possible. The characters '=' and ';' are meta characters in - * cookies. By convention, they are escaped using the URL-encoding. This is - * only a convention, not a standard. Often, cookies are expected to have - * encoded values. We encode '=' and ';' because we must. We encode '%' and - * '+' because they are meta characters in URL encoding. - * @param string The source string. - * @return The escaped result. - */ - public static String escape(String string) { - char c; - String s = string.trim(); - StringBuffer sb = new StringBuffer(); - int len = s.length(); - for (int i = 0; i < len; i += 1) { - c = s.charAt(i); - if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') { - sb.append('%'); - sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16)); - sb.append(Character.forDigit((char)(c & 0x0f), 16)); - } else { - sb.append(c); - } - } - return sb.toString(); - } - - - /** - * Convert a cookie specification string into a JSONObject. The string - * will contain a name value pair separated by '='. The name and the value - * will be unescaped, possibly converting '+' and '%' sequences. The - * cookie properties may follow, separated by ';', also represented as - * name=value (except the secure property, which does not have a value). - * The name will be stored under the key "name", and the value will be - * stored under the key "value". This method does not do checking or - * validation of the parameters. It only converts the cookie string into - * a JSONObject. - * @param string The cookie specification string. - * @return A JSONObject containing "name", "value", and possibly other - * members. - * @throws JSONException - */ - public static JSONObject toJSONObject(String string) throws JSONException { - String n; - JSONObject o = new JSONObject(); - Object v; - JSONTokener x = new JSONTokener(string); - o.put("name", x.nextTo('=')); - x.next('='); - o.put("value", x.nextTo(';')); - x.next(); - while (x.more()) { - n = unescape(x.nextTo("=;")); - if (x.next() != '=') { - if (n.equals("secure")) { - v = Boolean.TRUE; - } else { - throw x.syntaxError("Missing '=' in cookie parameter."); - } - } else { - v = unescape(x.nextTo(';')); - x.next(); - } - o.put(n, v); - } - return o; - } - - - /** - * Convert a JSONObject into a cookie specification string. The JSONObject - * must contain "name" and "value" members. - * If the JSONObject contains "expires", "domain", "path", or "secure" - * members, they will be appended to the cookie specification string. - * All other members are ignored. - * @param o A JSONObject - * @return A cookie specification string - * @throws JSONException - */ - public static String toString(JSONObject o) throws JSONException { - StringBuffer sb = new StringBuffer(); - - sb.append(escape(o.getString("name"))); - sb.append("="); - sb.append(escape(o.getString("value"))); - if (o.has("expires")) { - sb.append(";expires="); - sb.append(o.getString("expires")); - } - if (o.has("domain")) { - sb.append(";domain="); - sb.append(escape(o.getString("domain"))); - } - if (o.has("path")) { - sb.append(";path="); - sb.append(escape(o.getString("path"))); - } - if (o.optBoolean("secure")) { - sb.append(";secure"); - } - return sb.toString(); - } - - /** - * Convert {@code %}hh sequences to single characters, and - * convert plus to space. - * @param s A string that may contain - * {@code +} (plus) and - * {@code %}hh sequences. - * @return The unescaped string. - */ - public static String unescape(String s) { - int len = s.length(); - StringBuffer b = new StringBuffer(); - for (int i = 0; i < len; ++i) { - char c = s.charAt(i); - if (c == '+') { - c = ' '; - } else if (c == '%' && i + 2 < len) { - int d = JSONTokener.dehexchar(s.charAt(i + 1)); - int e = JSONTokener.dehexchar(s.charAt(i + 2)); - if (d >= 0 && e >= 0) { - c = (char)(d * 16 + e); - i += 2; - } - } - b.append(c); - } - return b.toString(); - } -} diff --git a/api/src/main/java/org/json/CookieList.java b/api/src/main/java/org/json/CookieList.java deleted file mode 100644 index 30bbb3670..000000000 --- a/api/src/main/java/org/json/CookieList.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.util.Iterator; - -/** - * Convert a web browser cookie list string to a JSONObject and back. - * @author JSON.org - * @version 2 - */ -public class CookieList { - - /** - * Convert a cookie list into a JSONObject. A cookie list is a sequence - * of name/value pairs. The names are separated from the values by '='. - * The pairs are separated by ';'. The names and the values - * will be unescaped, possibly converting '+' and '%' sequences. - * - * To add a cookie to a cooklist, - * cookielistJSONObject.put(cookieJSONObject.getString("name"), - * cookieJSONObject.getString("value")); - * @param string A cookie list string - * @return A JSONObject - * @throws JSONException - */ - public static JSONObject toJSONObject(String string) throws JSONException { - JSONObject o = new JSONObject(); - JSONTokener x = new JSONTokener(string); - while (x.more()) { - String name = Cookie.unescape(x.nextTo('=')); - x.next('='); - o.put(name, Cookie.unescape(x.nextTo(';'))); - x.next(); - } - return o; - } - - - /** - * Convert a JSONObject into a cookie list. A cookie list is a sequence - * of name/value pairs. The names are separated from the values by '='. - * The pairs are separated by ';'. The characters '%', '+', '=', and ';' - * in the names and values are replaced by "%hh". - * @param o A JSONObject - * @return A cookie list string - * @throws JSONException - */ - public static String toString(JSONObject o) throws JSONException { - boolean b = false; - Iterator keys = o.keys(); - String s; - StringBuffer sb = new StringBuffer(); - while (keys.hasNext()) { - s = keys.next().toString(); - if (!o.isNull(s)) { - if (b) { - sb.append(';'); - } - sb.append(Cookie.escape(s)); - sb.append("="); - sb.append(Cookie.escape(o.getString(s))); - b = true; - } - } - return sb.toString(); - } -} diff --git a/api/src/main/java/org/json/HTTP.java b/api/src/main/java/org/json/HTTP.java deleted file mode 100644 index 131676267..000000000 --- a/api/src/main/java/org/json/HTTP.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.util.Iterator; - -/** - * Convert an HTTP header to a JSONObject and back. - * @author JSON.org - * @version 2 - */ -public class HTTP { - - /** Carriage return/line feed. */ - public static final String CRLF = "\r\n"; - - /** - * Convert an HTTP header string into a JSONObject. It can be a request - * header or a response header. A request header will contain - * {@code { - * Method: "POST" (for example), - * "Request-URI": "/" (for example), - * "HTTP-Version": "HTTP/1.1" (for example) - * }} - * A response header will contain - * {@code { - * "HTTP-Version": "HTTP/1.1" (for example), - * "Status-Code": "200" (for example), - * "Reason-Phrase": "OK" (for example) - * }} - * In addition, the other parameters in the header will be captured, using - * the HTTP field names as JSON names, so that {@code - * Date: Sun, 26 May 2002 18:06:04 GMT - * Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s - * Cache-Control: no-cache} - * become - * {@code {... - * Date: "Sun, 26 May 2002 18:06:04 GMT", - * Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s", - * "Cache-Control": "no-cache", - * ...}} - * It does no further checking or conversion. It does not parse dates. - * It does not do '%' transforms on URLs. - * @param string An HTTP header string. - * @return A JSONObject containing the elements and attributes - * of the XML string. - * @throws JSONException - */ - public static JSONObject toJSONObject(String string) throws JSONException { - JSONObject o = new JSONObject(); - HTTPTokener x = new HTTPTokener(string); - String t; - - t = x.nextToken(); - if (t.toUpperCase().startsWith("HTTP")) { - -// Response - - o.put("HTTP-Version", t); - o.put("Status-Code", x.nextToken()); - o.put("Reason-Phrase", x.nextTo('\0')); - x.next(); - - } else { - -// Request - - o.put("Method", t); - o.put("Request-URI", x.nextToken()); - o.put("HTTP-Version", x.nextToken()); - } - -// Fields - - while (x.more()) { - String name = x.nextTo(':'); - x.next(':'); - o.put(name, x.nextTo('\0')); - x.next(); - } - return o; - } - - - /** - * Convert a JSONObject into an HTTP header. A request header must contain - *

    {
    -     *    Method: "POST" (for example),
    -     *    "Request-URI": "/" (for example),
    -     *    "HTTP-Version": "HTTP/1.1" (for example)
    -     * }
    - * A response header must contain - *
    {
    -     *    "HTTP-Version": "HTTP/1.1" (for example),
    -     *    "Status-Code": "200" (for example),
    -     *    "Reason-Phrase": "OK" (for example)
    -     * }
    - * Any other members of the JSONObject will be output as HTTP fields. - * The result will end with two CRLF pairs. - * @param o A JSONObject - * @return An HTTP header string. - * @throws JSONException if the object does not contain enough - * information. - */ - public static String toString(JSONObject o) throws JSONException { - Iterator keys = o.keys(); - String s; - StringBuffer sb = new StringBuffer(); - if (o.has("Status-Code") && o.has("Reason-Phrase")) { - sb.append(o.getString("HTTP-Version")); - sb.append(' '); - sb.append(o.getString("Status-Code")); - sb.append(' '); - sb.append(o.getString("Reason-Phrase")); - } else if (o.has("Method") && o.has("Request-URI")) { - sb.append(o.getString("Method")); - sb.append(' '); - sb.append('"'); - sb.append(o.getString("Request-URI")); - sb.append('"'); - sb.append(' '); - sb.append(o.getString("HTTP-Version")); - } else { - throw new JSONException("Not enough material for an HTTP header."); - } - sb.append(CRLF); - while (keys.hasNext()) { - s = keys.next().toString(); - if (!s.equals("HTTP-Version") && !s.equals("Status-Code") && - !s.equals("Reason-Phrase") && !s.equals("Method") && - !s.equals("Request-URI") && !o.isNull(s)) { - sb.append(s); - sb.append(": "); - sb.append(o.getString(s)); - sb.append(CRLF); - } - } - sb.append(CRLF); - return sb.toString(); - } -} diff --git a/api/src/main/java/org/json/HTTPTokener.java b/api/src/main/java/org/json/HTTPTokener.java deleted file mode 100644 index f2a6ba72b..000000000 --- a/api/src/main/java/org/json/HTTPTokener.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * The HTTPTokener extends the JSONTokener to provide additional methods - * for the parsing of HTTP headers. - * @author JSON.org - * @version 2 - */ -public class HTTPTokener extends JSONTokener { - - /** - * Construct an XMLTokener from a string. - * @param s A source string. - */ - public HTTPTokener(String s) { - super(s); - } - - - /** - * Get the next token or string. This is used in parsing HTTP headers. - * @throws JSONException - * @return A String. - */ - public String nextToken() throws JSONException { - char c; - char q; - StringBuffer sb = new StringBuffer(); - do { - c = next(); - } while (Character.isWhitespace(c)); - if (c == '"' || c == '\'') { - q = c; - for (;;) { - c = next(); - if (c < ' ') { - throw syntaxError("Unterminated string."); - } - if (c == q) { - return sb.toString(); - } - sb.append(c); - } - } - for (;;) { - if (c == 0 || Character.isWhitespace(c)) { - return sb.toString(); - } - sb.append(c); - c = next(); - } - } -} diff --git a/api/src/main/java/org/json/JSONArray.java b/api/src/main/java/org/json/JSONArray.java deleted file mode 100644 index b5b59eac5..000000000 --- a/api/src/main/java/org/json/JSONArray.java +++ /dev/null @@ -1,871 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -/** - * A JSONArray is an ordered sequence of values. Its external text form is a - * string wrapped in square brackets with commas separating the values. The - * internal form is an object having {@code get} and {@code opt} - * methods for accessing the values by index, and {@code put} methods for - * adding or replacing values. The values can be any of these types: - * {@code Boolean}, {@code JSONArray}, {@code JSONObject}, - * {@code Number}, {@code String}, or the - * {@code JSONObject.NULL object}. - *

    - * The constructor can convert a JSON text into a Java object. The - * {@code toString} method converts to JSON text. - *

    - * A {@code get} method returns a value if one can be found, and throws an - * exception if one cannot be found. An {@code opt} method returns a - * default value instead of throwing an exception, and so is useful for - * obtaining optional values. - *

    - * The generic {@code get()} and {@code opt()} methods return an - * object which you can cast or query for type. There are also typed - * {@code get} and {@code opt} methods that do type checking and type - * coersion for you. - *

    - * The texts produced by the {@code toString} methods strictly conform to - * JSON syntax rules. The constructors are more forgiving in the texts they will - * accept: - *

      - *
    • An extra {@code ,} (comma) may appear just - * before the closing bracket.
    • - *
    • The {@code null} value will be inserted when there - * is {@code ,} (comma) elision.
    • - *
    • Strings may be quoted with {@code '} (single - * quote).
    • - *
    • Strings do not need to be quoted at all if they do not begin with a quote - * or single quote, and if they do not contain leading or trailing spaces, - * and if they do not contain any of these characters: - * {@code { } [ ] / \ : , = ; #} and if they do not look like numbers - * and if they are not the reserved words {@code true}, - * {@code false}, or {@code null}.
    • - *
    • Values can be separated by {@code ;} (semicolon) as - * well as by {@code ,} (comma).
    • - *
    • Numbers may have the {@code 0-} (octal) or - * {@code 0x-} (hex) prefix.
    • - *
    • Comments written in the slashshlash, slashstar, and hash conventions - * will be ignored.
    • - *
    - - * @author JSON.org - * @version 2 - */ -public class JSONArray { - - - /** - * The arrayList where the JSONArray's properties are kept. - */ - private ArrayList myArrayList; - - - /** - * Construct an empty JSONArray. - */ - public JSONArray() { - this.myArrayList = new ArrayList(); - } - - /** - * Construct a JSONArray from a JSONTokener. - * @param x A JSONTokener - * @throws JSONException If there is a syntax error. - */ - public JSONArray(JSONTokener x) throws JSONException { - this(); - if (x.nextClean() != '[') { - throw x.syntaxError("A JSONArray text must start with '['"); - } - if (x.nextClean() == ']') { - return; - } - x.back(); - for (;;) { - if (x.nextClean() == ',') { - x.back(); - this.myArrayList.add(null); - } else { - x.back(); - this.myArrayList.add(x.nextValue()); - } - switch (x.nextClean()) { - case ';': - case ',': - if (x.nextClean() == ']') { - return; - } - x.back(); - break; - case ']': - return; - default: - throw x.syntaxError("Expected a ',' or ']'"); - } - } - } - - - /** - * Construct a JSONArray from a source sJSON text. - * @param string A string that begins with - * {@code [} (left bracket) - * and ends with {@code ]} (right bracket). - * @throws JSONException If there is a syntax error. - */ - public JSONArray(String string) throws JSONException { - this(new JSONTokener(string)); - } - - - /** - * Construct a JSONArray from a Collection. - * @param collection A Collection. - */ - public JSONArray(Collection collection) { - this.myArrayList = (collection == null) ? - new ArrayList() : - new ArrayList(collection); - } - - - /** - * Get the object value associated with an index. - * @param index - * The index must be between 0 and length() - 1. - * @return An object value. - * @throws JSONException If there is no value for the index. - */ - public Object get(int index) throws JSONException { - Object o = opt(index); - if (o == null) { - throw new JSONException("JSONArray[" + index + "] not found."); - } - return o; - } - - - /** - * Get the boolean value associated with an index. - * The string values "true" and "false" are converted to boolean. - * - * @param index The index must be between 0 and length() - 1. - * @return The truth. - * @throws JSONException If there is no value for the index or if the - * value is not convertable to boolean. - */ - public boolean getBoolean(int index) throws JSONException { - Object o = get(index); - if (o.equals(Boolean.FALSE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("false"))) { - return false; - } else if (o.equals(Boolean.TRUE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("true"))) { - return true; - } - throw new JSONException("JSONArray[" + index + "] is not a Boolean."); - } - - - /** - * Get the double value associated with an index. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - * @throws JSONException If the key is not found or if the value cannot - * be converted to a number. - */ - public double getDouble(int index) throws JSONException { - Object o = get(index); - try { - return o instanceof Number ? - ((Number)o).doubleValue() : - Double.valueOf((String)o).doubleValue(); - } catch (Exception e) { - throw new JSONException("JSONArray[" + index + - "] is not a number."); - } - } - - - /** - * Get the int value associated with an index. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - * @throws JSONException If the key is not found or if the value cannot - * be converted to a number. - * if the value cannot be converted to a number. - */ - public int getInt(int index) throws JSONException { - Object o = get(index); - return o instanceof Number ? - ((Number)o).intValue() : (int)getDouble(index); - } - - - /** - * Get the JSONArray associated with an index. - * @param index The index must be between 0 and length() - 1. - * @return A JSONArray value. - * @throws JSONException If there is no value for the index. or if the - * value is not a JSONArray - */ - public JSONArray getJSONArray(int index) throws JSONException { - Object o = get(index); - if (o instanceof JSONArray) { - return (JSONArray)o; - } - throw new JSONException("JSONArray[" + index + - "] is not a JSONArray."); - } - - - /** - * Get the JSONObject associated with an index. - * @param index subscript - * @return A JSONObject value. - * @throws JSONException If there is no value for the index or if the - * value is not a JSONObject - */ - public JSONObject getJSONObject(int index) throws JSONException { - Object o = get(index); - if (o instanceof JSONObject) { - return (JSONObject)o; - } - throw new JSONException("JSONArray[" + index + - "] is not a JSONObject."); - } - - - /** - * Get the long value associated with an index. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - * @throws JSONException If the key is not found or if the value cannot - * be converted to a number. - */ - public long getLong(int index) throws JSONException { - Object o = get(index); - return o instanceof Number ? - ((Number)o).longValue() : (long)getDouble(index); - } - - - /** - * Get the string associated with an index. - * @param index The index must be between 0 and length() - 1. - * @return A string value. - * @throws JSONException If there is no value for the index. - */ - public String getString(int index) throws JSONException { - return get(index).toString(); - } - - - /** - * Determine if the value is null. - * @param index The index must be between 0 and length() - 1. - * @return true if the value at the index is null, or if there is no value. - */ - public boolean isNull(int index) { - return JSONObject.NULL.equals(opt(index)); - } - - - /** - * Make a string from the contents of this JSONArray. The - * {@code separator} string is inserted between each element. - * Warning: This method assumes that the data structure is acyclical. - * @param separator A string that will be inserted between the elements. - * @return a string. - * @throws JSONException If the array contains an invalid number. - */ - public String join(String separator) throws JSONException { - int len = length(); - StringBuffer sb = new StringBuffer(); - - for (int i = 0; i < len; i += 1) { - if (i > 0) { - sb.append(separator); - } - sb.append(JSONObject.valueToString(this.myArrayList.get(i))); - } - return sb.toString(); - } - - - /** - * Get the number of elements in the JSONArray, included nulls. - * - * @return The length (or size). - */ - public int length() { - return this.myArrayList.size(); - } - - - /** - * Get the optional object value associated with an index. - * @param index The index must be between 0 and length() - 1. - * @return An object value, or null if there is no - * object at that index. - */ - public Object opt(int index) { - return (index < 0 || index >= length()) ? - null : this.myArrayList.get(index); - } - - - /** - * Get the optional boolean value associated with an index. - * It returns false if there is no value at that index, - * or if the value is not Boolean.TRUE or the String "true". - * - * @param index The index must be between 0 and length() - 1. - * @return The truth. - */ - public boolean optBoolean(int index) { - return optBoolean(index, false); - } - - - /** - * Get the optional boolean value associated with an index. - * It returns the defaultValue if there is no value at that index or if - * it is not a Boolean or the String "true" or "false" (case insensitive). - * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue A boolean default. - * @return The truth. - */ - public boolean optBoolean(int index, boolean defaultValue) { - try { - return getBoolean(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional double value associated with an index. - * NaN is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - */ - public double optDouble(int index) { - return optDouble(index, Double.NaN); - } - - - /** - * Get the optional double value associated with an index. - * The defaultValue is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index subscript - * @param defaultValue The default value. - * @return The value. - */ - public double optDouble(int index, double defaultValue) { - try { - return getDouble(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional int value associated with an index. - * Zero is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - */ - public int optInt(int index) { - return optInt(index, 0); - } - - - /** - * Get the optional int value associated with an index. - * The defaultValue is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. - * @return The value. - */ - public int optInt(int index, int defaultValue) { - try { - return getInt(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional JSONArray associated with an index. - * @param index subscript - * @return A JSONArray value, or null if the index has no value, - * or if the value is not a JSONArray. - */ - public JSONArray optJSONArray(int index) { - Object o = opt(index); - return o instanceof JSONArray ? (JSONArray)o : null; - } - - - /** - * Get the optional JSONObject associated with an index. - * Null is returned if the key is not found, or null if the index has - * no value, or if the value is not a JSONObject. - * - * @param index The index must be between 0 and length() - 1. - * @return A JSONObject value. - */ - public JSONObject optJSONObject(int index) { - Object o = opt(index); - return o instanceof JSONObject ? (JSONObject)o : null; - } - - - /** - * Get the optional long value associated with an index. - * Zero is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - */ - public long optLong(int index) { - return optLong(index, 0); - } - - - /** - * Get the optional long value associated with an index. - * The defaultValue is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. - * @return The value. - */ - public long optLong(int index, long defaultValue) { - try { - return getLong(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional string value associated with an index. It returns an - * empty string if there is no value at that index. If the value - * is not a string and is not null, then it is coverted to a string. - * - * @param index The index must be between 0 and length() - 1. - * @return A String value. - */ - public String optString(int index) { - return optString(index, ""); - } - - - /** - * Get the optional string associated with an index. - * The defaultValue is returned if the key is not found. - * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. - * @return A String value. - */ - public String optString(int index, String defaultValue) { - Object o = opt(index); - return o != null ? o.toString() : defaultValue; - } - - - /** - * Append a boolean value. This increases the array's length by one. - * - * @param value A boolean value. - * @return this. - */ - public JSONArray put(boolean value) { - put(value ? Boolean.TRUE : Boolean.FALSE); - return this; - } - - - /** - * Put a value in the JSONArray, where the value will be a - * JSONArray which is produced from a Collection. - * @param value A Collection value. - * @return this. - */ - public JSONArray put(Collection value) { - put(new JSONArray(value)); - return this; - } - - - /** - * Append a double value. This increases the array's length by one. - * - * @param value A double value. - * @throws JSONException if the value is not finite. - * @return this. - */ - public JSONArray put(double value) throws JSONException { - Double d = new Double(value); - JSONObject.testValidity(d); - put(d); - return this; - } - - - /** - * Append an int value. This increases the array's length by one. - * - * @param value An int value. - * @return this. - */ - public JSONArray put(int value) { - put(new Integer(value)); - return this; - } - - - /** - * Append an long value. This increases the array's length by one. - * - * @param value A long value. - * @return this. - */ - public JSONArray put(long value) { - put(new Long(value)); - return this; - } - - - /** - * Put a value in the JSONArray, where the value will be a - * JSONObject which is produced from a Map. - * @param value A Map value. - * @return this. - */ - public JSONArray put(Map value) { - put(new JSONObject(value)); - return this; - } - - - /** - * Append an object value. This increases the array's length by one. - * @param value An object value. The value should be a - * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the - * JSONObject.NULL object. - * @return this. - */ - public JSONArray put(Object value) { - this.myArrayList.add(value); - return this; - } - - - /** - * Put or replace a boolean value in the JSONArray. If the index is greater - * than the length of the JSONArray, then null elements will be added as - * necessary to pad it out. - * @param index The subscript. - * @param value A boolean value. - * @return this. - * @throws JSONException If the index is negative. - */ - public JSONArray put(int index, boolean value) throws JSONException { - put(index, value ? Boolean.TRUE : Boolean.FALSE); - return this; - } - - - /** - * Put a value in the JSONArray, where the value will be a - * JSONArray which is produced from a Collection. - * @param index The subscript. - * @param value A Collection value. - * @return this. - * @throws JSONException If the index is negative or if the value is - * not finite. - */ - public JSONArray put(int index, Collection value) throws JSONException { - put(index, new JSONArray(value)); - return this; - } - - - /** - * Put or replace a double value. If the index is greater than the length of - * the JSONArray, then null elements will be added as necessary to pad - * it out. - * @param index The subscript. - * @param value A double value. - * @return this. - * @throws JSONException If the index is negative or if the value is - * not finite. - */ - public JSONArray put(int index, double value) throws JSONException { - put(index, new Double(value)); - return this; - } - - - /** - * Put or replace an int value. If the index is greater than the length of - * the JSONArray, then null elements will be added as necessary to pad - * it out. - * @param index The subscript. - * @param value An int value. - * @return this. - * @throws JSONException If the index is negative. - */ - public JSONArray put(int index, int value) throws JSONException { - put(index, new Integer(value)); - return this; - } - - - /** - * Put or replace a long value. If the index is greater than the length of - * the JSONArray, then null elements will be added as necessary to pad - * it out. - * @param index The subscript. - * @param value A long value. - * @return this. - * @throws JSONException If the index is negative. - */ - public JSONArray put(int index, long value) throws JSONException { - put(index, new Long(value)); - return this; - } - - - /** - * Put a value in the JSONArray, where the value will be a - * JSONObject which is produced from a Map. - * @param index The subscript. - * @param value The Map value. - * @return this. - * @throws JSONException If the index is negative or if the the value is - * an invalid number. - */ - public JSONArray put(int index, Map value) throws JSONException { - put(index, new JSONObject(value)); - return this; - } - - - /** - * Put or replace an object value in the JSONArray. If the index is greater - * than the length of the JSONArray, then null elements will be added as - * necessary to pad it out. - * @param index The subscript. - * @param value The value to put into the array. The value should be a - * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the - * JSONObject.NULL object. - * @return this. - * @throws JSONException If the index is negative or if the the value is - * an invalid number. - */ - public JSONArray put(int index, Object value) throws JSONException { - JSONObject.testValidity(value); - if (index < 0) { - throw new JSONException("JSONArray[" + index + "] not found."); - } - if (index < length()) { - this.myArrayList.set(index, value); - } else { - while (index != length()) { - put(JSONObject.NULL); - } - put(value); - } - return this; - } - - - /** - * Produce a JSONObject by combining a JSONArray of names with the values - * of this JSONArray. - * @param names A JSONArray containing a list of key strings. These will be - * paired with the values. - * @return A JSONObject, or null if there are no names or if this JSONArray - * has no values. - * @throws JSONException If any of the names are null. - */ - public JSONObject toJSONObject(JSONArray names) throws JSONException { - if (names == null || names.length() == 0 || length() == 0) { - return null; - } - JSONObject jo = new JSONObject(); - for (int i = 0; i < names.length(); i += 1) { - jo.put(names.getString(i), this.opt(i)); - } - return jo; - } - - - /** - * Make a JSON text of this JSONArray. For compactness, no - * unnecessary whitespace is added. If it is not possible to produce a - * syntactically correct JSON text then null will be returned instead. This - * could occur if the array contains an invalid number. - *

    - * Warning: This method assumes that the data structure is acyclical. - * - * @return a printable, displayable, transmittable - * representation of the array. - */ - public String toString() { - try { - return '[' + join(",") + ']'; - } catch (Exception e) { - return null; - } - } - - - /** - * Make a prettyprinted JSON text of this JSONArray. - * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with {@code [} (left bracket) and ending - * with {@code ]} (right bracket). - * @throws JSONException - */ - public String toString(int indentFactor) throws JSONException { - return toString(indentFactor, 0); - } - - - /** - * Make a prettyprinted JSON text of this JSONArray. - * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @param indent The indention of the top level. - * @return a printable, displayable, transmittable - * representation of the array. - * @throws JSONException - */ - String toString(int indentFactor, int indent) throws JSONException { - int len = length(); - if (len == 0) { - return "[]"; - } - int i; - StringBuffer sb = new StringBuffer("["); - if (len == 1) { - sb.append(JSONObject.valueToString(this.myArrayList.get(0), - indentFactor, indent)); - } else { - int newindent = indent + indentFactor; - sb.append('\n'); - for (i = 0; i < len; i += 1) { - if (i > 0) { - sb.append(",\n"); - } - for (int j = 0; j < newindent; j += 1) { - sb.append(' '); - } - sb.append(JSONObject.valueToString(this.myArrayList.get(i), - indentFactor, newindent)); - } - sb.append('\n'); - for (i = 0; i < indent; i += 1) { - sb.append(' '); - } - } - sb.append(']'); - return sb.toString(); - } - - - /** - * Write the contents of the JSONArray as JSON text to a writer. - * For compactness, no whitespace is added. - *

    - * Warning: This method assumes that the data structure is acyclical. - * - * @return The writer. - * @throws JSONException - */ - public Writer write(Writer writer) throws JSONException { - try { - boolean b = false; - int len = length(); - - writer.write('['); - - for (int i = 0; i < len; i += 1) { - if (b) { - writer.write(','); - } - Object v = this.myArrayList.get(i); - if (v instanceof JSONObject) { - ((JSONObject)v).write(writer); - } else if (v instanceof JSONArray) { - ((JSONArray)v).write(writer); - } else { - writer.write(JSONObject.valueToString(v)); - } - b = true; - } - writer.write(']'); - return writer; - } catch (IOException e) { - throw new JSONException(e); - } - } -} \ No newline at end of file diff --git a/api/src/main/java/org/json/JSONException.java b/api/src/main/java/org/json/JSONException.java deleted file mode 100644 index 535168f66..000000000 --- a/api/src/main/java/org/json/JSONException.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.json; - -/** - * The JSONException is thrown by the JSON.org classes then things are amiss. - * @author JSON.org - * @version 2 - */ -public class JSONException extends Exception { - private Throwable cause; - - /** - * Constructs a JSONException with an explanatory message. - * @param message Detail about the reason for the exception. - */ - public JSONException(String message) { - super(message); - } - - public JSONException(Throwable t) { - super(t.getMessage()); - this.cause = t; - } - - public Throwable getCause() { - return this.cause; - } -} diff --git a/api/src/main/java/org/json/JSONObject.java b/api/src/main/java/org/json/JSONObject.java deleted file mode 100644 index 89686da77..000000000 --- a/api/src/main/java/org/json/JSONObject.java +++ /dev/null @@ -1,1259 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.util.Collection; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.io.IOException; -import java.io.Writer; - -/** - * A JSONObject is an unordered collection of name/value pairs. Its - * external form is a string wrapped in curly braces with colons between the - * names and values, and commas between the values and names. The internal form - * is an object having {@code get} and {@code opt} methods for - * accessing the values by name, and {@code put} methods for adding or - * replacing values by name. The values can be any of these types: - * {@code Boolean}, {@code JSONArray}, {@code JSONObject}, - * {@code Number}, {@code String}, or the {@code JSONObject.NULL} - * object. A JSONObject constructor can be used to convert an external form - * JSON text into an internal form whose values can be retrieved with the - * {@code get} and {@code opt} methods, or to convert values into a - * JSON text using the {@code put} and {@code toString} methods. - * A {@code get} method returns a value if one can be found, and throws an - * exception if one cannot be found. An {@code opt} method returns a - * default value instead of throwing an exception, and so is useful for - * obtaining optional values. - *

    - * The generic {@code get()} and {@code opt()} methods return an - * object, which you can cast or query for type. There are also typed - * {@code get} and {@code opt} methods that do type checking and type - * coersion for you. - *

    - * The {@code put} methods adds values to an object. For example,

    - *     myString = new JSONObject().put("JSON", "Hello, World!").toString();
    - * produces the string {@code {"JSON": "Hello, World"}}. - *

    - * The texts produced by the {@code toString} methods strictly conform to - * the JSON sysntax rules. - * The constructors are more forgiving in the texts they will accept: - *

      - *
    • An extra {@code ,} (comma) may appear just - * before the closing brace.
    • - *
    • Strings may be quoted with {@code '} (single - * quote).
    • - *
    • Strings do not need to be quoted at all if they do not begin with a quote - * or single quote, and if they do not contain leading or trailing spaces, - * and if they do not contain any of these characters: - * {@code { } [ ] / \ : , = ; #} and if they do not look like numbers - * and if they are not the reserved words {@code true}, - * {@code false}, or {@code null}.
    • - *
    • Keys can be followed by {@code =} or {@code =>} as well as - * by {@code :}.
    • - *
    • Values can be followed by {@code ;} (semicolon) as - * well as by {@code ,} (comma).
    • - *
    • Numbers may have the {@code 0-} (octal) or - * {@code 0x-} (hex) prefix.
    • - *
    • Comments written in the slashshlash, slashstar, and hash conventions - * will be ignored.
    • - *
    - * @author JSON.org - * @version 2 - */ -public class JSONObject { - - /** - * JSONObject.NULL is equivalent to the value that JavaScript calls null, - * whilst Java's null is equivalent to the value that JavaScript calls - * undefined. - */ - private static final class Null { - - /** - * There is only intended to be a single instance of the NULL object, - * so the clone method returns itself. - * @return NULL. - */ - protected final Object clone() { - return this; - } - - - /** - * A Null object is equal to the null value and to itself. - * @param object An object to test for nullness. - * @return true if the object parameter is the JSONObject.NULL object - * or null. - */ - public boolean equals(Object object) { - return object == null || object == this; - } - - - /** - * Get the "null" string value. - * @return The string "null". - */ - public String toString() { - return "null"; - } - } - - - /** - * The hash map where the JSONObject's properties are kept. - */ - private HashMap myHashMap; - - - /** - * It is sometimes more convenient and less ambiguous to have a - * {@code NULL} object than to use Java's {@code null} value. - * {@code JSONObject.NULL.equals(null)} returns {@code true}. - * {@code JSONObject.NULL.toString()} returns {@code "null"}. - */ - public static final Object NULL = new Null(); - - - /** - * Construct an empty JSONObject. - */ - public JSONObject() { - this.myHashMap = new HashMap(); - } - - - /** - * Construct a JSONObject from a subset of another JSONObject. - * An array of strings is used to identify the keys that should be copied. - * Missing keys are ignored. - * @param jo A JSONObject. - * @param sa An array of strings. - * @exception JSONException If a value is a non-finite number. - */ - public JSONObject(JSONObject jo, String[] sa) throws JSONException { - this(); - for (int i = 0; i < sa.length; i += 1) { - putOpt(sa[i], jo.opt(sa[i])); - } - } - - - /** - * Construct a JSONObject from a JSONTokener. - * @param x A JSONTokener object containing the source string. - * @throws JSONException If there is a syntax error in the source string. - */ - public JSONObject(JSONTokener x) throws JSONException { - this(); - char c; - String key; - - if (x.nextClean() != '{') { - throw x.syntaxError("A JSONObject text must begin with '{'"); - } - for (;;) { - c = x.nextClean(); - switch (c) { - case 0: - throw x.syntaxError("A JSONObject text must end with '}'"); - case '}': - return; - default: - x.back(); - key = x.nextValue().toString(); - } - - /* - * The key is followed by ':'. We will also tolerate '=' or '=>'. - */ - - c = x.nextClean(); - if (c == '=') { - if (x.next() != '>') { - x.back(); - } - } else if (c != ':') { - throw x.syntaxError("Expected a ':' after a key"); - } - this.myHashMap.put(key, x.nextValue()); - - /* - * Pairs are separated by ','. We will also tolerate ';'. - */ - - switch (x.nextClean()) { - case ';': - case ',': - if (x.nextClean() == '}') { - return; - } - x.back(); - break; - case '}': - return; - default: - throw x.syntaxError("Expected a ',' or '}'"); - } - } - } - - - /** - * Construct a JSONObject from a Map. - * @param map A map object that can be used to initialize the contents of - * the JSONObject. - */ - public JSONObject(Map map) { - this.myHashMap = (map == null) ? - new HashMap() : - new HashMap(map); - } - - - /** - * Construct a JSONObject from an Object, using reflection to find the - * public members. The resulting JSONObject's keys will be the strings - * from the names array, and the values will be the field values associated - * with those keys in the object. If a key is not found or not visible, - * then it will not be copied into the new JSONObject. - * @param object An object that has fields that should be used to make a - * JSONObject. - * @param names An array of strings, the names of the fields to be used - * from the object. - */ - public JSONObject(Object object, String names[]) { - this(); - Class c = object.getClass(); - for (int i = 0; i < names.length; i += 1) { - try { - String name = names[i]; - Field field = c.getField(name); - Object value = field.get(object); - this.put(name, value); - } catch (Exception e) { - /* forget about it */ - } - } - } - - - /** - * Construct a JSONObject from a string. - * This is the most commonly used JSONObject constructor. - * @param string A string beginning - * with {@code {} (left brace) and ending - * with {@code }} (right brace). - * @exception JSONException If there is a syntax error in the source string. - */ - public JSONObject(String string) throws JSONException { - this(new JSONTokener(string)); - } - - - /** - * Accumulate values under a key. It is similar to the put method except - * that if there is already an object stored under the key then a - * JSONArray is stored under the key to hold all of the accumulated values. - * If there is already a JSONArray, then the new value is appended to it. - * In contrast, the put method replaces the previous value. - * @param key A key string. - * @param value An object to be accumulated under the key. - * @return this. - * @throws JSONException If the value is an invalid number - * or if the key is null. - */ - public JSONObject accumulate(String key, Object value) - throws JSONException { - testValidity(value); - Object o = opt(key); - if (o == null) { - put(key, value); - } else if (o instanceof JSONArray) { - ((JSONArray)o).put(value); - } else { - put(key, new JSONArray().put(o).put(value)); - } - return this; - } - - - /** - * Append values to the array under a key. If the key does not exist in the - * JSONObject, then the key is put in the JSONObject with its value being a - * JSONArray containing the value parameter. If the key was already - * associated with a JSONArray, then the value parameter is appended to it. - * @param key A key string. - * @param value An object to be accumulated under the key. - * @return this. - * @throws JSONException If the key is null or if the current value - * associated with the key is not a JSONArray. - */ - public JSONObject append(String key, Object value) - throws JSONException { - testValidity(value); - Object o = opt(key); - if (o == null) { - put(key, new JSONArray().put(value)); - } else if (o instanceof JSONArray) { - throw new JSONException("JSONObject[" + key + - "] is not a JSONArray."); - } else { - put(key, new JSONArray().put(o).put(value)); - } - return this; - } - - - /** - * Produce a string from a double. The string "null" will be returned if - * the number is not finite. - * @param d A double. - * @return A String. - */ - static public String doubleToString(double d) { - if (Double.isInfinite(d) || Double.isNaN(d)) { - return "null"; - } - -// Shave off trailing zeros and decimal point, if possible. - - String s = Double.toString(d); - if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) { - while (s.endsWith("0")) { - s = s.substring(0, s.length() - 1); - } - if (s.endsWith(".")) { - s = s.substring(0, s.length() - 1); - } - } - return s; - } - - - /** - * Get the value object associated with a key. - * - * @param key A key string. - * @return The object associated with the key. - * @throws JSONException if the key is not found. - */ - public Object get(String key) throws JSONException { - Object o = opt(key); - if (o == null) { - throw new JSONException("JSONObject[" + quote(key) + - "] not found."); - } - return o; - } - - - /** - * Get the boolean value associated with a key. - * - * @param key A key string. - * @return The truth. - * @throws JSONException - * if the value is not a Boolean or the String "true" or "false". - */ - public boolean getBoolean(String key) throws JSONException { - Object o = get(key); - if (o.equals(Boolean.FALSE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("false"))) { - return false; - } else if (o.equals(Boolean.TRUE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("true"))) { - return true; - } - throw new JSONException("JSONObject[" + quote(key) + - "] is not a Boolean."); - } - - - /** - * Get the double value associated with a key. - * @param key A key string. - * @return The numeric value. - * @throws JSONException if the key is not found or - * if the value is not a Number object and cannot be converted to a number. - */ - public double getDouble(String key) throws JSONException { - Object o = get(key); - try { - return o instanceof Number ? - ((Number)o).doubleValue() : - Double.valueOf((String)o).doubleValue(); - } catch (Exception e) { - throw new JSONException("JSONObject[" + quote(key) + - "] is not a number."); - } - } - - - /** - * Get the int value associated with a key. If the number value is too - * large for an int, it will be clipped. - * - * @param key A key string. - * @return The integer value. - * @throws JSONException if the key is not found or if the value cannot - * be converted to an integer. - */ - public int getInt(String key) throws JSONException { - Object o = get(key); - return o instanceof Number ? - ((Number)o).intValue() : (int)getDouble(key); - } - - - /** - * Get the JSONArray value associated with a key. - * - * @param key A key string. - * @return A JSONArray which is the value. - * @throws JSONException if the key is not found or - * if the value is not a JSONArray. - */ - public JSONArray getJSONArray(String key) throws JSONException { - Object o = get(key); - if (o instanceof JSONArray) { - return (JSONArray)o; - } - throw new JSONException("JSONObject[" + quote(key) + - "] is not a JSONArray."); - } - - - /** - * Get the JSONObject value associated with a key. - * - * @param key A key string. - * @return A JSONObject which is the value. - * @throws JSONException if the key is not found or - * if the value is not a JSONObject. - */ - public JSONObject getJSONObject(String key) throws JSONException { - Object o = get(key); - if (o instanceof JSONObject) { - return (JSONObject)o; - } - throw new JSONException("JSONObject[" + quote(key) + - "] is not a JSONObject."); - } - - - /** - * Get the long value associated with a key. If the number value is too - * long for a long, it will be clipped. - * - * @param key A key string. - * @return The long value. - * @throws JSONException if the key is not found or if the value cannot - * be converted to a long. - */ - public long getLong(String key) throws JSONException { - Object o = get(key); - return o instanceof Number ? - ((Number)o).longValue() : (long)getDouble(key); - } - - - /** - * Get the string associated with a key. - * - * @param key A key string. - * @return A string which is the value. - * @throws JSONException if the key is not found. - */ - public String getString(String key) throws JSONException { - return get(key).toString(); - } - - - /** - * Determine if the JSONObject contains a specific key. - * @param key A key string. - * @return true if the key exists in the JSONObject. - */ - public boolean has(String key) { - return this.myHashMap.containsKey(key); - } - - - /** - * Determine if the value associated with the key is null or if there is - * no value. - * @param key A key string. - * @return true if there is no value associated with the key or if - * the value is the JSONObject.NULL object. - */ - public boolean isNull(String key) { - return JSONObject.NULL.equals(opt(key)); - } - - - /** - * Get an enumeration of the keys of the JSONObject. - * - * @return An iterator of the keys. - */ - public Iterator keys() { - return this.myHashMap.keySet().iterator(); - } - - - /** - * Get the number of keys stored in the JSONObject. - * - * @return The number of keys in the JSONObject. - */ - public int length() { - return this.myHashMap.size(); - } - - - /** - * Produce a JSONArray containing the names of the elements of this - * JSONObject. - * @return A JSONArray containing the key strings, or null if the JSONObject - * is empty. - */ - public JSONArray names() { - JSONArray ja = new JSONArray(); - Iterator keys = keys(); - while (keys.hasNext()) { - ja.put(keys.next()); - } - return ja.length() == 0 ? null : ja; - } - - /** - * Produce a string from a Number. - * @param n A Number - * @return A String. - * @throws JSONException If n is a non-finite number. - */ - static public String numberToString(Number n) - throws JSONException { - if (n == null) { - throw new JSONException("Null pointer"); - } - testValidity(n); - -// Shave off trailing zeros and decimal point, if possible. - - String s = n.toString(); - if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) { - while (s.endsWith("0")) { - s = s.substring(0, s.length() - 1); - } - if (s.endsWith(".")) { - s = s.substring(0, s.length() - 1); - } - } - return s; - } - - - /** - * Get an optional value associated with a key. - * @param key A key string. - * @return An object which is the value, or null if there is no value. - */ - public Object opt(String key) { - return key == null ? null : this.myHashMap.get(key); - } - - - /** - * Get an optional boolean associated with a key. - * It returns false if there is no such key, or if the value is not - * Boolean.TRUE or the String "true". - * - * @param key A key string. - * @return The truth. - */ - public boolean optBoolean(String key) { - return optBoolean(key, false); - } - - - /** - * Get an optional boolean associated with a key. - * It returns the defaultValue if there is no such key, or if it is not - * a Boolean or the String "true" or "false" (case insensitive). - * - * @param key A key string. - * @param defaultValue The default. - * @return The truth. - */ - public boolean optBoolean(String key, boolean defaultValue) { - try { - return getBoolean(key); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Put a key/value pair in the JSONObject, where the value will be a - * JSONArray which is produced from a Collection. - * @param key A key string. - * @param value A Collection value. - * @return this. - * @throws JSONException - */ - public JSONObject put(String key, Collection value) throws JSONException { - put(key, new JSONArray(value)); - return this; - } - - - /** - * Get an optional double associated with a key, - * or NaN if there is no such key or if its value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A string which is the key. - * @return An object which is the value. - */ - public double optDouble(String key) { - return optDouble(key, Double.NaN); - } - - - /** - * Get an optional double associated with a key, or the - * defaultValue if there is no such key or if its value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @param defaultValue The default. - * @return An object which is the value. - */ - public double optDouble(String key, double defaultValue) { - try { - Object o = opt(key); - return o instanceof Number ? ((Number)o).doubleValue() : - new Double((String)o).doubleValue(); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional int value associated with a key, - * or zero if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @return An object which is the value. - */ - public int optInt(String key) { - return optInt(key, 0); - } - - - /** - * Get an optional int value associated with a key, - * or the default if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @param defaultValue The default. - * @return An object which is the value. - */ - public int optInt(String key, int defaultValue) { - try { - return getInt(key); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional JSONArray associated with a key. - * It returns null if there is no such key, or if its value is not a - * JSONArray. - * - * @param key A key string. - * @return A JSONArray which is the value. - */ - public JSONArray optJSONArray(String key) { - Object o = opt(key); - return o instanceof JSONArray ? (JSONArray)o : null; - } - - - /** - * Get an optional JSONObject associated with a key. - * It returns null if there is no such key, or if its value is not a - * JSONObject. - * - * @param key A key string. - * @return A JSONObject which is the value. - */ - public JSONObject optJSONObject(String key) { - Object o = opt(key); - return o instanceof JSONObject ? (JSONObject)o : null; - } - - - /** - * Get an optional long value associated with a key, - * or zero if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @return An object which is the value. - */ - public long optLong(String key) { - return optLong(key, 0); - } - - - /** - * Get an optional long value associated with a key, - * or the default if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @param defaultValue The default. - * @return An object which is the value. - */ - public long optLong(String key, long defaultValue) { - try { - return getLong(key); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional string associated with a key. - * It returns an empty string if there is no such key. If the value is not - * a string and is not null, then it is coverted to a string. - * - * @param key A key string. - * @return A string which is the value. - */ - public String optString(String key) { - return optString(key, ""); - } - - - /** - * Get an optional string associated with a key. - * It returns the defaultValue if there is no such key. - * - * @param key A key string. - * @param defaultValue The default. - * @return A string which is the value. - */ - public String optString(String key, String defaultValue) { - Object o = opt(key); - return o != null ? o.toString() : defaultValue; - } - - - /** - * Put a key/boolean pair in the JSONObject. - * - * @param key A key string. - * @param value A boolean which is the value. - * @return this. - * @throws JSONException If the key is null. - */ - public JSONObject put(String key, boolean value) throws JSONException { - put(key, value ? Boolean.TRUE : Boolean.FALSE); - return this; - } - - - /** - * Put a key/double pair in the JSONObject. - * - * @param key A key string. - * @param value A double which is the value. - * @return this. - * @throws JSONException If the key is null or if the number is invalid. - */ - public JSONObject put(String key, double value) throws JSONException { - put(key, new Double(value)); - return this; - } - - - /** - * Put a key/int pair in the JSONObject. - * - * @param key A key string. - * @param value An int which is the value. - * @return this. - * @throws JSONException If the key is null. - */ - public JSONObject put(String key, int value) throws JSONException { - put(key, new Integer(value)); - return this; - } - - - /** - * Put a key/long pair in the JSONObject. - * - * @param key A key string. - * @param value A long which is the value. - * @return this. - * @throws JSONException If the key is null. - */ - public JSONObject put(String key, long value) throws JSONException { - put(key, new Long(value)); - return this; - } - - - /** - * Put a key/value pair in the JSONObject, where the value will be a - * JSONObject which is produced from a Map. - * @param key A key string. - * @param value A Map value. - * @return this. - * @throws JSONException - */ - public JSONObject put(String key, Map value) throws JSONException { - put(key, new JSONObject(value)); - return this; - } - - - /** - * Put a key/value pair in the JSONObject. If the value is null, - * then the key will be removed from the JSONObject if it is present. - * @param key A key string. - * @param value An object which is the value. It should be of one of these - * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, - * or the JSONObject.NULL object. - * @return this. - * @throws JSONException If the value is non-finite number - * or if the key is null. - */ - public JSONObject put(String key, Object value) throws JSONException { - if (key == null) { - throw new JSONException("Null key."); - } - if (value != null) { - testValidity(value); - this.myHashMap.put(key, value); - } else { - remove(key); - } - return this; - } - - - /** - * Put a key/value pair in the JSONObject, but only if the - * key and the value are both non-null. - * @param key A key string. - * @param value An object which is the value. It should be of one of these - * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, - * or the JSONObject.NULL object. - * @return this. - * @throws JSONException If the value is a non-finite number. - */ - public JSONObject putOpt(String key, Object value) throws JSONException { - if (key != null && value != null) { - put(key, value); - } - return this; - } - - - /** - * Produce a string in double quotes with backslash sequences in all the - * right places. A backslash will be inserted, allowing JSON - * text to be delivered in HTML. In JSON text, a string cannot contain a - * control character or an unescaped quote or backslash. - * @param string A String - * @return A String correctly formatted for insertion in a JSON text. - */ - public static String quote(String string) { - if (string == null || string.length() == 0) { - return "\"\""; - } - - char b; - char c = 0; - int i; - int len = string.length(); - StringBuffer sb = new StringBuffer(len + 4); - String t; - - sb.append('"'); - for (i = 0; i < len; i += 1) { - b = c; - c = string.charAt(i); - switch (c) { - case '\\': - case '"': - sb.append('\\'); - sb.append(c); - break; - case '/': - if (b == '<') { - sb.append('\\'); - } - sb.append(c); - break; - case '\b': - sb.append("\\b"); - break; - case '\t': - sb.append("\\t"); - break; - case '\n': - sb.append("\\n"); - break; - case '\f': - sb.append("\\f"); - break; - case '\r': - sb.append("\\r"); - break; - default: - if (c < ' ') { - t = "000" + Integer.toHexString(c); - sb.append("\\u" + t.substring(t.length() - 4)); - } else { - sb.append(c); - } - } - } - sb.append('"'); - return sb.toString(); - } - - /** - * Remove a name and its value, if present. - * @param key The name to be removed. - * @return The value that was associated with the name, - * or null if there was no value. - */ - public Object remove(String key) { - return this.myHashMap.remove(key); - } - - - /** - * Throw an exception if the object is an NaN or infinite number. - * @param o The object to test. - * @throws JSONException If o is a non-finite number. - */ - static void testValidity(Object o) throws JSONException { - if (o != null) { - if (o instanceof Double) { - if (((Double)o).isInfinite() || ((Double)o).isNaN()) { - throw new JSONException( - "JSON does not allow non-finite numbers"); - } - } else if (o instanceof Float) { - if (((Float)o).isInfinite() || ((Float)o).isNaN()) { - throw new JSONException( - "JSON does not allow non-finite numbers."); - } - } - } - } - - - /** - * Produce a JSONArray containing the values of the members of this - * JSONObject. - * @param names A JSONArray containing a list of key strings. This - * determines the sequence of the values in the result. - * @return A JSONArray of values. - * @throws JSONException If any of the values are non-finite numbers. - */ - public JSONArray toJSONArray(JSONArray names) throws JSONException { - if (names == null || names.length() == 0) { - return null; - } - JSONArray ja = new JSONArray(); - for (int i = 0; i < names.length(); i += 1) { - ja.put(this.opt(names.getString(i))); - } - return ja; - } - - /** - * Make a JSON text of this JSONObject. For compactness, no whitespace - * is added. If this would not result in a syntactically correct JSON text, - * then null will be returned instead. - *

    - * Warning: This method assumes that the data structure is acyclical. - * - * @return a printable, displayable, portable, transmittable - * representation of the object, beginning - * with {@code {} (left brace) and ending - * with {@code }} (right brace). - */ - public String toString() { - try { - Iterator keys = keys(); - StringBuffer sb = new StringBuffer("{"); - - while (keys.hasNext()) { - if (sb.length() > 1) { - sb.append(','); - } - Object o = keys.next(); - sb.append(quote(o.toString())); - sb.append(':'); - sb.append(valueToString(this.myHashMap.get(o))); - } - sb.append('}'); - return sb.toString(); - } catch (Exception e) { - return null; - } - } - - - /** - * Make a prettyprinted JSON text of this JSONObject. - *

    - * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @return a printable, displayable, portable, transmittable - * representation of the object, beginning - * with {@code {} (left brace) and ending - * with {@code }} (right brace). - * @throws JSONException If the object contains an invalid number. - */ - public String toString(int indentFactor) throws JSONException { - return toString(indentFactor, 0); - } - - - /** - * Make a prettyprinted JSON text of this JSONObject. - *

    - * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @param indent The indentation of the top level. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with {@code {} (left brace) and ending - * with {@code }} (right brace). - * @throws JSONException If the object contains an invalid number. - */ - String toString(int indentFactor, int indent) throws JSONException { - int i; - int n = length(); - if (n == 0) { - return "{}"; - } - Iterator keys = keys(); - StringBuffer sb = new StringBuffer("{"); - int newindent = indent + indentFactor; - Object o; - if (n == 1) { - o = keys.next(); - sb.append(quote(o.toString())); - sb.append(": "); - sb.append(valueToString(this.myHashMap.get(o), indentFactor, - indent)); - } else { - while (keys.hasNext()) { - o = keys.next(); - if (sb.length() > 1) { - sb.append(",\n"); - } else { - sb.append('\n'); - } - for (i = 0; i < newindent; i += 1) { - sb.append(' '); - } - sb.append(quote(o.toString())); - sb.append(": "); - sb.append(valueToString(this.myHashMap.get(o), indentFactor, - newindent)); - } - if (sb.length() > 1) { - sb.append('\n'); - for (i = 0; i < indent; i += 1) { - sb.append(' '); - } - } - } - sb.append('}'); - return sb.toString(); - } - - - /** - * Make a JSON text of an Object value. If the object has an - * value.toJSONString() method, then that method will be used to produce - * the JSON text. The method is required to produce a strictly - * conforming text. If the object does not contain a toJSONString - * method (which is the most common case), then a text will be - * produced by the rules. - *

    - * Warning: This method assumes that the data structure is acyclical. - * @param value The value to be serialized. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with {@code {} (left brace) and ending - * with {@code }} (right brace). - * @throws JSONException If the value is or contains an invalid number. - */ - static String valueToString(Object value) throws JSONException { - if (value == null || value.equals(null)) { - return "null"; - } - if (value instanceof JSONString) { - Object o; - try { - o = ((JSONString)value).toJSONString(); - } catch (Exception e) { - throw new JSONException(e); - } - if (o instanceof String) { - return (String)o; - } - throw new JSONException("Bad value from toJSONString: " + o); - } - if (value instanceof Number) { - return numberToString((Number) value); - } - if (value instanceof Boolean || value instanceof JSONObject || - value instanceof JSONArray) { - return value.toString(); - } - return quote(value.toString()); - } - - - /** - * Make a prettyprinted JSON text of an object value. - *

    - * Warning: This method assumes that the data structure is acyclical. - * @param value The value to be serialized. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @param indent The indentation of the top level. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with {@code {} (left brace) and ending - * with {@code }} (right brace). - * @throws JSONException If the object contains an invalid number. - */ - static String valueToString(Object value, int indentFactor, int indent) - throws JSONException { - if (value == null || value.equals(null)) { - return "null"; - } - try { - if (value instanceof JSONString) { - Object o = ((JSONString)value).toJSONString(); - if (o instanceof String) { - return (String)o; - } - } - } catch (Exception e) { - /* forget about it */ - } - if (value instanceof Number) { - return numberToString((Number) value); - } - if (value instanceof Boolean) { - return value.toString(); - } - if (value instanceof JSONObject) { - return ((JSONObject)value).toString(indentFactor, indent); - } - if (value instanceof JSONArray) { - return ((JSONArray)value).toString(indentFactor, indent); - } - return quote(value.toString()); - } - - - /** - * Write the contents of the JSONObject as JSON text to a writer. - * For compactness, no whitespace is added. - *

    - * Warning: This method assumes that the data structure is acyclical. - * - * @return The writer. - * @throws JSONException - */ - public Writer write(Writer writer) throws JSONException { - try { - boolean b = false; - Iterator keys = keys(); - writer.write('{'); - - while (keys.hasNext()) { - if (b) { - writer.write(','); - } - Object k = keys.next(); - writer.write(quote(k.toString())); - writer.write(':'); - Object v = this.myHashMap.get(k); - if (v instanceof JSONObject) { - ((JSONObject)v).write(writer); - } else if (v instanceof JSONArray) { - ((JSONArray)v).write(writer); - } else { - writer.write(valueToString(v)); - } - b = true; - } - writer.write('}'); - return writer; - } catch (IOException e) { - throw new JSONException(e); - } - } -} \ No newline at end of file diff --git a/api/src/main/java/org/json/JSONString.java b/api/src/main/java/org/json/JSONString.java deleted file mode 100644 index 2822961ae..000000000 --- a/api/src/main/java/org/json/JSONString.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.json; -/** - * The {@code JSONString} interface allows a {@code toJSONString()} - * method so that a class can change the behavior of - * {@code JSONObject.toString()}, {@code JSONArray.toString()}, - * and {@code JSONWriter.value(}Object{@code )}. The - * {@code toJSONString} method will be used instead of the default behavior - * of using the Object's {@code toString()} method and quoting the result. - */ -public interface JSONString { - /** - * The {@code toJSONString} method allows a class to produce its own JSON - * serialization. - * - * @return A strictly syntactically correct JSON text. - */ - public String toJSONString(); -} diff --git a/api/src/main/java/org/json/JSONStringer.java b/api/src/main/java/org/json/JSONStringer.java deleted file mode 100644 index dcdab0fdf..000000000 --- a/api/src/main/java/org/json/JSONStringer.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.json; - -/* -Copyright (c) 2006 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.io.StringWriter; - -/** - * JSONStringer provides a quick and convenient way of producing JSON text. - * The texts produced strictly conform to JSON syntax rules. No whitespace is - * added, so the results are ready for transmission or storage. Each instance of - * JSONStringer can produce one JSON text. - *

    - * A JSONStringer instance provides a {@code value} method for appending - * values to the - * text, and a {@code key} - * method for adding keys before values in objects. There are {@code array} - * and {@code endArray} methods that make and bound array values, and - * {@code object} and {@code endObject} methods which make and bound - * object values. All of these methods return the JSONWriter instance, - * permitting cascade style. For example,

    - * myString = new JSONStringer()
    - *     .object()
    - *         .key("JSON")
    - *         .value("Hello, World!")
    - *     .endObject()
    - *     .toString();
    which produces the string
    - * {"JSON":"Hello, World!"}
    - *

    - * The first method called must be {@code array} or {@code object}. - * There are no methods for adding commas or colons. JSONStringer adds them for - * you. Objects and arrays can be nested up to 20 levels deep. - *

    - * This can sometimes be easier than using a JSONObject to build a string. - * @author JSON.org - * @version 2 - */ -public class JSONStringer extends JSONWriter { - /** - * Make a fresh JSONStringer. It can be used to build one JSON text. - */ - public JSONStringer() { - super(new StringWriter()); - } - - /** - * Return the JSON text. This method is used to obtain the product of the - * JSONStringer instance. It will return {@code null} if there was a - * problem in the construction of the JSON text (such as the calls to - * {@code array} were not properly balanced with calls to - * {@code endArray}). - * @return The JSON text. - */ - public String toString() { - return this.mode == 'd' ? this.writer.toString() : null; - } -} diff --git a/api/src/main/java/org/json/JSONTokener.java b/api/src/main/java/org/json/JSONTokener.java deleted file mode 100644 index 66a0af34d..000000000 --- a/api/src/main/java/org/json/JSONTokener.java +++ /dev/null @@ -1,460 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * A JSONTokener takes a source string and extracts characters and tokens from - * it. It is used by the JSONObject and JSONArray constructors to parse - * JSON source strings. - * @author JSON.org - * @version 2 - */ -public class JSONTokener { - - /** - * The index of the next character. - */ - private int myIndex; - - - /** - * The source string being tokenized. - */ - private String mySource; - - - /** - * Construct a JSONTokener from a string. - * - * @param s A source string. - */ - public JSONTokener(String s) { - this.myIndex = 0; - this.mySource = s; - } - - - /** - * Back up one character. This provides a sort of lookahead capability, - * so that you can test for a digit or letter before attempting to parse - * the next number or identifier. - */ - public void back() { - if (this.myIndex > 0) { - this.myIndex -= 1; - } - } - - - - /** - * Get the hex value of a character (base16). - * @param c A character between '0' and '9' or between 'A' and 'F' or - * between 'a' and 'f'. - * @return An int between 0 and 15, or -1 if c was not a hex digit. - */ - public static int dehexchar(char c) { - if (c >= '0' && c <= '9') { - return c - '0'; - } - if (c >= 'A' && c <= 'F') { - return c - ('A' - 10); - } - if (c >= 'a' && c <= 'f') { - return c - ('a' - 10); - } - return -1; - } - - - /** - * Determine if the source string still contains characters that next() - * can consume. - * @return true if not yet at the end of the source. - */ - public boolean more() { - return this.myIndex < this.mySource.length(); - } - - - /** - * Get the next character in the source string. - * - * @return The next character, or 0 if past the end of the source string. - */ - public char next() { - if (more()) { - char c = this.mySource.charAt(this.myIndex); - this.myIndex += 1; - return c; - } - return 0; - } - - - /** - * Consume the next character, and check that it matches a specified - * character. - * @param c The character to match. - * @return The character. - * @throws JSONException if the character does not match. - */ - public char next(char c) throws JSONException { - char n = next(); - if (n != c) { - throw syntaxError("Expected '" + c + "' and instead saw '" + - n + "'."); - } - return n; - } - - - /** - * Get the next n characters. - * - * @param n The number of characters to take. - * @return A string of n characters. - * @throws JSONException - * Substring bounds error if there are not - * n characters remaining in the source string. - */ - public String next(int n) throws JSONException { - int i = this.myIndex; - int j = i + n; - if (j >= this.mySource.length()) { - throw syntaxError("Substring bounds error"); - } - this.myIndex += n; - return this.mySource.substring(i, j); - } - - - /** - * Get the next char in the string, skipping whitespace - * and comments (slashslash, slashstar, and hash). - * @throws JSONException - * @return A character, or 0 if there are no more characters. - */ - public char nextClean() throws JSONException { - for (;;) { - char c = next(); - if (c == '/') { - switch (next()) { - case '/': - do { - c = next(); - } while (c != '\n' && c != '\r' && c != 0); - break; - case '*': - for (;;) { - c = next(); - if (c == 0) { - throw syntaxError("Unclosed comment."); - } - if (c == '*') { - if (next() == '/') { - break; - } - back(); - } - } - break; - default: - back(); - return '/'; - } - } else if (c == '#') { - do { - c = next(); - } while (c != '\n' && c != '\r' && c != 0); - } else if (c == 0 || c > ' ') { - return c; - } - } - } - - - /** - * Return the characters up to the next close quote character. - * Backslash processing is done. The formal JSON format does not - * allow strings in single quotes, but an implementation is allowed to - * accept them. - * @param quote The quoting character, either - * {@code "} (double quote) or - * {@code '} (single quote). - * @return A String. - * @throws JSONException Unterminated string. - */ - public String nextString(char quote) throws JSONException { - char c; - StringBuffer sb = new StringBuffer(); - for (;;) { - c = next(); - switch (c) { - case 0: - case '\n': - case '\r': - throw syntaxError("Unterminated string"); - case '\\': - c = next(); - switch (c) { - case 'b': - sb.append('\b'); - break; - case 't': - sb.append('\t'); - break; - case 'n': - sb.append('\n'); - break; - case 'f': - sb.append('\f'); - break; - case 'r': - sb.append('\r'); - break; - case 'u': - sb.append((char)Integer.parseInt(next(4), 16)); - break; - case 'x' : - sb.append((char) Integer.parseInt(next(2), 16)); - break; - default: - sb.append(c); - } - break; - default: - if (c == quote) { - return sb.toString(); - } - sb.append(c); - } - } - } - - - /** - * Get the text up but not including the specified character or the - * end of line, whichever comes first. - * @param d A delimiter character. - * @return A string. - */ - public String nextTo(char d) { - StringBuffer sb = new StringBuffer(); - for (;;) { - char c = next(); - if (c == d || c == 0 || c == '\n' || c == '\r') { - if (c != 0) { - back(); - } - return sb.toString().trim(); - } - sb.append(c); - } - } - - - /** - * Get the text up but not including one of the specified delimeter - * characters or the end of line, whichever comes first. - * @param delimiters A set of delimiter characters. - * @return A string, trimmed. - */ - public String nextTo(String delimiters) { - char c; - StringBuffer sb = new StringBuffer(); - for (;;) { - c = next(); - if (delimiters.indexOf(c) >= 0 || c == 0 || - c == '\n' || c == '\r') { - if (c != 0) { - back(); - } - return sb.toString().trim(); - } - sb.append(c); - } - } - - - /** - * Get the next value. The value can be a Boolean, Double, Integer, - * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object. - * @throws JSONException If syntax error. - * - * @return An object. - */ - public Object nextValue() throws JSONException { - char c = nextClean(); - String s; - - switch (c) { - case '"': - case '\'': - return nextString(c); - case '{': - back(); - return new JSONObject(this); - case '[': - back(); - return new JSONArray(this); - } - - /* - * Handle unquoted text. This could be the values true, false, or - * null, or it can be a number. An implementation (such as this one) - * is allowed to also accept non-standard forms. - * - * Accumulate characters until we reach the end of the text or a - * formatting character. - */ - - StringBuffer sb = new StringBuffer(); - char b = c; - while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { - sb.append(c); - c = next(); - } - back(); - - /* - * If it is true, false, or null, return the proper value. - */ - - s = sb.toString().trim(); - if (s.equals("")) { - throw syntaxError("Missing value."); - } - if (s.equalsIgnoreCase("true")) { - return Boolean.TRUE; - } - if (s.equalsIgnoreCase("false")) { - return Boolean.FALSE; - } - if (s.equalsIgnoreCase("null")) { - return JSONObject.NULL; - } - - /* - * If it might be a number, try converting it. We support the 0- and 0x- - * conventions. If a number cannot be produced, then the value will just - * be a string. Note that the 0-, 0x-, plus, and implied string - * conventions are non-standard. A JSON parser is free to accept - * non-JSON forms as long as it accepts all correct JSON forms. - */ - - if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') { - if (b == '0') { - if (s.length() > 2 && - (s.charAt(1) == 'x' || s.charAt(1) == 'X')) { - try { - return new Integer(Integer.parseInt(s.substring(2), - 16)); - } catch (Exception e) { - /* Ignore the error */ - } - } else { - try { - return new Integer(Integer.parseInt(s, 8)); - } catch (Exception e) { - /* Ignore the error */ - } - } - } - try { - return new Integer(s); - } catch (Exception e) { - try { - return new Long(s); - } catch (Exception f) { - try { - return new Double(s); - } catch (Exception g) { - return s; - } - } - } - } - return s; - } - - - /** - * Skip characters until the next character is the requested character. - * If the requested character is not found, no characters are skipped. - * @param to A character to skip to. - * @return The requested character, or zero if the requested character - * is not found. - */ - public char skipTo(char to) { - char c; - int index = this.myIndex; - do { - c = next(); - if (c == 0) { - this.myIndex = index; - return c; - } - } while (c != to); - back(); - return c; - } - - - /** - * Skip characters until past the requested string. - * If it is not found, we are left at the end of the source. - * @param to A string to skip past. - */ - public void skipPast(String to) { - this.myIndex = this.mySource.indexOf(to, this.myIndex); - if (this.myIndex < 0) { - this.myIndex = this.mySource.length(); - } else { - this.myIndex += to.length(); - } - } - - - /** - * Make a JSONException to signal a syntax error. - * - * @param message The error message. - * @return A JSONException object, suitable for throwing - */ - public JSONException syntaxError(String message) { - return new JSONException(message + toString()); - } - - - /** - * Make a printable string of this JSONTokener. - * - * @return " at character [this.myIndex] of [this.mySource]" - */ - public String toString() { - return " at character " + this.myIndex + " of " + this.mySource; - } -} \ No newline at end of file diff --git a/api/src/main/java/org/json/JSONWriter.java b/api/src/main/java/org/json/JSONWriter.java deleted file mode 100644 index b95959ec1..000000000 --- a/api/src/main/java/org/json/JSONWriter.java +++ /dev/null @@ -1,318 +0,0 @@ -package org.json; - -import java.io.IOException; -import java.io.Writer; - -/* -Copyright (c) 2006 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * JSONWriter provides a quick and convenient way of producing JSON text. - * The texts produced strictly conform to JSON syntax rules. No whitespace is - * added, so the results are ready for transmission or storage. Each instance of - * JSONWriter can produce one JSON text. - *

    - * A JSONWriter instance provides a {@code value} method for appending - * values to the - * text, and a {@code key} - * method for adding keys before values in objects. There are {@code array} - * and {@code endArray} methods that make and bound array values, and - * {@code object} and {@code endObject} methods which make and bound - * object values. All of these methods return the JSONWriter instance, - * permitting a cascade style. For example,

    - * new JSONWriter(myWriter)
    - *     .object()
    - *         .key("JSON")
    - *         .value("Hello, World!")
    - *     .endObject();
    which writes
    - * {"JSON":"Hello, World!"}
    - *

    - * The first method called must be {@code array} or {@code object}. - * There are no methods for adding commas or colons. JSONWriter adds them for - * you. Objects and arrays can be nested up to 20 levels deep. - *

    - * This can sometimes be easier than using a JSONObject to build a string. - * @author JSON.org - * @version 2 - */ -public class JSONWriter { - private static final int maxdepth = 20; - - /** - * The comma flag determines if a comma should be output before the next - * value. - */ - private boolean comma; - - /** - * The current mode. Values: - * 'a' (array), - * 'd' (done), - * 'i' (initial), - * 'k' (key), - * 'o' (object). - */ - protected char mode; - - /** - * The object/array stack. - */ - private char stack[]; - - /** - * The stack top index. A value of 0 indicates that the stack is empty. - */ - private int top; - - /** - * The writer that will receive the output. - */ - protected Writer writer; - - /** - * Make a fresh JSONWriter. It can be used to build one JSON text. - */ - public JSONWriter(Writer w) { - this.comma = false; - this.mode = 'i'; - this.stack = new char[maxdepth]; - this.top = 0; - this.writer = w; - } - - /** - * Append a value. - * @param s A string value. - * @return this - * @throws JSONException If the value is out of sequence. - */ - private JSONWriter append(String s) throws JSONException { - if (s == null) { - throw new JSONException("Null pointer"); - } - if (this.mode == 'o' || this.mode == 'a') { - try { - if (this.comma && this.mode == 'a') { - this.writer.write(','); - } - this.writer.write(s); - } catch (IOException e) { - throw new JSONException(e); - } - if (this.mode == 'o') { - this.mode = 'k'; - } - this.comma = true; - return this; - } - throw new JSONException("Value out of sequence."); - } - - /** - * Begin appending a new array. All values until the balancing - * {@code endArray} will be appended to this array. The - * {@code endArray} method must be called to mark the array's end. - * @return this - * @throws JSONException If the nesting is too deep, or if the object is - * started in the wrong place (for example as a key or after the end of the - * outermost array or object). - */ - public JSONWriter array() throws JSONException { - if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { - this.push('a'); - this.append("["); - this.comma = false; - return this; - } - throw new JSONException("Misplaced array."); - } - - /** - * End something. - * @param m Mode - * @param c Closing character - * @return this - * @throws JSONException If unbalanced. - */ - private JSONWriter end(char m, char c) throws JSONException { - if (this.mode != m) { - throw new JSONException(m == 'o' ? "Misplaced endObject." : - "Misplaced endArray."); - } - this.pop(m); - try { - this.writer.write(c); - } catch (IOException e) { - throw new JSONException(e); - } - this.comma = true; - return this; - } - - /** - * End an array. This method most be called to balance calls to - * {@code array}. - * @return this - * @throws JSONException If incorrectly nested. - */ - public JSONWriter endArray() throws JSONException { - return this.end('a', ']'); - } - - /** - * End an object. This method most be called to balance calls to - * {@code object}. - * @return this - * @throws JSONException If incorrectly nested. - */ - public JSONWriter endObject() throws JSONException { - return this.end('k', '}'); - } - - /** - * Append a key. The key will be associated with the next value. In an - * object, every value must be preceded by a key. - * @param s A key string. - * @return this - * @throws JSONException If the key is out of place. For example, keys - * do not belong in arrays or if the key is null. - */ - public JSONWriter key(String s) throws JSONException { - if (s == null) { - throw new JSONException("Null key."); - } - if (this.mode == 'k') { - try { - if (this.comma) { - this.writer.write(','); - } - this.writer.write(JSONObject.quote(s)); - this.writer.write(':'); - this.comma = false; - this.mode = 'o'; - return this; - } catch (IOException e) { - throw new JSONException(e); - } - } - throw new JSONException("Misplaced key."); - } - - - /** - * Begin appending a new object. All keys and values until the balancing - * {@code endObject} will be appended to this object. The - * {@code endObject} method must be called to mark the object's end. - * @return this - * @throws JSONException If the nesting is too deep, or if the object is - * started in the wrong place (for example as a key or after the end of the - * outermost array or object). - */ - public JSONWriter object() throws JSONException { - if (this.mode == 'i') { - this.mode = 'o'; - } - if (this.mode == 'o' || this.mode == 'a') { - this.append("{"); - this.push('k'); - this.comma = false; - return this; - } - throw new JSONException("Misplaced object."); - - } - - - /** - * Pop an array or object scope. - * @param c The scope to close. - * @throws JSONException If nesting is wrong. - */ - private void pop(char c) throws JSONException { - if (this.top <= 0 || this.stack[this.top - 1] != c) { - throw new JSONException("Nesting error."); - } - this.top -= 1; - this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1]; - } - - /** - * Push an array or object scope. - * @param c The scope to open. - * @throws JSONException If nesting is too deep. - */ - private void push(char c) throws JSONException { - if (this.top >= maxdepth) { - throw new JSONException("Nesting too deep."); - } - this.stack[this.top] = c; - this.mode = c; - this.top += 1; - } - - - /** - * Append either the value {@code true} or the value - * {@code false}. - * @param b A boolean. - * @return this - * @throws JSONException - */ - public JSONWriter value(boolean b) throws JSONException { - return this.append(b ? "true" : "false"); - } - - /** - * Append a double value. - * @param d A double. - * @return this - * @throws JSONException If the number is not finite. - */ - public JSONWriter value(double d) throws JSONException { - return this.value(new Double(d)); - } - - /** - * Append a long value. - * @param l A long. - * @return this - * @throws JSONException - */ - public JSONWriter value(long l) throws JSONException { - return this.append(Long.toString(l)); - } - - - /** - * Append an object value. - * @param o The object to append. It can be null, or a Boolean, Number, - * String, JSONObject, or JSONArray, or an object with a toJSONString() - * method. - * @return this - * @throws JSONException If the value is out of sequence. - */ - public JSONWriter value(Object o) throws JSONException { - return this.append(JSONObject.valueToString(o)); - } -} diff --git a/api/src/main/java/org/json/Test.java b/api/src/main/java/org/json/Test.java deleted file mode 100644 index a68e8146c..000000000 --- a/api/src/main/java/org/json/Test.java +++ /dev/null @@ -1,413 +0,0 @@ -package org.json; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.io.StringWriter; - -/** - * Test class. This file is not formally a member of the org.json library. - * It is just a casual test tool. - */ -public class Test { - - /** - * Entry point. - * @param args Command line argumments - */ - public static void main(String args[]) { - Iterator it; - JSONArray a; - JSONObject j; - JSONStringer jj; - String s; - -// Obj is a typical class that implements JSONString. - - class Obj implements JSONString { - public String aString; - public double aNumber; - public boolean aBoolean; - - public Obj(String string, double n, boolean b) { - this.aString = string; - this.aNumber = n; - this.aBoolean = b; - } - - public String toJSONString() { - return "{" + JSONObject.quote(this.aString) + ":" + - JSONObject.doubleToString(this.aNumber) + "}"; - } - public String toString() { - return this.aString + " " + this.aNumber + " " + this.aBoolean; - } - } - - - try { - String sa[] = {"aString", "aNumber", "aBoolean"}; - Obj obj = new Obj("A string, a number, and a boolean", 42, true); - - j = XML.toJSONObject(""); - System.out.println(j.toString()); - - jj = new JSONStringer(); - s = jj.object() - .key("foo") - .value("bar") - .key("baz") - .array() - .object() - .key("quux") - .value("Thanks, Josh!") - .endObject() - .endArray() - .endObject() - .toString(); - System.out.println(s); - - System.out.println(new JSONStringer() - .object() - .key("a") - .array() - .array() - .array() - .value("b") - .endArray() - .endArray() - .endArray() - .endObject() - .toString()); - - jj = new JSONStringer(); - jj.array(); - jj.value(1); - jj.array(); - jj.value(null); - jj.array(); - jj.object(); - jj.key("empty-array").array().endArray(); - jj.key("answer").value(42); - jj.key("null").value(null); - jj.key("false").value(false); - jj.key("true").value(true); - jj.key("big").value(123456789e+88); - jj.key("small").value(123456789e-88); - jj.key("empty-object").object().endObject(); - jj.key("long"); - jj.value(9223372036854775807L); - jj.endObject(); - jj.value("two"); - jj.endArray(); - jj.value(true); - jj.endArray(); - jj.value(98.6); - jj.value(-100.0); - jj.object(); - jj.endObject(); - jj.object(); - jj.key("one"); - jj.value(1.00); - jj.endObject(); - jj.value(obj); - jj.endArray(); - System.out.println(jj.toString()); - - System.out.println(new JSONArray(jj.toString()).toString(4)); - - j = new JSONObject(obj, sa); - j.put("test", obj); - j.put("comment", "This object contains a test object that implements JSONString"); - System.out.println(j.toString(4)); - - j = new JSONObject("{slashes: '///', closetag: '', backslash:'\\\\', ei: {quotes: '\"\\''},eo: {a: '\"quoted\"', b:\"don't\"}, quotes: [\"'\", '\"']}"); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = new JSONObject( - "/*comment*/{foo: [true, false,9876543210, 0.0, 1.00000001, 1.000000000001, 1.00000000000000001," + - " .00000000000000001, 2.00, 0.1, 2e100, -32,[],{}, \"string\"], " + - " to : null, op : 'Good'," + - "ten:10} postfix comment"); - j.put("String", "98.6"); - j.put("JSONObject", new JSONObject()); - j.put("JSONArray", new JSONArray()); - j.put("int", 57); - j.put("double", 123456789012345678901234567890.); - j.put("true", true); - j.put("false", false); - j.put("null", JSONObject.NULL); - j.put("bool", "true"); - j.put("zero", -0.0); - a = j.getJSONArray("foo"); - a.put(666); - a.put(2001.99); - a.put("so \"fine\"."); - a.put("so ."); - a.put(true); - a.put(false); - a.put(new JSONArray()); - a.put(new JSONObject()); - System.out.println(j.toString(4)); - System.out.println(XML.toString(j)); - - System.out.println("String: " + j.getDouble("String")); - System.out.println(" bool: " + j.getBoolean("bool")); - System.out.println(" to: " + j.getString("to")); - System.out.println(" true: " + j.getString("true")); - System.out.println(" foo: " + j.getJSONArray("foo")); - System.out.println(" op: " + j.getString("op")); - System.out.println(" ten: " + j.getInt("ten")); - System.out.println(" oops: " + j.optBoolean("oops")); - - j = XML.toJSONObject("First \u0009<content> This is \"content\". 3 JSON does not preserve the sequencing of elements and contents. III T H R E EContent text is an implied structure in XML. JSON does not have implied structure:7everything is explicit.!]]>"); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = XML.toJSONObject(" "); - - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = XML.toJSONObject("Sample BookThis is chapter 1. It is not very long or interesting.This is chapter 2. Although it is longer than chapter 1, it is not any more interesting."); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = XML.toJSONObject(""); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = XML.toJSONObject(" Fred fbs0001 Scerbo B "); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = XML.toJSONObject("Repository Address Special Collections LibraryABC UniversityMain Library, 40 Circle DriveOurtown, Pennsylvania17654 USA"); - System.out.println(j.toString()); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = XML.toJSONObject("deluxe&"toot"&toot;Aeksbonusbonus2"); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = HTTP.toJSONObject("GET / HTTP/1.0\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*\nAccept-Language: en-us\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90; T312461; Q312461)\nHost: www.nokko.com\nConnection: keep-alive\nAccept-encoding: gzip, deflate\n"); - System.out.println(j.toString(2)); - System.out.println(HTTP.toString(j)); - System.out.println(""); - - j = HTTP.toJSONObject("HTTP/1.1 200 Oki Doki\nDate: Sun, 26 May 2002 17:38:52 GMT\nServer: Apache/1.3.23 (Unix) mod_perl/1.26\nKeep-Alive: timeout=15, max=100\nConnection: Keep-Alive\nTransfer-Encoding: chunked\nContent-Type: text/html\n"); - System.out.println(j.toString(2)); - System.out.println(HTTP.toString(j)); - System.out.println(""); - - j = new JSONObject("{nix: null, nux: false, null: 'null', 'Request-URI': '/', Method: 'GET', 'HTTP-Version': 'HTTP/1.0'}"); - System.out.println(j.toString(2)); - System.out.println("isNull: " + j.isNull("nix")); - System.out.println(" has: " + j.has("nix")); - System.out.println(XML.toString(j)); - System.out.println(HTTP.toString(j)); - System.out.println(""); - - j = XML.toJSONObject(""+"\n\n"+""+ - ""+ - "GOOGLEKEY '+search+' 0 10 true false latin1 latin1"+ - ""+ - ""); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = new JSONObject("{Envelope: {Body: {\"ns1:doGoogleSearch\": {oe: \"latin1\", filter: true, q: \"'+search+'\", key: \"GOOGLEKEY\", maxResults: 10, \"SOAP-ENV:encodingStyle\": \"http://schemas.xmlsoap.org/soap/encoding/\", start: 0, ie: \"latin1\", safeSearch:false, \"xmlns:ns1\": \"urn:GoogleSearch\"}}}}"); - System.out.println(j.toString(2)); - System.out.println(XML.toString(j)); - System.out.println(""); - - j = CookieList.toJSONObject(" f%oo = b+l=ah ; o;n%40e = t.wo "); - System.out.println(j.toString(2)); - System.out.println(CookieList.toString(j)); - System.out.println(""); - - j = Cookie.toJSONObject("f%oo=blah; secure ;expires = April 24, 2002"); - System.out.println(j.toString(2)); - System.out.println(Cookie.toString(j)); - System.out.println(""); - - j = new JSONObject("{script: 'It is not allowed in HTML to send a close script tag in a stringso we insert a backslash before the /'}"); - System.out.println(j.toString()); - System.out.println(""); - - JSONTokener jt = new JSONTokener("{op:'test', to:'session', pre:1}{op:'test', to:'session', pre:2}"); - j = new JSONObject(jt); - System.out.println(j.toString()); - System.out.println("pre: " + j.optInt("pre")); - int i = jt.skipTo('{'); - System.out.println(i); - j = new JSONObject(jt); - System.out.println(j.toString()); - System.out.println(""); - - a = CDL.toJSONArray("No quotes, 'Single Quotes', \"Double Quotes\"\n1,'2',\"3\"\n,'It is \"good,\"', \"It works.\"\n\n"); - - System.out.println(CDL.toString(a)); - System.out.println(""); - System.out.println(a.toString(4)); - System.out.println(""); - - a = new JSONArray(" [\"\", next is an implied null , , ok,] "); - System.out.println(a.toString()); - System.out.println(""); - System.out.println(XML.toString(a)); - System.out.println(""); - - j = new JSONObject("{ fun => with non-standard forms ; forgiving => This package can be used to parse formats that are similar to but not stricting conforming to JSON; why=To make it easier to migrate existing data to JSON,one = [[1.00]]; uno=[[{1=>1}]];'+':+6e66 ;pluses=+++;empty = '' , 'double':0.666,true: TRUE, false: FALSE, null=NULL;[true] = [[!,@;*]]; string=> o. k. ; # comment\r oct=0666; hex=0x666; dec=666; o=0999; noh=0x0x}"); - System.out.println(j.toString(4)); - System.out.println(""); - if (j.getBoolean("true") && !j.getBoolean("false")) { - System.out.println("It's all good"); - } - - System.out.println(""); - j = new JSONObject(j, new String[]{"dec", "oct", "hex", "missing"}); - System.out.println(j.toString(4)); - - System.out.println(""); - System.out.println(new JSONStringer().array().value(a).value(j).endArray()); - - j = new JSONObject("{string: \"98.6\", long: 2147483648, int: 2147483647, longer: 9223372036854775807, double: 9223372036854775808}"); - System.out.println(j.toString(4)); - - System.out.println("\ngetInt"); - System.out.println("int " + j.getInt("int")); - System.out.println("long " + j.getInt("long")); - System.out.println("longer " + j.getInt("longer")); - System.out.println("double " + j.getInt("double")); - System.out.println("string " + j.getInt("string")); - - System.out.println("\ngetLong"); - System.out.println("int " + j.getLong("int")); - System.out.println("long " + j.getLong("long")); - System.out.println("longer " + j.getLong("longer")); - System.out.println("double " + j.getLong("double")); - System.out.println("string " + j.getLong("string")); - - System.out.println("\ngetDouble"); - System.out.println("int " + j.getDouble("int")); - System.out.println("long " + j.getDouble("long")); - System.out.println("longer " + j.getDouble("longer")); - System.out.println("double " + j.getDouble("double")); - System.out.println("string " + j.getDouble("string")); - - j.put("good sized", 9223372036854775807L); - System.out.println(j.toString(4)); - - a = new JSONArray("[2147483647, 2147483648, 9223372036854775807, 9223372036854775808]"); - System.out.println(a.toString(4)); - - System.out.println("\nKeys: "); - it = j.keys(); - while (it.hasNext()) { - s = (String)it.next(); - System.out.println(s + ": " + j.getString(s)); - } - - - System.out.println("\naccumulate: "); - j = new JSONObject(); - j.accumulate("stooge", "Curly"); - j.accumulate("stooge", "Larry"); - j.accumulate("stooge", "Moe"); - a = j.getJSONArray("stooge"); - a.put(5, "Shemp"); - System.out.println(j.toString(4)); - - System.out.println("\nwrite:"); - System.out.println(j.write(new StringWriter())); - - s = "122333"; - j = XML.toJSONObject(s); - System.out.println(j.toString(4)); - System.out.println(XML.toString(j)); - - s = "Content of the first chapterContent of the second chapter Content of the first subchapter Content of the second subchapterThird Chapter"; - j = XML.toJSONObject(s); - System.out.println(j.toString(4)); - System.out.println(XML.toString(j)); - - Collection c = null; - Map m = null; - - j = new JSONObject(m); - a = new JSONArray(c); - j.append("stooge", "Joe DeRita"); - j.put("map", m); - j.put("collection", c); - j.put("array", a); - a.put(m); - a.put(c); - System.out.println(j.toString(4)); - - System.out.println("\nTesting Exceptions: "); - - System.out.print("Exception: "); - try { - System.out.println(j.getDouble("stooge")); - } catch (Exception e) { - System.out.println(e); - } - System.out.print("Exception: "); - try { - System.out.println(j.getDouble("howard")); - } catch (Exception e) { - System.out.println(e); - } - System.out.print("Exception: "); - try { - System.out.println(j.put(null, "howard")); - } catch (Exception e) { - System.out.println(e); - } - System.out.print("Exception: "); - try { - System.out.println(a.getDouble(0)); - } catch (Exception e) { - System.out.println(e); - } - System.out.print("Exception: "); - try { - System.out.println(a.get(-1)); - } catch (Exception e) { - System.out.println(e); - } - System.out.print("Exception: "); - try { - System.out.println(a.put(Double.NaN)); - } catch (Exception e) { - System.out.println(e); - } - } catch (Exception e) { - System.out.println(e.toString()); - } - } -} diff --git a/api/src/main/java/org/json/XML.java b/api/src/main/java/org/json/XML.java deleted file mode 100644 index cb89036fe..000000000 --- a/api/src/main/java/org/json/XML.java +++ /dev/null @@ -1,401 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.util.Iterator; - - -/** - * This provides static methods to convert an XML text into a JSONObject, - * and to covert a JSONObject into an XML text. - * @author JSON.org - * @version 2 - */ -public class XML { - - /* The Character '&'. */ - public static final Character AMP = new Character('&'); - - /* The Character '''. */ - public static final Character APOS = new Character('\''); - - /* The Character '!'. */ - public static final Character BANG = new Character('!'); - - /* The Character '='. */ - public static final Character EQ = new Character('='); - - /* The Character '>'. */ - public static final Character GT = new Character('>'); - - /* The Character '<'. */ - public static final Character LT = new Character('<'); - - /* The Character '?'. */ - public static final Character QUEST = new Character('?'); - - /* The Character '"'. */ - public static final Character QUOT = new Character('"'); - - /* The Character '/'. */ - public static final Character SLASH = new Character('/'); - - /** - * Replace special characters with XML escapes: - *

    -     * & (ampersand) is replaced by &amp;
    -     * < (less than) is replaced by &lt;
    -     * > (greater than) is replaced by &gt;
    -     * " (double quote) is replaced by &quot;
    -     * 
    - * @param string The string to be escaped. - * @return The escaped string. - */ - public static String escape(String string) { - StringBuffer sb = new StringBuffer(); - for (int i = 0, len = string.length(); i < len; i++) { - char c = string.charAt(i); - switch (c) { - case '&': - sb.append("&"); - break; - case '<': - sb.append("<"); - break; - case '>': - sb.append(">"); - break; - case '"': - sb.append("""); - break; - default: - sb.append(c); - } - } - return sb.toString(); - } - - /** - * Scan the content following the named tag, attaching it to the context. - * @param x The XMLTokener containing the source string. - * @param context The JSONObject that will include the new material. - * @param name The tag name. - * @return true if the close tag is processed. - * @throws JSONException - */ - private static boolean parse(XMLTokener x, JSONObject context, - String name) throws JSONException { - char c; - int i; - String n; - JSONObject o = null; - String s; - Object t; - -// Test for and skip past these forms: -// -// -// -// -// Report errors for these forms: -// <> -// <= -// << - - t = x.nextToken(); - -// "); - return false; - } - x.back(); - } else if (c == '[') { - t = x.nextToken(); - if (t.equals("CDATA")) { - if (x.next() == '[') { - s = x.nextCDATA(); - if (s.length() > 0) { - context.accumulate("content", s); - } - return false; - } - } - throw x.syntaxError("Expected 'CDATA['"); - } - i = 1; - do { - t = x.nextMeta(); - if (t == null) { - throw x.syntaxError("Missing '>' after ' 0); - return false; - } else if (t == QUEST) { - -// "); - return false; - } else if (t == SLASH) { - -// Close tag - - } else if (t == SLASH) { - if (x.nextToken() != GT) { - throw x.syntaxError("Misshaped tag"); - } - context.accumulate(n, o); - return false; - -// Content, between <...> and - - } else if (t == GT) { - for (;;) { - t = x.nextContent(); - if (t == null) { - if (name != null) { - throw x.syntaxError("Unclosed tag " + name); - } - return false; - } else if (t instanceof String) { - s = (String)t; - if (s.length() > 0) { - o.accumulate("content", s); - } - -// Nested element - - } else if (t == LT) { - if (parse(x, o, n)) { - if (o.length() == 0) { - context.accumulate(n, ""); - } else if (o.length() == 1 && - o.opt("content") != null) { - context.accumulate(n, o.opt("content")); - } else { - context.accumulate(n, o); - } - return false; - } - } - } - } else { - throw x.syntaxError("Misshaped tag"); - } - } - } - } - - - /** - * Convert a well-formed (but not necessarily valid) XML string into a - * JSONObject. Some information may be lost in this transformation - * because JSON is a data format and XML is a document format. XML uses - * elements, attributes, and content text, while JSON uses unordered - * collections of name/value pairs and arrays of values. JSON does not - * does not like to distinguish between elements and attributes. - * Sequences of similar elements are represented as JSONArrays. Content - * text may be placed in a "content" member. Comments, prologs, DTDs, and - * {@code <[ [ ]]>} are ignored. - * @param string The source string. - * @return A JSONObject containing the structured data from the XML string. - * @throws JSONException - */ - public static JSONObject toJSONObject(String string) throws JSONException { - JSONObject o = new JSONObject(); - XMLTokener x = new XMLTokener(string); - while (x.more()) { - x.skipPast("<"); - parse(x, o, null); - } - return o; - } - - - /** - * Convert a JSONObject into a well-formed, element-normal XML string. - * @param o A JSONObject. - * @return A string. - * @throws JSONException - */ - public static String toString(Object o) throws JSONException { - return toString(o, null); - } - - - /** - * Convert a JSONObject into a well-formed, element-normal XML string. - * @param o A JSONObject. - * @param tagName The optional name of the enclosing tag. - * @return A string. - * @throws JSONException - */ - public static String toString(Object o, String tagName) - throws JSONException { - StringBuffer b = new StringBuffer(); - int i; - JSONArray ja; - JSONObject jo; - String k; - Iterator keys; - int len; - String s; - Object v; - if (o instanceof JSONObject) { - -// Emit - - if (tagName != null) { - b.append('<'); - b.append(tagName); - b.append('>'); - } - -// Loop thru the keys. - - jo = (JSONObject)o; - keys = jo.keys(); - while (keys.hasNext()) { - k = keys.next().toString(); - v = jo.get(k); - if (v instanceof String) { - s = (String)v; - } else { - s = null; - } - -// Emit content in body - - if (k.equals("content")) { - if (v instanceof JSONArray) { - ja = (JSONArray)v; - len = ja.length(); - for (i = 0; i < len; i += 1) { - if (i > 0) { - b.append('\n'); - } - b.append(escape(ja.get(i).toString())); - } - } else { - b.append(escape(v.toString())); - } - -// Emit an array of similar keys - - } else if (v instanceof JSONArray) { - ja = (JSONArray)v; - len = ja.length(); - for (i = 0; i < len; i += 1) { - b.append(toString(ja.get(i), k)); - } - } else if (v.equals("")) { - b.append('<'); - b.append(k); - b.append("/>"); - -// Emit a new tag - - } else { - b.append(toString(v, k)); - } - } - if (tagName != null) { - -// Emit the close tag - - b.append("'); - } - return b.toString(); - -// XML does not have good support for arrays. If an array appears in a place -// where XML is lacking, synthesize an element. - - } else if (o instanceof JSONArray) { - ja = (JSONArray)o; - len = ja.length(); - for (i = 0; i < len; ++i) { - b.append(toString( - ja.opt(i), (tagName == null) ? "array" : tagName)); - } - return b.toString(); - } else { - s = (o == null) ? "null" : escape(o.toString()); - return (tagName == null) ? "\"" + s + "\"" : - (s.length() == 0) ? "<" + tagName + "/>" : - "<" + tagName + ">" + s + ""; - } - } -} \ No newline at end of file diff --git a/api/src/main/java/org/json/XMLTokener.java b/api/src/main/java/org/json/XMLTokener.java deleted file mode 100644 index 4c2880f69..000000000 --- a/api/src/main/java/org/json/XMLTokener.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * The XMLTokener extends the JSONTokener to provide additional methods - * for the parsing of XML texts. - * @author JSON.org - * @version 2 - */ -public class XMLTokener extends JSONTokener { - - - /** The table of entity values. It initially contains Character values for - * amp, apos, gt, lt, quot. - */ - public static final java.util.HashMap entity; - - static { - entity = new java.util.HashMap(8); - entity.put("amp", XML.AMP); - entity.put("apos", XML.APOS); - entity.put("gt", XML.GT); - entity.put("lt", XML.LT); - entity.put("quot", XML.QUOT); - } - - /** - * Construct an XMLTokener from a string. - * @param s A source string. - */ - public XMLTokener(String s) { - super(s); - } - - /** - * Get the text in the CDATA block. - * @return The string up to the {@code ]]>}. - * @throws JSONException If the {@code ]]>} is not found. - */ - public String nextCDATA() throws JSONException { - char c; - int i; - StringBuffer sb = new StringBuffer(); - for (;;) { - c = next(); - if (c == 0) { - throw syntaxError("Unclosed CDATA."); - } - sb.append(c); - i = sb.length() - 3; - if (i >= 0 && sb.charAt(i) == ']' && - sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') { - sb.setLength(i); - return sb.toString(); - } - } - } - - - /** - * Get the next XML outer token, trimming whitespace. There are two kinds - * of tokens: the character which begins a markup tag, and the content - * text between markup tags. - * - * @return A string, or a '<' Character, or null if there is no more - * source text. - * @throws JSONException - */ - public Object nextContent() throws JSONException { - char c; - StringBuffer sb; - do { - c = next(); - } while (Character.isWhitespace(c)); - if (c == 0) { - return null; - } - if (c == '<') { - return XML.LT; - } - sb = new StringBuffer(); - for (;;) { - if (c == '<' || c == 0) { - back(); - return sb.toString().trim(); - } - if (c == '&') { - sb.append(nextEntity(c)); - } else { - sb.append(c); - } - c = next(); - } - } - - - /** - * Return the next entity. These entities are translated to Characters: - * {@code & ' > < "}. - * @param a An ampersand character. - * @return A Character or an entity String if the entity is not recognized. - * @throws JSONException If missing ';' in XML entity. - */ - public Object nextEntity(char a) throws JSONException { - StringBuffer sb = new StringBuffer(); - for (;;) { - char c = next(); - if (Character.isLetterOrDigit(c) || c == '#') { - sb.append(Character.toLowerCase(c)); - } else if (c == ';') { - break; - } else { - throw syntaxError("Missing ';' in XML entity: &" + sb); - } - } - String s = sb.toString(); - Object e = entity.get(s); - return e != null ? e : a + s + ";"; - } - - - /** - * Returns the next XML meta token. - * - * @return Syntax characters ({@code < > / = ! ?}) are returned as - * Character, and strings and names are returned as Boolean. We don't care - * what the values actually are. - * @throws JSONException If a string is not properly closed or if the XML - * is badly structured. - */ - public Object nextMeta() throws JSONException { - char c; - char q; - do { - c = next(); - } while (Character.isWhitespace(c)); - switch (c) { - case 0: - throw syntaxError("Misshaped meta tag."); - case '<': - return XML.LT; - case '>': - return XML.GT; - case '/': - return XML.SLASH; - case '=': - return XML.EQ; - case '!': - return XML.BANG; - case '?': - return XML.QUEST; - case '"': - case '\'': - q = c; - for (;;) { - c = next(); - if (c == 0) { - throw syntaxError("Unterminated string."); - } - if (c == q) { - return Boolean.TRUE; - } - } - default: - for (;;) { - c = next(); - if (Character.isWhitespace(c)) { - return Boolean.TRUE; - } - switch (c) { - case 0: - case '<': - case '>': - case '/': - case '=': - case '!': - case '?': - case '"': - case '\'': - back(); - return Boolean.TRUE; - } - } - } - } - - - /** - * Get the next XML Token. These tokens are found inside of angle - * brackets. It may be one of these characters: {@code / > = ! ?} or it - * may be a string wrapped in single quotes or double quotes, or it may be a - * name. - * @return a String or a Character. - * @throws JSONException If the XML is not well formed. - */ - public Object nextToken() throws JSONException { - char c; - char q; - StringBuffer sb; - do { - c = next(); - } while (Character.isWhitespace(c)); - switch (c) { - case 0: - throw syntaxError("Misshaped element."); - case '<': - throw syntaxError("Misplaced '<'."); - case '>': - return XML.GT; - case '/': - return XML.SLASH; - case '=': - return XML.EQ; - case '!': - return XML.BANG; - case '?': - return XML.QUEST; - -// Quoted string - - case '"': - case '\'': - q = c; - sb = new StringBuffer(); - for (;;) { - c = next(); - if (c == 0) { - throw syntaxError("Unterminated string."); - } - if (c == q) { - return sb.toString(); - } - if (c == '&') { - sb.append(nextEntity(c)); - } else { - sb.append(c); - } - } - default: - -// Name - - sb = new StringBuffer(); - for (;;) { - sb.append(c); - c = next(); - if (Character.isWhitespace(c)) { - return sb.toString(); - } - switch (c) { - case 0: - case '>': - case '/': - case '=': - case '!': - case '?': - case '[': - case ']': - back(); - return sb.toString(); - case '<': - case '"': - case '\'': - throw syntaxError("Bad character in a name."); - } - } - } - } -} diff --git a/dependencies/pom.xml b/dependencies/pom.xml index ae9b83161..048065257 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -203,6 +203,11 @@ jackson-core 2.7.4
    + + com.fasterxml.jackson.datatype + jackson-datatype-json-org + 2.7.4 + + + javadoc + test-javadoc + + + + aggregate + false + + aggregate + + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.5 + + + aggregate + + aggregate + test-aggregate + + + + + + + + + vivo-project + https://vivo-project.github.io/ + ossrh https://oss.sonatype.org/content/repositories/snapshots From 4859eb7da1fabb5a3e091f5d08495e28e4017b79 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Mon, 18 Sep 2017 00:21:04 +0100 Subject: [PATCH 24/90] Various code improvements from IntelliJ inspections --- .../mannlib/semservices/util/XMLUtils.java | 10 +-- .../mannlib/vedit/beans/DynamicField.java | 1 - .../vedit/controller/BaseEditController.java | 1 - .../vedit/controller/OperationController.java | 73 +++++++++-------- .../vedit/forwarder/impl/UrlForwarder.java | 3 - .../mannlib/vedit/tags/DynamicFieldsTag.java | 33 ++++---- .../cornell/mannlib/vedit/tags/EditTag.java | 3 - .../cornell/mannlib/vedit/tags/ErrorTag.java | 3 +- .../cornell/mannlib/vedit/tags/ValueTag.java | 1 - .../cornell/mannlib/vedit/util/FormUtils.java | 2 +- .../cornell/mannlib/vedit/util/Stemmer.java | 34 ++++---- .../validator/impl/EnumValuesValidator.java | 15 ++-- .../vedit/validator/impl/UrlValidator.java | 4 +- .../application/VitroHomeDirectory.java | 4 +- .../bean/PropertyRestrictionBeanImpl.java | 11 +-- .../PublishObjectPropertyStatement.java | 1 - .../vitro/webapp/beans/ApplicationBean.java | 2 - .../webapp/beans/DataPropertyComparator.java | 2 +- .../webapp/beans/DataPropertyStatement.java | 4 - .../beans/DataPropertyStatementImpl.java | 2 - .../vitro/webapp/beans/ObjectProperty.java | 8 +- .../webapp/beans/ObjectPropertyStatement.java | 1 - .../beans/ObjectPropertyStatementImpl.java | 1 - .../vitro/webapp/beans/PermissionSet.java | 6 +- .../vitro/webapp/beans/PropertyInstance.java | 2 - .../webapp/beans/PropertyInstanceIface.java | 2 - .../ConfigurationPropertiesSmokeTests.java | 1 - .../webapp/controller/MailUsersServlet.java | 26 +++--- .../webapp/controller/OntologyController.java | 9 +- .../controller/SparqlQueryBuilderServlet.java | 1 - .../accounts/admin/UserAccountsEditPage.java | 3 +- .../UserAccountsFirstTimeExternalPage.java | 3 +- .../user/UserAccountsPasswordBasePage.java | 3 +- .../ajax/SparqlQueryAjaxController.java | 3 +- .../api/SparqlUpdateApiController.java | 1 - .../SparqlQueryApiRdfProducer.java | 1 - .../authenticate/Authenticator.java | 6 +- .../authenticate/LoginExternalAuthReturn.java | 6 +- .../controller/authenticate/ProgramLogin.java | 3 +- .../dumprestore/DumpRestoreController.java | 2 - .../dumprestore/NQuadLineSplitter.java | 6 +- .../webapp/controller/edit/Authenticate.java | 9 +- .../Classes2ClassesOperationController.java | 72 +++++++++------- .../edit/ClassgroupRetryController.java | 2 +- .../controller/edit/EntityEditController.java | 12 +-- ...perties2PropertiesOperationController.java | 7 +- .../edit/PropertyGroupRetryController.java | 2 +- .../edit/RefactorOperationController.java | 20 +++-- .../edit/RefactorRetryController.java | 18 ++-- .../edit/RestrictionOperationController.java | 82 ++++++++++--------- .../edit/RestrictionRetryController.java | 55 +++++++------ .../controller/edit/VclassEditController.java | 2 +- .../listing/ListingControllerWebUtils.java | 10 +-- .../edit/utils/LocalNamespaceClassUtils.java | 6 +- .../freemarker/DumpTestController.java | 5 +- .../freemarker/FreemarkerHttpServlet.java | 3 +- .../freemarker/ImageUploadHelper.java | 3 - .../freemarker/ListClassGroupsController.java | 30 +++---- .../ListDatatypePropertiesController.java | 22 ++--- .../ListPropertyGroupsController.java | 32 ++++---- .../ListPropertyWebappsController.java | 24 +++--- .../ListVClassWebappsController.java | 18 ++-- .../ShowClassHierarchyController.java | 44 +++++----- .../ShowDataPropertyHierarchyController.java | 42 +++++----- ...ShowObjectPropertyHierarchyController.java | 42 +++++----- .../freemarker/TemplateProcessingHelper.java | 1 - .../controller/freemarker/TestController.java | 4 - .../controller/freemarker/UrlBuilder.java | 29 ++++--- .../freemarker/ViewLabelsServlet.java | 4 - .../grefine/GrefineMqlreadServlet.java | 2 - .../grefine/GrefinePropertyListServlet.java | 6 +- .../grefine/JSONReconcileServlet.java | 6 +- .../individual/IndividualResponseBuilder.java | 6 +- .../individuallist/IndividualJsonWrapper.java | 1 - .../IndividualListResultsUtils.java | 1 - .../controller/jena/JenaAdminActions.java | 32 ++++---- .../jena/JenaCsv2RdfController.java | 1 - .../controller/jena/JenaExportController.java | 67 ++++++++------- .../controller/jena/JenaIngestController.java | 6 +- .../controller/jena/RDFUploadController.java | 3 +- .../controller/json/GetAllVClasses.java | 1 - .../GetRandomSearchIndividualsByVClass.java | 1 - .../GetRenderedSearchIndividualsByVClass.java | 1 - .../json/GetSearchIndividualsByVClass.java | 1 - .../json/GetVClassesForVClassGroup.java | 2 - .../controller/json/JsonObjectProducer.java | 2 - .../vitro/webapp/dao/NewURIMakerVitro.java | 1 - .../vitro/webapp/dao/PropertyGroupDao.java | 1 - .../vitro/webapp/dao/PropertyInstanceDao.java | 2 - .../DataPropertyStatementFiltering.java | 3 - .../FilteringPropertyInstanceDao.java | 10 +-- .../dao/filtering/IndividualFiltering.java | 5 +- .../ObjectPropertyStatementFiltering.java | 1 - .../filtering/PropertyGroupDaoFiltering.java | 7 +- .../dao/filtering/VClassDaoFiltering.java | 1 - .../filters/EntityPropertyListFilter.java | 2 - .../filtering/filters/VitroFiltersImpl.java | 1 - .../webapp/dao/jena/DisplayModelDaoJena.java | 2 +- .../webapp/dao/jena/IndividualDaoJena.java | 6 +- .../webapp/dao/jena/IndividualDaoSDB.java | 2 - .../vitro/webapp/dao/jena/IndividualSDB.java | 8 -- .../vitro/webapp/dao/jena/JenaBaseDao.java | 9 +- .../vitro/webapp/dao/jena/JenaModelUtils.java | 16 ++-- .../jena/ObjectPropertyStatementDaoJena.java | 2 - .../webapp/dao/jena/PropertyDaoJena.java | 42 +++++----- .../dao/jena/PropertyInstanceDaoJena.java | 1 - .../vitro/webapp/dao/jena/QueryUtils.java | 2 - .../webapp/dao/jena/RDFServiceDataset.java | 1 - .../dao/jena/RDFServiceDatasetGraph.java | 4 +- .../webapp/dao/jena/RDFServiceGraph.java | 27 +++--- .../vitro/webapp/dao/jena/SparqlGraph.java | 22 ++--- .../vitro/webapp/dao/jena/VClassDaoJena.java | 57 ++++++------- .../vitro/webapp/dao/jena/VClassDaoSDB.java | 5 +- .../webapp/dao/jena/WebappDaoFactorySDB.java | 3 +- .../n3editing/VTwo/BaseEditElementVTwo.java | 4 +- .../n3editing/VTwo/BasicValidationVTwo.java | 16 ++-- .../VTwo/DateTimeWithPrecisionVTwo.java | 16 +--- .../VTwo/EditConfigurationUtils.java | 8 +- .../n3editing/VTwo/EditConfigurationVTwo.java | 4 +- .../n3editing/VTwo/EditN3GeneratorVTwo.java | 3 - .../edit/n3editing/VTwo/N3EditUtils.java | 2 +- .../edit/n3editing/VTwo/ProcessRdfForm.java | 17 ++-- ...vidualsViaObjectPropertyByRankOptions.java | 3 +- .../IndividualsViaObjectPropetyOptions.java | 6 +- .../fields/IndividualsViaVClassOptions.java | 6 +- .../VTwo/fields/SelectListGeneratorVTwo.java | 1 - .../EditConfigurationConstants.java | 2 - .../DateTimeIntervalFormGenerator.java | 7 -- .../generators/DateTimePropertyGenerator.java | 14 ---- .../DateTimeValueFormGenerator.java | 6 -- ...aultAddMissingIndividualFormGenerator.java | 11 ++- .../DefaultObjectPropertyFormGenerator.java | 5 +- .../InstitutionalInternalClassForm.java | 5 +- .../DefaultDataPropEmptyField.java | 1 - .../FoafNameToRdfsLabelPreprocessor.java | 5 -- ...ManageLabelsForIndividualPreprocessor.java | 10 --- .../validators/AntiXssValidation.java | 8 +- .../DefaultDataPropertyFormValidator.java | 1 - .../controller/EditRequestAJAXController.java | 10 +-- .../EditRequestDispatchController.java | 29 ++----- .../controller/ProcessRdfFormController.java | 10 +-- .../webapp/email/FreemarkerEmailFactory.java | 4 +- .../webapp/email/FreemarkerEmailMessage.java | 12 +-- .../webapp/filestorage/model/FileInfo.java | 4 +- .../webapp/filters/RequestLoggerFilter.java | 2 +- .../vitro/webapp/filters/VitroURL.java | 7 +- .../config/FreemarkerConfigurationImpl.java | 5 +- .../imageio/IIOImageProcessor.java | 1 - .../imageprocessor/jai/JaiImageProcessor.java | 1 - .../webapp/ontology/update/ABoxUpdater.java | 2 - .../ontology/update/KnowledgeBaseUpdater.java | 4 +- .../ontology/update/OntologyChangeParser.java | 1 - .../webapp/ontology/update/TBoxUpdater.java | 5 +- .../adapters/BulkUpdatingModel.java | 5 -- .../adapters/BulkUpdatingOntModel.java | 1 - .../adapters/MemoryMappedModel.java | 3 - .../adapters/RDFServiceBulkUpdater.java | 5 +- .../adapters/SparqlBulkUpdater.java | 6 +- .../rdfservice/impl/RDFServiceImpl.java | 11 ++- .../rdfservice/impl/jena/RDFServiceJena.java | 10 +-- .../impl/jena/sdb/RDFServiceSDB.java | 4 +- .../impl/sparql/RDFServiceSparql.java | 24 +++--- .../impl/sparql/RDFServiceSparqlHttp.java | 2 - .../impl/virtuoso/RDFServiceVirtuoso.java | 1 - .../vitro/webapp/reasoner/ABoxRecomputer.java | 12 +-- .../vitro/webapp/reasoner/SimpleReasoner.java | 12 +-- .../webapp/reasoner/plugin/DisableSameAs.java | 4 +- .../reasoner/plugin/SimpleBridgingRule.java | 2 +- .../controller/AutocompleteController.java | 2 - .../DataAutocompleteController.java | 1 - .../controller/PagedSearchController.java | 16 +--- .../controller/SearchHelpController.java | 16 ---- .../solr/SolrConversionUtils.java | 1 - .../searchindex/IndexingChangeListener.java | 4 - .../DocumentModifierListDeveloper.java | 10 +-- .../documentBuilding/ThumbnailImageURL.java | 4 +- .../ExcludeBasedOnTypeNamespace.java | 6 +- .../SearchIndexExcluderListDeveloper.java | 10 +-- .../IndexingUriFinderListDeveloper.java | 10 +-- .../webapp/servlet/setup/FileGraphSetup.java | 5 -- .../servlet/setup/RunSparqlConstructs.java | 2 +- .../webapp/servlet/setup/SolrSmokeTest.java | 4 +- .../vitro/webapp/sparql/GetAllClasses.java | 10 +-- .../vitro/webapp/sparql/GetAllPrefix.java | 8 +- .../webapp/sparql/GetClazzAllProperties.java | 11 +-- .../webapp/sparql/GetClazzDataProperties.java | 14 ++-- .../sparql/GetClazzObjectProperties.java | 10 +-- .../vitro/webapp/sparql/GetObjectClasses.java | 13 ++- .../vitro/webapp/startup/StartupManager.java | 8 +- .../ConfiguredReasonerListener.java | 6 +- .../impl/jfact/JFactTBoxReasoner.java | 1 - .../mannlib/vitro/webapp/utils/Csv2Rdf.java | 7 +- .../webapp/utils/FrontEndEditingUtils.java | 10 --- .../vitro/webapp/utils/JsonToFmModel.java | 2 +- .../mannlib/vitro/webapp/utils/Stemmer.java | 34 ++++---- .../utils/dataGetter/DataGetterUtils.java | 2 - .../utils/dataGetter/FixedHTMLDataGetter.java | 6 -- .../utils/jena/ExtendedLinkedDataUtils.java | 2 +- .../webapp/utils/jena/JenaIngestUtils.java | 6 +- .../webapp/utils/jena/JenaOutputUtils.java | 3 +- .../jena/criticalsection/LockedModel.java | 3 - .../vitro/webapp/utils/log/LogUtils.java | 6 +- .../vitro/webapp/utils/logging/ToString.java | 2 +- .../webapp/utils/searchengine/Formatter.java | 27 ++---- .../utils/sparql/ResultSetIterators.java | 2 +- .../mannlib/vitro/webapp/web/AntiScript.java | 12 +-- .../mannlib/vitro/webapp/web/ContentType.java | 4 +- .../vitro/webapp/web/MiscWebUtils.java | 38 +++------ .../IndividualShortViewDirective.java | 4 +- .../webapp/web/images/PlaceholderUtil.java | 1 - .../vitro/webapp/web/jsptags/JsonSet.java | 2 +- .../web/jsptags/OptionsForClassTag.java | 4 - .../web/methods/BaseTemplateMethodModel.java | 1 - .../web/templatemodels/BaseTemplateModel.java | 1 - .../vitro/webapp/web/templatemodels/Tags.java | 1 - .../DataPropertyListConfig.java | 2 - ...MultiValueEditSubmissionTemplateModel.java | 1 - .../BaseObjectPropertyDataPostProcessor.java | 4 - .../CollatedObjectPropertyTemplateModel.java | 6 -- .../individual/GroupedPropertyList.java | 9 +- .../IndividualTemplateModelBuilder.java | 1 - .../PropertyGroupTemplateModel.java | 24 ++---- .../individual/PropertyTemplateModel.java | 1 - .../individual/SubclassTemplateModel.java | 5 +- .../webapp/web/templatemodels/menu/Menu.java | 1 - .../searchresult/IndividualSearchResult.java | 8 +- .../vitro/opensocial/GadgetController.java | 6 +- .../vitro/opensocial/OpenSocialManager.java | 38 ++++----- .../opensocial/OpenSocialSmokeTests.java | 3 - .../ext/beans/WrapperExtractor.java | 2 - .../ext/dump/BaseDumpDirective.java | 1 - .../linkeddatafragments/util/MIMEParse.java | 4 +- ...DFServiceBasedRequestProcessorForTPFs.java | 18 +--- .../rdfservice/RDFServiceDataSource.java | 2 - .../rdfservice/RDFServiceDataSourceType.java | 2 - .../VitroLinkedDataFragmentServlet.java | 5 +- .../HtmlTriplePatternFragmentWriterImpl.java | 2 +- .../vitro/testing/AbstractTestClass.java | 12 +-- .../factory/HasPermissionFactoryTest.java | 5 +- .../controller/api/SparqlUpdateApiTest.java | 2 - .../authenticate/ProgramLoginTest.java | 7 +- .../dumprestore/NQuadLineSplitterTest.java | 1 - .../ListClassGroupsControllerTest.java | 6 +- .../controller/json/JsonServletTest.java | 5 -- .../IndividualFilteringByStatementTest.java | 6 +- .../filters/VitroFiltersFactoryTest.java | 9 -- .../dao/jena/DataPropertyDaoJenaTest.java | 3 - .../dao/jena/ObjectPropertyDaoJenaTest.java | 3 - .../dao/jena/PropertyInstanceDaoJenaTest.java | 1 - .../vitro/webapp/dao/jena/QueryUtilsTest.java | 2 - .../dao/jena/UserAccountsDaoJenaTest.java | 6 +- .../vitro/webapp/dao/jena/VClassJenaTest.java | 14 ++-- .../vitro/webapp/edit/EditLiteralTest.java | 1 - .../processEdit/RdfLiteralHashTest.java | 11 --- .../URLRewritingHttpServletResponseTest.java | 2 - .../adapters/ListCachingModelMakerTest.java | 1 - .../adapters/VitroModelFactoryTest.java | 4 +- .../LanguageFilteringRDFServiceTest.java | 1 - .../setup/UpdateKnowledgeBaseTest.java | 12 +-- .../ConfigurationBeanLoaderTest.java | 5 -- .../StringResultsMappingTest.java | 4 +- .../ext/dump/DumpDirectiveTest.java | 4 +- .../modelaccess/ContextModelAccessStub.java | 1 - .../servlet/http/HttpServletRequestStub.java | 4 +- .../servlet/http/HttpServletResponseStub.java | 1 - .../templates/edit/fetch/horizontal.jsp | 2 +- .../edit/specific/ents_edit_head.jsp | 2 +- 267 files changed, 879 insertions(+), 1400 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/semservices/util/XMLUtils.java b/api/src/main/java/edu/cornell/mannlib/semservices/util/XMLUtils.java index 4a2cb0ef3..86a043c9a 100644 --- a/api/src/main/java/edu/cornell/mannlib/semservices/util/XMLUtils.java +++ b/api/src/main/java/edu/cornell/mannlib/semservices/util/XMLUtils.java @@ -134,10 +134,7 @@ public class XMLUtils { Transformer transformer = null; try { transformer = TransformerFactory.newInstance().newTransformer(); - } catch (TransformerConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (TransformerFactoryConfigurationError e) { + } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -164,10 +161,7 @@ public class XMLUtils { Transformer transformer = null; try { transformer = TransformerFactory.newInstance().newTransformer(); - } catch (TransformerConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (TransformerFactoryConfigurationError e) { + } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/beans/DynamicField.java b/api/src/main/java/edu/cornell/mannlib/vedit/beans/DynamicField.java index bf45c0103..ae2ebdb75 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/beans/DynamicField.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/beans/DynamicField.java @@ -3,7 +3,6 @@ package edu.cornell.mannlib.vedit.beans; import java.util.List; -import java.util.ArrayList; import java.util.HashMap; public class DynamicField { diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java b/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java index 10eb262bd..aa755021e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java @@ -32,7 +32,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; -import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; public class BaseEditController extends VitroHttpServlet { diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java b/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java index 6547be004..1d5b282f0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/controller/OperationController.java @@ -129,27 +129,31 @@ public class OperationController extends BaseEditController { notifyChangeListeners(epo, action); /* send the user somewhere */ - if (action.equals("insert")){ - // Object[] args = new Object[1]; - // args[0] = result; - // epo.setNewBean(epo.getGetMethod().invoke(facade,args)); - PageForwarder pipf = epo.getPostInsertPageForwarder(); - if (pipf != null){ - pipf.doForward(request,response,epo); - return; - } - } else if (action.equals("update")){ - PageForwarder pupf = epo.getPostUpdatePageForwarder(); - if (pupf != null) { - pupf.doForward(request,response,epo); - return; - } - } else if (action.equals("delete")){ - PageForwarder pdpf = epo.getPostDeletePageForwarder(); - if (pdpf != null) { - pdpf.doForward(request,response,epo); - return; - } + switch (action) { + case "insert": + // Object[] args = new Object[1]; + // args[0] = result; + // epo.setNewBean(epo.getGetMethod().invoke(facade,args)); + PageForwarder pipf = epo.getPostInsertPageForwarder(); + if (pipf != null) { + pipf.doForward(request, response, epo); + return; + } + break; + case "update": + PageForwarder pupf = epo.getPostUpdatePageForwarder(); + if (pupf != null) { + pupf.doForward(request, response, epo); + return; + } + break; + case "delete": + PageForwarder pdpf = epo.getPostDeletePageForwarder(); + if (pdpf != null) { + pdpf.doForward(request, response, epo); + return; + } + break; } //if no page forwarder was set, just go back to referring page: @@ -170,7 +174,6 @@ public class OperationController extends BaseEditController { try { retry(request, response, epo); - return; } catch (IOException ioe) { log.error(this.getClass().getName() + " IOError on redirect: ", ioe); } @@ -198,7 +201,6 @@ public class OperationController extends BaseEditController { } else { response.sendRedirect(getDefaultLandingPage(request)); } - return; } private void runPreprocessors(EditProcessObject epo, Object newObj) { @@ -256,14 +258,14 @@ public class OperationController extends BaseEditController { List validatorList = (List) epo.getValidatorMap().get(currParam); if (validatorList != null) { Iterator valIt = validatorList.iterator(); - String errMsg = ""; + StringBuilder errMsg = new StringBuilder(); while (valIt.hasNext()){ Validator val = (Validator)valIt.next(); ValidationObject vo = val.validate(currValue); if (!vo.getValid()){ valid = false; fieldValid = false; - errMsg += vo.getMessage() + " "; + errMsg.append(vo.getMessage()).append(" "); epo.getBadValueMap().put(currParam,currValue); } else { try { @@ -273,7 +275,7 @@ public class OperationController extends BaseEditController { } } if (errMsg.length()>0) { - epo.getErrMsgMap().put(currParam,errMsg); + epo.getErrMsgMap().put(currParam, errMsg.toString()); log.info("doPost() putting error message "+errMsg+" for "+currParam); } } @@ -330,12 +332,17 @@ public class OperationController extends BaseEditController { Iterator changeIt = changeListeners.iterator(); while (changeIt.hasNext()) { ChangeListener cl = changeIt.next(); - if (action.equals("insert")) - cl.doInserted(epo.getNewBean(),epo); - else if (action.equals("update")) - cl.doUpdated(epo.getOriginalBean(),epo.getNewBean(),epo); - else if (action.equals("delete")) - cl.doDeleted(epo.getOriginalBean(),epo); + switch (action) { + case "insert": + cl.doInserted(epo.getNewBean(), epo); + break; + case "update": + cl.doUpdated(epo.getOriginalBean(), epo.getNewBean(), epo); + break; + case "delete": + cl.doDeleted(epo.getOriginalBean(), epo); + break; + } } } } @@ -499,8 +506,6 @@ public class OperationController extends BaseEditController { } catch (InvocationTargetException f) { log.error(f.getTargetException().getMessage()); } - } catch (NoSuchMethodException e) { - //log.error("doPost() could not find setId() method for "+partialClassName); } catch (Exception f) { //log.error("doPost() could not set id of new bean."); } diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/forwarder/impl/UrlForwarder.java b/api/src/main/java/edu/cornell/mannlib/vedit/forwarder/impl/UrlForwarder.java index adcb3c10b..5104fbc9e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/forwarder/impl/UrlForwarder.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/forwarder/impl/UrlForwarder.java @@ -4,11 +4,8 @@ package edu.cornell.mannlib.vedit.forwarder.impl; import java.io.IOException; -import java.net.URLEncoder; - import edu.cornell.mannlib.vedit.forwarder.PageForwarder; import edu.cornell.mannlib.vedit.beans.EditProcessObject; -import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/tags/DynamicFieldsTag.java b/api/src/main/java/edu/cornell/mannlib/vedit/tags/DynamicFieldsTag.java index a7da820c4..927a4ba0d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/tags/DynamicFieldsTag.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/tags/DynamicFieldsTag.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Iterator; import java.io.File; -import java.io.BufferedOutputStream; import java.io.InputStream; import java.io.FileInputStream; import java.io.BufferedInputStream; @@ -16,18 +15,14 @@ import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.JspWriter; -import javax.servlet.ServletException; + import edu.cornell.mannlib.vedit.beans.FormObject; import edu.cornell.mannlib.vedit.beans.DynamicField; import edu.cornell.mannlib.vedit.beans.DynamicFieldRow; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringEscapeUtils; import edu.cornell.mannlib.vedit.tags.EditTag; public class DynamicFieldsTag extends EditTag { @@ -63,7 +58,7 @@ public class DynamicFieldsTag extends EditTag { int templateStart = -1; int postStart = -1; - InputStream fis = new FileInputStream (pageContext.getServletContext().getRealPath(new String())+PATH_SEP+MARKUP_FILE_PATH+usePage); + InputStream fis = new FileInputStream (pageContext.getServletContext().getRealPath("")+PATH_SEP+MARKUP_FILE_PATH+usePage); InputStream bis = new BufferedInputStream(fis); BufferedReader in = new BufferedReader(new InputStreamReader(bis)); List lines = new ArrayList(); @@ -83,9 +78,9 @@ public class DynamicFieldsTag extends EditTag { } in.close(); - StringBuffer preMarkupB = new StringBuffer(); - StringBuffer postMarkupB = new StringBuffer(); - StringBuffer templateMarkupB = new StringBuffer(); + StringBuilder preMarkupB = new StringBuilder(); + StringBuilder postMarkupB = new StringBuilder(); + StringBuilder templateMarkupB = new StringBuilder(); if (templateStart>preStart && preStart>0) { for (int i=preStart+1; i0) { - StringBuffer taName = new StringBuffer().append("_").append(dynf.getTable()).append("_"); + StringBuilder taName = new StringBuilder().append("_").append(dynf.getTable()).append("_"); taName.append(row.getId()).append("_"); Iterator paramIt = row.getParameterMap().keySet().iterator(); while(paramIt.hasNext()) { @@ -184,7 +179,7 @@ public class DynamicFieldsTag extends EditTag { taName.append(key).append(":").append(new String(valueInBase64)).append(";"); } if (row.getValue().length()>0) { - String templateWithVars = new String(templateMarkup); + String templateWithVars = templateMarkup; templateWithVars = strReplace(templateWithVars,type+"NN",Integer.toString(i)); templateWithVars = strReplace(templateWithVars,"\\$taName",taName.toString()); templateWithVars = strReplace(templateWithVars,"\\$\\$",row.getValue()); @@ -199,14 +194,14 @@ public class DynamicFieldsTag extends EditTag { // output the row template for the javascript to clone out.println(""); - String hiddenTemplatePreMarkup = new String(preMarkup); + String hiddenTemplatePreMarkup = preMarkup; // bit of a hack to hide the template from the user: hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:none\\;",""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:block\\;",""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:inline\\;",""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"style\\=\\\"","style=\"display:none;"); out.print(hiddenTemplatePreMarkup); - String hiddenTemplateTemplateMarkup = new String(templateMarkup); + String hiddenTemplateTemplateMarkup = templateMarkup; hiddenTemplateTemplateMarkup = strReplace(hiddenTemplateTemplateMarkup, "\\$\\$", ""); out.print(hiddenTemplateTemplateMarkup); out.print(postMarkup); diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/tags/EditTag.java b/api/src/main/java/edu/cornell/mannlib/vedit/tags/EditTag.java index 95b713dd9..e20a8de83 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/tags/EditTag.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/tags/EditTag.java @@ -5,13 +5,10 @@ package edu.cornell.mannlib.vedit.tags; import java.util.HashMap; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; -import javax.servlet.jsp.JspWriter; import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.beans.FormObject; -import org.apache.commons.lang3.StringEscapeUtils; public class EditTag extends TagSupport { private String name = null; diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/tags/ErrorTag.java b/api/src/main/java/edu/cornell/mannlib/vedit/tags/ErrorTag.java index 2242b044a..482504b79 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/tags/ErrorTag.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/tags/ErrorTag.java @@ -3,9 +3,8 @@ package edu.cornell.mannlib.vedit.tags; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.JspWriter; -import edu.cornell.mannlib.vedit.beans.FormObject; + import edu.cornell.mannlib.vedit.tags.EditTag; import org.apache.commons.lang3.StringEscapeUtils; diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/tags/ValueTag.java b/api/src/main/java/edu/cornell/mannlib/vedit/tags/ValueTag.java index 9efbb8522..650bfbf35 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/tags/ValueTag.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/tags/ValueTag.java @@ -5,7 +5,6 @@ package edu.cornell.mannlib.vedit.tags; import java.util.HashMap; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.JspWriter; import edu.cornell.mannlib.vedit.beans.FormObject; import org.apache.commons.lang3.StringEscapeUtils; diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/util/FormUtils.java b/api/src/main/java/edu/cornell/mannlib/vedit/util/FormUtils.java index 20ef40006..ba9f8fcce 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/util/FormUtils.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/util/FormUtils.java @@ -226,7 +226,7 @@ public class FormUtils { Option sOpt = new Option(); sOpt.setValue(selectedValue); if (selectedBody == null || selectedBody.length() == 0) - sOpt.setBody(selectedValue.toString()); + sOpt.setBody(selectedValue); else sOpt.setBody(selectedBody); sOpt.setSelected(true); diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/util/Stemmer.java b/api/src/main/java/edu/cornell/mannlib/vedit/util/Stemmer.java index 753a0b791..5b84d7053 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/util/Stemmer.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/util/Stemmer.java @@ -71,7 +71,7 @@ class Stemmer public void add(char ch) { if (i == b.length) { char[] new_b = new char[i+INC]; - for (int c = 0; c < i; c++) new_b[c] = b[c]; + System.arraycopy(b, 0, new_b, 0, i); b = new_b; } b[i++] = ch; @@ -86,7 +86,7 @@ class Stemmer public void add(char[] w, int wLen) { if (i+wLen >= b.length) { char[] new_b = new char[i+wLen+INC]; - for (int c = 0; c < i; c++) new_b[c] = b[c]; + System.arraycopy(b, 0, new_b, 0, i); b = new_b; } for (int c = 0; c < wLen; c++) b[i++] = w[c]; @@ -116,7 +116,7 @@ class Stemmer private final boolean cons(int i) { switch (b[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': return false; - case 'y': return (i==0) ? true : !cons(i-1); + case 'y': return (i == 0) || !cons(i - 1); default: return true; } } @@ -368,7 +368,7 @@ class Stemmer public static String StemString( String inputStr, int maxLength ) { - String outputStr=""; + StringBuilder outputStr= new StringBuilder(); int previousCh=0; char[] w = new char[maxLength]; @@ -396,19 +396,19 @@ class Stemmer { String u; u = s.toString(); - outputStr += u; + outputStr.append(u); if ( ch == '-' ) { // replace - with space - outputStr += " "; + outputStr.append(" "); } else if ( ch == '.' ) { if ( Character.isDigit( (char) previousCh )) { - outputStr += "."; + outputStr.append("."); } else { - outputStr += " "; + outputStr.append(" "); //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass } } else { Character Ch = new Character((char) ch); - outputStr += Ch.toString(); + outputStr.append(Ch.toString()); } stemmerInputBufferIndex=0; // to avoid repeats after ) } @@ -422,7 +422,7 @@ class Stemmer if ( !Character.isWhitespace((char) previousCh ) ) { if ( previousCh != '.' ) { Character Ch = new Character((char) ch); - outputStr += Ch.toString(); + outputStr.append(Ch.toString()); } } } else if ( ch == '(' ) { // open paren; copy all characters until close paren @@ -449,21 +449,21 @@ class Stemmer stemmerInputBufferIndex=0; } else if ( ch == ')' ) { // when is last character of input string Character Ch = new Character((char) ch); - outputStr += Ch.toString(); + outputStr.append(Ch.toString()); log.trace( Ch.toString() ); log.trace("found close paren at position: " + inputArrayIndex + " of input term " + inputStr ); } else if ( ch == '-' ) { // replace - with space - outputStr += " "; + outputStr.append(" "); } else if ( ch == '.' ) { if ( Character.isDigit( (char) previousCh )) { - outputStr += "."; + outputStr.append("."); } else { - outputStr += " "; + outputStr.append(" "); //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass } } else { Character Ch = new Character((char) ch); - outputStr += Ch.toString(); + outputStr.append(Ch.toString()); } previousCh = ch; if (ch < 0) break; @@ -477,10 +477,10 @@ class Stemmer String u; u = s.toString(); - outputStr += u; + outputStr.append(u); } - return outputStr == null ? ( outputStr.equals("") ? null : outputStr.trim() ) : outputStr.trim(); + return outputStr == null || outputStr.length() == 0 ? null : outputStr.toString().trim(); } /* diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/validator/impl/EnumValuesValidator.java b/api/src/main/java/edu/cornell/mannlib/vedit/validator/impl/EnumValuesValidator.java index 71e20112c..05b7ccacb 100644 --- a/api/src/main/java/edu/cornell/mannlib/vedit/validator/impl/EnumValuesValidator.java +++ b/api/src/main/java/edu/cornell/mannlib/vedit/validator/impl/EnumValuesValidator.java @@ -3,6 +3,8 @@ package edu.cornell.mannlib.vedit.validator.impl; import edu.cornell.mannlib.vedit.validator.*; + +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; @@ -17,17 +19,17 @@ public class EnumValuesValidator implements Validator { } else { vo.setValid(false); if (legalValues.size()<7){ - String msgString = "Please enter one of "; + StringBuilder msgString = new StringBuilder("Please enter one of "); Iterator valuesIt = legalValues.iterator(); while (valuesIt.hasNext()) { String legalValue = (String) valuesIt.next(); - msgString += "'"+legalValue+"'"; + msgString.append("'").append(legalValue).append("'"); if (valuesIt.hasNext()) - msgString += ", "; + msgString.append(", "); else - msgString += "."; + msgString.append("."); } - vo.setMessage(msgString); + vo.setMessage(msgString.toString()); } else { vo.setMessage("Please enter a legal value."); @@ -38,7 +40,6 @@ public class EnumValuesValidator implements Validator { } public EnumValuesValidator (String[] legalValues){ - for (int i=0; i violIt = iri.violations(false); while(violIt.hasNext()) { - errorStr += violIt.next().getShortMessage() + " "; + errorStr.append(violIt.next().getShortMessage()).append(" "); } vo.setValid(false); vo.setMessage("Please enter a valid URL. " + errorStr); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java index 7b1ad8788..06513cdfb 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java @@ -159,8 +159,8 @@ public class VitroHomeDirectory { VHD_BUILD_PROPERTY); throw new IllegalStateException(message); } else if (foundLocations.size() > 1) { - String message = String.format("Found multiple values for the " - + "Vitro home directory: " + foundLocations); + String message = "Found multiple values for the " + + "Vitro home directory: " + foundLocations; log.warn(message); } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/policy/bean/PropertyRestrictionBeanImpl.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/policy/bean/PropertyRestrictionBeanImpl.java index 5fed6daf3..0ddbb5ee7 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/policy/bean/PropertyRestrictionBeanImpl.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/policy/bean/PropertyRestrictionBeanImpl.java @@ -145,11 +145,8 @@ public class PropertyRestrictionBeanImpl extends PropertyRestrictionBean { if (resourceUri == null || userRole == null) { return false; } - if (prohibitedNamespaces.contains(namespace(resourceUri)) - && !permittedExceptions.contains(resourceUri)) { - return false; - } - return true; + return !prohibitedNamespaces.contains(namespace(resourceUri)) + || permittedExceptions.contains(resourceUri); } @Override @@ -241,9 +238,7 @@ public class PropertyRestrictionBeanImpl extends PropertyRestrictionBean { StringBuilder buffer = new StringBuilder(); for (FullPropertyKey key : keys) { - buffer.append(key + " " + thresholdMap.get(key).getLevel(DISPLAY) - + " " + thresholdMap.get(key).getLevel(MODIFY) + " " - + thresholdMap.get(key).getLevel(PUBLISH) + "\n"); + buffer.append(key).append(" ").append(thresholdMap.get(key).getLevel(DISPLAY)).append(" ").append(thresholdMap.get(key).getLevel(MODIFY)).append(" ").append(thresholdMap.get(key).getLevel(PUBLISH)).append("\n"); } return buffer.toString(); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/publish/PublishObjectPropertyStatement.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/publish/PublishObjectPropertyStatement.java index bd5fcbbe0..cf593284f 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/publish/PublishObjectPropertyStatement.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/publish/PublishObjectPropertyStatement.java @@ -6,7 +6,6 @@ import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAct import org.apache.jena.ontology.OntModel; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction; import edu.cornell.mannlib.vitro.webapp.beans.Property; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java index 5e6c100df..c3d51788c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java @@ -7,8 +7,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.servlet.ServletContext; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyComparator.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyComparator.java index fa285934c..642ee49d8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyComparator.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyComparator.java @@ -51,7 +51,7 @@ public class DataPropertyComparator implements Comparator { if (XSD.xint.toString().equals(datatype)) { int i1 = Integer.valueOf(dps1.getData()); int i2 = Integer.valueOf(dps2.getData()); - result = ((Integer) i1).compareTo(i2); + result = Integer.compare(i1, i2); } else if (XSD.xstring.toString().equals(datatype)) { result = dps1.getData().compareTo(dps2.getData()); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatement.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatement.java index c8fcb499b..4e1e95b70 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatement.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatement.java @@ -2,10 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.beans; -import java.util.Date; - -import org.apache.jena.rdf.model.Property; - /** * a class representing a particular instance of a data property * diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatementImpl.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatementImpl.java index 2ede77d2b..98768ea56 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatementImpl.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/DataPropertyStatementImpl.java @@ -2,8 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.beans; -import java.util.Date; - /** * a class representing an particular instance of a data property * diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ObjectProperty.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ObjectProperty.java index c1f1649d4..ffc42cf14 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ObjectProperty.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/ObjectProperty.java @@ -576,16 +576,16 @@ public class ObjectProperty extends Property implements Comparable getPermissionUris() { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstance.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstance.java index 2b02301ce..61b0600e3 100755 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstance.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstance.java @@ -2,8 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.beans; -import java.util.Date; - /** Represents a Vitro object property instance. It includes values from the entities, object property statements, properties, and ent2relationships tables diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstanceIface.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstanceIface.java index 603c2523c..19e53d2e8 100755 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstanceIface.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/PropertyInstanceIface.java @@ -2,8 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.beans; -import java.util.Date; - public interface PropertyInstanceIface { //needed for PropertyInstance //object property statements diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java index dfaef633f..e5d92aeeb 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java @@ -2,7 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.config; -import java.io.File; import java.net.URI; import java.net.URISyntaxException; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java index 612dc6203..9163f571f 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java @@ -104,30 +104,30 @@ public class MailUsersServlet extends VitroHttpServlet { comments=comments.trim(); //Removed spam filtering code - StringBuffer msgBuf = new StringBuffer(); // contains the intro copy for the body of the email message + StringBuilder msgBuf = new StringBuilder(); // contains the intro copy for the body of the email message String lineSeparator = System.getProperty("line.separator"); // \r\n on windows, \n on unix // from MyLibrary msgBuf.setLength(0); //msgBuf.append("Content-Type: text/html; charset='us-ascii'" + lineSeparator); - msgBuf.append("" + lineSeparator ); - msgBuf.append("" + lineSeparator ); - msgBuf.append("" + lineSeparator ); - msgBuf.append("" + deliveryfrom + "" + lineSeparator ); - msgBuf.append("" + lineSeparator ); - msgBuf.append("" + lineSeparator ); - msgBuf.append("

    " + deliveryfrom + "

    " + lineSeparator ); - msgBuf.append("

    From: "+webusername +" (" + webuseremail + ")"+" at IP address "+request.getRemoteAddr()+"

    "+lineSeparator); + msgBuf.append("").append(lineSeparator); + msgBuf.append("").append(lineSeparator); + msgBuf.append("").append(lineSeparator); + msgBuf.append("").append(deliveryfrom).append("").append(lineSeparator); + msgBuf.append("").append(lineSeparator); + msgBuf.append("").append(lineSeparator); + msgBuf.append("

    ").append(deliveryfrom).append("

    ").append(lineSeparator); + msgBuf.append("

    From: ").append(webusername).append(" (").append(webuseremail).append(")").append(" at IP address ").append(request.getRemoteAddr()).append("

    ").append(lineSeparator); //Don't need any 'likely viewing page' portion to be emailed out to the others - msgBuf.append(lineSeparator + "

    Comments:

    " + lineSeparator ); + msgBuf.append(lineSeparator).append("

    Comments:

    ").append(lineSeparator); if (comments==null || comments.equals("")) { msgBuf.append("

    BLANK MESSAGE

    "); } else { - msgBuf.append("

    "+comments+"

    "); + msgBuf.append("

    ").append(comments).append("

    "); } - msgBuf.append("" + lineSeparator ); - msgBuf.append("" + lineSeparator ); + msgBuf.append("").append(lineSeparator); + msgBuf.append("").append(lineSeparator); String msgText = msgBuf.toString(); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java index ce3cd1c64..58b859a77 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java @@ -58,8 +58,7 @@ public class OntologyController extends VitroHttpServlet{ if( rdfFormat != null ){ doRdf(req, res, rdfFormat ); - return; - } + } } private static Pattern RDF_REQUEST = Pattern.compile("^/ontology/([^/]*)/([^/]*).rdf$"); @@ -159,8 +158,7 @@ public class OntologyController extends VitroHttpServlet{ if( ! found ){ //respond to HTTP outside of critical section doNotFound(req,res); - return; - } else { + } else { JenaOutputUtils.setNameSpacePrefixes(newModel,vreq.getWebappDaoFactory()); res.setContentType(rdfFormat.getMediaType()); String format = ""; @@ -171,8 +169,7 @@ public class OntologyController extends VitroHttpServlet{ else if ( TTL_MIMETYPE.equals(rdfFormat.getMediaType())) format ="TTL"; - newModel.write( res.getOutputStream(), format ); - return; + newModel.write( res.getOutputStream(), format ); } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java index acf738b3d..89b60a12b 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java @@ -87,7 +87,6 @@ public class SparqlQueryBuilderServlet extends BaseEditController { } doHelp(request,response); - return; } private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res){ diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java index 840e690ac..42dd4102d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java @@ -127,8 +127,7 @@ public class UserAccountsEditPage extends UserAccountsPage { + "but is not authorized to do so. Logged in as: " + LoginStatusBean.getCurrentUser(vreq)); bogusMessage = getBogusStandardMessage(vreq); - return; - } + } } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java index 4503947dc..55e860670 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java @@ -126,8 +126,7 @@ public class UserAccountsFirstTimeExternalPage extends UserAccountsPage { } if (!Authenticator.getInstance(vreq).isUserPermittedToLogin(null)) { bogusMessage = i18n.text("logins_disabled_for_maintenance"); - return; - } + } } public boolean isBogus() { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java index 9a471b4bb..3923c17b2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java @@ -121,8 +121,7 @@ public abstract class UserAccountsPasswordBasePage extends UserAccountsPage { + "' when already logged in as '" + currentUserEmail + "'"); bogusMessage = alreadyLoggedInMessage(currentUserEmail); - return; - } + } } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java index 03fbc4f5a..93a8ff861 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/ajax/SparqlQueryAjaxController.java @@ -61,8 +61,7 @@ public class SparqlQueryAjaxController extends VitroAjaxController { String queryParam = locateQueryParam(vreq); Query query = SparqlUtils.createQuery(queryParam); SparqlUtils.executeQuery(response, query, model); - return; - } catch (AjaxControllerException e) { + } catch (AjaxControllerException e) { log.error(e.getMessage()); response.sendError(e.getStatusCode()); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java index 682d73281..528217e95 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/SparqlUpdateApiController.java @@ -9,7 +9,6 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import java.io.IOException; -import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/sparqlquery/SparqlQueryApiRdfProducer.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/sparqlquery/SparqlQueryApiRdfProducer.java index 1a24e5020..0168294d8 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/sparqlquery/SparqlQueryApiRdfProducer.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/api/sparqlquery/SparqlQueryApiRdfProducer.java @@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.util.Collection; import org.apache.commons.io.IOUtils; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java index bf5aae3e5..76bc3bc20 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java @@ -197,11 +197,7 @@ public abstract class Authenticator { // InternetAddress permits a localname without hostname. // Guard against that. - if (emailAddress.indexOf('@') == -1) { - return false; - } - - return true; + return emailAddress.indexOf('@') != -1; } catch (AddressException e) { return false; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java index 1db8c4c16..153520974 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginExternalAuthReturn.java @@ -104,14 +104,12 @@ public class LoginExternalAuthReturn extends BaseLoginServlet { getAuthenticator(req).recordLoginAgainstUserAccount(userAccount, AuthenticationSource.EXTERNAL); new LoginRedirector(req, afterLoginUrl).redirectLoggedInUser(resp); - return; - } catch (LoginNotPermitted e) { + } catch (LoginNotPermitted e) { // should have been caught by isUserPermittedToLogin() log.debug("Logins disabled for " + userAccount); complainAndReturnToReferrer(req, resp, ATTRIBUTE_REFERRER, messageLoginDisabled(req)); - return; - } + } } @Override diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java index 1c775f1a0..d6f1c15d4 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/authenticate/ProgramLogin.java @@ -144,8 +144,7 @@ public class ProgramLogin extends HttpServlet { } recordLoginWithPasswordChange(); sendSuccess(MESSAGE_SUCCESS_FIRST_TIME); - return; - } + } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java index 45fabe992..6b1ef67f6 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/DumpRestoreController.java @@ -3,7 +3,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore; import java.io.IOException; -import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -22,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; /** diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/NQuadLineSplitter.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/NQuadLineSplitter.java index 580cd2635..7bff579c0 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/NQuadLineSplitter.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/datatools/dumprestore/NQuadLineSplitter.java @@ -95,11 +95,7 @@ class NQuadLineSplitter { while (!atEnd() && isWhiteSpace()) { i++; } - if (atEnd()) { - return; - } else if (line.charAt(i) == '#') { - return; - } else { + if (!atEnd() && line.charAt(i) != '#') { throw new BadNodeException( "Period was not followed by end of line: '" + line + "'"); } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java index da38df6a4..c1752f327 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Authenticate.java @@ -351,8 +351,7 @@ public class Authenticate extends VitroHttpServlet { // This should have been caught by isUserPermittedToLogin() bean.setMessage(request, ERROR, "logins_disabled_for_maintenance"); - return; - } + } } } @@ -413,8 +412,7 @@ public class Authenticate extends VitroHttpServlet { } catch (LoginNotPermitted e) { // This should have been caught by isUserPermittedToLogin() bean.setMessage(request, ERROR, "logins_disabled_for_maintenance"); - return; - } + } } /** @@ -497,8 +495,7 @@ public class Authenticate extends VitroHttpServlet { String loginProcessPage = LoginProcessBean.getBean(vreq) .getLoginPageUrl(); response.sendRedirect(loginProcessPage); - return; - } + } /** * Exit: user has completed the login. Redirect appropriately and clear the diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java index 7f8310d4e..026a55476 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Classes2ClassesOperationController.java @@ -73,16 +73,20 @@ public class Classes2ClassesOperationController extends BaseEditController { String superclassURIstr = request.getParameter("SuperclassURI"); if (superclassURIstr != null) { for (int i=0; i classList = inferredEnt.getVClasses(false); sortForPickList(classList, vreq); if (classList != null) { @@ -109,13 +109,13 @@ public class EntityEditController extends BaseEditController { } catch (Exception e) { rClassName = vc.getLocalNameWithPrefix(); } - classStr += rClassName; + classStr.append(rClassName); if (classIt.hasNext()) { - classStr += ", "; + classStr.append(", "); } } } - results.add(classStr); + results.add(classStr.toString()); results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" : ent.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel()); @@ -147,7 +147,7 @@ public class EntityEditController extends BaseEditController { Iterator externalIdIt = ent.getExternalIds().iterator(); while (externalIdIt.hasNext()) { DataPropertyStatement eid = externalIdIt.next(); - String multiplexedString = new String ("DatapropURI:" + new String(Base64.encodeBase64(eid.getDatapropURI().getBytes())) + ";" + "Data:" + new String(Base64.encodeBase64(eid.getData().getBytes()))); + String multiplexedString = "DatapropURI:" + new String(Base64.encodeBase64(eid.getDatapropURI().getBytes())) + ";" + "Data:" + new String(Base64.encodeBase64(eid.getData().getBytes())); externalIdOptionList.add(new Option(multiplexedString, eid.getData())); } } @@ -172,7 +172,7 @@ public class EntityEditController extends BaseEditController { Iterator epiIt = epiColl.iterator(); while (epiIt.hasNext()) { PropertyInstance pi = epiIt.next(); - String multiplexedString = new String ("PropertyURI:" + new String(Base64.encodeBase64(pi.getPropertyURI().getBytes())) + ";" + "ObjectEntURI:" + new String(Base64.encodeBase64(pi.getObjectEntURI().getBytes()))); + String multiplexedString = "PropertyURI:" + new String(Base64.encodeBase64(pi.getPropertyURI().getBytes())) + ";" + "ObjectEntURI:" + new String(Base64.encodeBase64(pi.getObjectEntURI().getBytes())); epiOptionList.add(new Option(multiplexedString, pi.getDomainPublic()+" "+pi.getObjectName())); } OptionMap.put("ExistingPropertyInstances", epiOptionList); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java index 166a89b4e..93fd5723a 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/Properties2PropertiesOperationController.java @@ -102,14 +102,11 @@ public class Properties2PropertiesOperationController extends } } - } catch (RuntimeException e) { + } catch (RuntimeException | Error e) { log.error("Unable to perform edit operation: ", e); throw e; - } catch (Error err) { - log.error("Unable to perform edit operation: ", err); - throw err; } - + } public void doGet(HttpServletRequest request, HttpServletResponse response) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyGroupRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyGroupRetryController.java index bd89deab9..d12316fe5 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyGroupRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/PropertyGroupRetryController.java @@ -67,7 +67,7 @@ public class PropertyGroupRetryController extends BaseEditController { } if (propertyGroupForEditing == null) { // UTF-8 expected due to URIEncoding on Connector element in server.xml - String uriToFind = new String(request.getParameter("uri")); + String uriToFind = request.getParameter("uri"); propertyGroupForEditing = (PropertyGroup)pgDao.getGroupByURI(uriToFind); } } else { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java index c8b212faf..a4e1f97bb 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorOperationController.java @@ -492,14 +492,18 @@ public class RefactorOperationController extends BaseEditController { if (vreq.getParameter("_cancel") == null) { if (modeStr != null) { - - if (modeStr.equals("renameResource")) { - redirectStr = doRenameResource(vreq, response, epo); - } else if (modeStr.equals("movePropertyStatements")) { - doMovePropertyStatements(vreq, response, epo); - } else if (modeStr.equals("moveInstances")) { - doMoveInstances(vreq, response, epo); - } + + switch (modeStr) { + case "renameResource": + redirectStr = doRenameResource(vreq, response, epo); + break; + case "movePropertyStatements": + doMovePropertyStatements(vreq, response, epo); + break; + case "moveInstances": + doMoveInstances(vreq, response, epo); + break; + } } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java index 391ba55f4..8fb612d77 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RefactorRetryController.java @@ -108,13 +108,17 @@ public class RefactorRetryController extends BaseEditController { String modeStr = request.getParameter("mode"); if (modeStr != null) { - if (modeStr.equals("renameResource")) { - doRenameResource(vreq, response, epo); - } else if (modeStr.equals("movePropertyStatements")) { - doMovePropertyStatements(vreq, response, epo); - } else if (modeStr.equals("moveInstances")) { - doMoveInstances(vreq, response, epo); - } + switch (modeStr) { + case "renameResource": + doRenameResource(vreq, response, epo); + break; + case "movePropertyStatements": + doMovePropertyStatements(vreq, response, epo); + break; + case "moveInstances": + doMoveInstances(vreq, response, epo); + break; + } } setRequestAttributes(request,epo); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java index f9c51db71..1fbefad91 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionOperationController.java @@ -83,8 +83,7 @@ public class RestrictionOperationController extends BaseEditController { log.error(e, e); try { response.sendRedirect(defaultLandingPage); - return; - } catch (Exception f) { + } catch (Exception f) { log.error(f, f); throw new RuntimeException(f); } @@ -176,47 +175,54 @@ public class RestrictionOperationController extends BaseEditController { if (cardinalityStr != null) { cardinality = Integer.decode(cardinalityStr); } - - if (restrictionTypeStr.equals("allValuesFrom")) { - rest = ontModel.createAllValuesFromRestriction(null,onProperty,roleFiller); - } else if (restrictionTypeStr.equals("someValuesFrom")) { - rest = ontModel.createSomeValuesFromRestriction(null,onProperty,roleFiller); - } else if (restrictionTypeStr.equals("hasValue")) { - String valueURI = request.getParameter("ValueIndividual"); - if (valueURI != null) { - Resource valueRes = ontModel.getResource(valueURI); - if (valueRes != null) { - rest = ontModel.createHasValueRestriction(null, onProperty, valueRes); - } - } else { - String valueLexicalForm = request.getParameter("ValueLexicalForm"); - if (valueLexicalForm != null) { - String valueDatatype = request.getParameter("ValueDatatype"); - Literal value = null; - if (valueDatatype != null && valueDatatype.length() > 0) { - RDFDatatype dtype = null; - try { - dtype = TypeMapper.getInstance().getSafeTypeByName(valueDatatype); - } catch (Exception e) { - log.warn ("Unable to get safe type " + valueDatatype + " using TypeMapper"); - } - if (dtype != null) { - value = ontModel.createTypedLiteral(valueLexicalForm, dtype); + + switch (restrictionTypeStr) { + case "allValuesFrom": + rest = ontModel.createAllValuesFromRestriction(null, onProperty, roleFiller); + break; + case "someValuesFrom": + rest = ontModel.createSomeValuesFromRestriction(null, onProperty, roleFiller); + break; + case "hasValue": + String valueURI = request.getParameter("ValueIndividual"); + if (valueURI != null) { + Resource valueRes = ontModel.getResource(valueURI); + if (valueRes != null) { + rest = ontModel.createHasValueRestriction(null, onProperty, valueRes); + } + } else { + String valueLexicalForm = request.getParameter("ValueLexicalForm"); + if (valueLexicalForm != null) { + String valueDatatype = request.getParameter("ValueDatatype"); + Literal value = null; + if (valueDatatype != null && valueDatatype.length() > 0) { + RDFDatatype dtype = null; + try { + dtype = TypeMapper.getInstance().getSafeTypeByName(valueDatatype); + } catch (Exception e) { + log.warn("Unable to get safe type " + valueDatatype + " using TypeMapper"); + } + if (dtype != null) { + value = ontModel.createTypedLiteral(valueLexicalForm, dtype); + } else { + value = ontModel.createLiteral(valueLexicalForm); + } } else { value = ontModel.createLiteral(valueLexicalForm); } - } else { - value = ontModel.createLiteral(valueLexicalForm); + rest = ontModel.createHasValueRestriction(null, onProperty, value); } - rest = ontModel.createHasValueRestriction(null, onProperty, value); } - } - } else if (restrictionTypeStr.equals("minCardinality")) { - rest = ontModel.createMinCardinalityRestriction(null,onProperty,cardinality); - } else if (restrictionTypeStr.equals("maxCardinality")) { - rest = ontModel.createMaxCardinalityRestriction(null,onProperty,cardinality); - } else if (restrictionTypeStr.equals("cardinality")) { - rest = ontModel.createCardinalityRestriction(null,onProperty,cardinality); + break; + case "minCardinality": + rest = ontModel.createMinCardinalityRestriction(null, onProperty, cardinality); + break; + case "maxCardinality": + rest = ontModel.createMaxCardinalityRestriction(null, onProperty, cardinality); + break; + case "cardinality": + rest = ontModel.createCardinalityRestriction(null, onProperty, cardinality); + break; } if (conditionTypeStr.equals("necessary")) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionRetryController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionRetryController.java index 79438c49b..ec6d6e6ba 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionRetryController.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/edit/RestrictionRetryController.java @@ -66,29 +66,38 @@ public class RestrictionRetryController extends BaseEditController { epo.setFormObject(new FormObject()); epo.getFormObject().getOptionLists().put("onProperty", onPropertyList); - - if (restrictionTypeStr.equals("someValuesFrom")) { - request.setAttribute("specificRestrictionForm","someValuesFromRestriction_retry.jsp"); - List